class BitBucket::Issues

Constants

VALID_ISSUE_PARAM_NAMES
VALID_ISSUE_PARAM_VALUES

Public Class Methods

new(options = {}) click to toggle source

Creates new Issues API

Calls superclass method BitBucket::API::new
# File lib/bitbucket_rest_api/issues.rb, line 35
def initialize(options = {})
  super(options)
end

Public Instance Methods

comments() click to toggle source

Access to Issues::Comments API

# File lib/bitbucket_rest_api/issues.rb, line 40
def comments
  @comments ||= ApiFactory.new 'Issues::Comments'
end
components() click to toggle source

Access to Issues::Components API

# File lib/bitbucket_rest_api/issues.rb, line 45
def components
  @components ||= ApiFactory.new 'Issues::Components'
end
create(user_name, repo_name, params = {}) click to toggle source

Create an issue

Inputs

<tt>:title</tt> - Required string
<tt>:content</tt> - Optional string
<tt>:responsible</tt> - Optional string - Login for the user that this issue should be assigned to.
<tt>:milestone</tt> - Optional number - Milestone to associate this issue with
<tt>:version</tt> - Optional number - Version to associate this issue with
<tt>:component</tt> - Optional number - Component to associate this issue with
<tt>:priority</tt> - Optional string - The priority of this issue
* <tt>trivial</tt>
* <tt>minor</tt>
* <tt>major</tt>
* <tt>critical</tt>
* <tt>blocker</tt>
<tt>:status</tt> - Optional string - The status of this issue
* <tt>new</tt>
* <tt>open</tt>
* <tt>resolved</tt>
* <tt>on hold</tt>
* <tt>invalid</tt>
* <tt>duplicate</tt>
* <tt>wontfix</tt>
<tt>:kind</tt> - Optional string - The kind of issue
* <tt>bug</tt>
* <tt>enhancement</tt>
* <tt>proposal</tt>
* <tt>task</tt>

Examples

bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
bitbucket.issues.create
  "title" => "Found a bug",
  "content" => "I'm having a problem with this.",
  "responsible" => "octocat",
  "milestone" => 1,
  "priority" => "blocker"
# File lib/bitbucket_rest_api/issues.rb, line 166
def create(user_name, repo_name, params = {})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?

  normalize! params
  _merge_user_into_params!(params) unless params.key?('user')
  # _merge_mime_type(:issue, params)
  filter! VALID_ISSUE_PARAM_NAMES, params
  assert_required_keys(%w[title], params)

  post_request("/1.0/repositories/#{user}/#{repo.downcase}/issues/", params)
end
delete(user_name, repo_name, issue_id, params = {}) click to toggle source

Delete a single issue

Examples

bitbucket = BitBucket.new
bitbucket.issues.delete 'user-name', 'repo-name', 'issue-id'
# File lib/bitbucket_rest_api/issues.rb, line 117
def delete(user_name, repo_name, issue_id, params = {})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of issue_id

  normalize! params
  # _merge_mime_type(:issue, params)

  delete_request("/1.0/repositories/#{user}/#{repo}/issues/#{issue_id}", params)
end
edit(user_name, repo_name, issue_id, params = {}) click to toggle source

Edit an issue

Inputs

<tt>:title</tt> - Required string
<tt>:content</tt> - Optional string
<tt>:responsible</tt> - Optional string - Login for the user that this issue should be assigned to.
<tt>:milestone</tt> - Optional number - Milestone to associate this issue with
<tt>:version</tt> - Optional number - Version to associate this issue with
<tt>:component</tt> - Optional number - Component to associate this issue with
<tt>:priority</tt> - Optional string - The priority of this issue
* <tt>trivial</tt>
* <tt>minor</tt>
* <tt>major</tt>
* <tt>critical</tt>
* <tt>blocker</tt>
<tt>:status</tt> - Optional string - The status of this issue
* <tt>new</tt>
* <tt>open</tt>
* <tt>resolved</tt>
* <tt>on hold</tt>
* <tt>invalid</tt>
* <tt>duplicate</tt>
* <tt>wontfix</tt>
<tt>:kind</tt> - Optional string - The kind of issue
* <tt>bug</tt>
* <tt>enhancement</tt>
* <tt>proposal</tt>
* <tt>task</tt>

Examples

bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
bitbucket.issues.create
  "title" => "Found a bug",
  "content" => "I'm having a problem with this.",
  "responsible" => "octocat",
  "milestone" => 1,
  "priority" => "blocker"
# File lib/bitbucket_rest_api/issues.rb, line 217
def edit(user_name, repo_name, issue_id, params = {})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of issue_id

  normalize! params
  # _merge_mime_type(:issue, params)
  filter! VALID_ISSUE_PARAM_NAMES, params

  put_request("/1.0/repositories/#{user}/#{repo.downcase}/issues/#{issue_id}/", params)
end
find(user_name, repo_name, issue_id, params = {})
Alias for: get
get(user_name, repo_name, issue_id, params = {}) click to toggle source

Get a single issue

Examples

bitbucket = BitBucket.new
bitbucket.issues.get 'user-name', 'repo-name', 'issue-id'
# File lib/bitbucket_rest_api/issues.rb, line 98
def get(user_name, repo_name, issue_id, params = {})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  _validate_presence_of issue_id

  normalize! params
  # _merge_mime_type(:issue, params)

  get_request("/1.0/repositories/#{user}/#{repo.downcase}/issues/#{issue_id}", params)
end
Also aliased as: find
list_repo(user_name, repo_name, params = {}) { |el| ... } click to toggle source

List issues for a repository

Inputs

<tt>:limit</tt> - Optional - Number of issues to retrieve, default 15
<tt>:start</tt> - Optional - Issue offset, default 0
<tt>:search</tt> - Optional - A string to search for
<tt>:sort</tt> - Optional - Sorts the output by any of the metadata fields
<tt>:title</tt> - Optional - Contains a filter operation to restrict the list of issues by the issue title
<tt>:content</tt> - Optional - Contains a filter operation to restrict the list of issues by the issue content
<tt>:version</tt> - Optional - Contains an is or ! ( is not) filter to restrict the list of issues by the version
<tt>:milestone</tt> - Optional - Contains an is or ! ( is not) filter to restrict the list of issues by the milestone
<tt>:component</tt> - Optional - Contains an is or ! ( is not) filter to restrict the list of issues by the component
<tt>:kind</tt> - Optional - Contains an is or ! ( is not) filter to restrict the list of issues by the issue kind
<tt>:status</tt> - Optional - Contains an is or ! ( is not) filter to restrict the list of issues by the issue status
<tt>:responsible</tt> - Optional - Contains an is or ! ( is not) filter to restrict the list of issues by the user responsible
<tt>:reported_by</tt> - Optional - Contains a filter operation to restrict the list of issues by the user that reported the issue

Examples

bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
bitbucket.issues.list_repo :filter => 'kind=bug&kind=enhancement'
# File lib/bitbucket_rest_api/issues.rb, line 75
def list_repo(user_name, repo_name, params = {})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?

  normalize! params
  filter! VALID_ISSUE_PARAM_NAMES, params
  # _merge_mime_type(:issue, params)
  assert_valid_values(VALID_ISSUE_PARAM_VALUES, params)

  response = get_request("/1.0/repositories/#{user}/#{repo.downcase}/issues", params)
  return response.issues unless block_given?

  response.issues.each { |el| yield el }
end
Also aliased as: list_repository
list_repository(user_name, repo_name, params = {})
Alias for: list_repo
milestones() click to toggle source

Access to Issues::Milestones API

# File lib/bitbucket_rest_api/issues.rb, line 50
def milestones
  @milestones ||= ApiFactory.new 'Issues::Milestones'
end