bitbucket_rest_api2 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +7 -0
- data/README.md +169 -0
- data/lib/bitbucket_rest_api.rb +90 -0
- data/lib/bitbucket_rest_api/api.rb +106 -0
- data/lib/bitbucket_rest_api/api/actions.rb +35 -0
- data/lib/bitbucket_rest_api/api_factory.rb +30 -0
- data/lib/bitbucket_rest_api/authorization.rb +34 -0
- data/lib/bitbucket_rest_api/client.rb +56 -0
- data/lib/bitbucket_rest_api/configuration.rb +106 -0
- data/lib/bitbucket_rest_api/connection.rb +98 -0
- data/lib/bitbucket_rest_api/constants.rb +58 -0
- data/lib/bitbucket_rest_api/core_ext/array.rb +7 -0
- data/lib/bitbucket_rest_api/core_ext/hash.rb +46 -0
- data/lib/bitbucket_rest_api/deprecation.rb +39 -0
- data/lib/bitbucket_rest_api/error.rb +38 -0
- data/lib/bitbucket_rest_api/error/bad_events.rb +9 -0
- data/lib/bitbucket_rest_api/error/bad_request.rb +12 -0
- data/lib/bitbucket_rest_api/error/blank_value.rb +9 -0
- data/lib/bitbucket_rest_api/error/client_error.rb +20 -0
- data/lib/bitbucket_rest_api/error/forbidden.rb +12 -0
- data/lib/bitbucket_rest_api/error/internal_server_error.rb +12 -0
- data/lib/bitbucket_rest_api/error/invalid_options.rb +18 -0
- data/lib/bitbucket_rest_api/error/no_events.rb +9 -0
- data/lib/bitbucket_rest_api/error/not_found.rb +12 -0
- data/lib/bitbucket_rest_api/error/required_params.rb +18 -0
- data/lib/bitbucket_rest_api/error/service_error.rb +19 -0
- data/lib/bitbucket_rest_api/error/service_unavailable.rb +12 -0
- data/lib/bitbucket_rest_api/error/unauthorized.rb +12 -0
- data/lib/bitbucket_rest_api/error/unknown_value.rb +18 -0
- data/lib/bitbucket_rest_api/error/unprocessable_entity.rb +12 -0
- data/lib/bitbucket_rest_api/error/validations.rb +18 -0
- data/lib/bitbucket_rest_api/invitations.rb +15 -0
- data/lib/bitbucket_rest_api/issues.rb +230 -0
- data/lib/bitbucket_rest_api/issues/comments.rb +118 -0
- data/lib/bitbucket_rest_api/issues/components.rb +106 -0
- data/lib/bitbucket_rest_api/issues/milestones.rb +107 -0
- data/lib/bitbucket_rest_api/normalizer.rb +27 -0
- data/lib/bitbucket_rest_api/parameter_filter.rb +32 -0
- data/lib/bitbucket_rest_api/repos.rb +264 -0
- data/lib/bitbucket_rest_api/repos/changesets.rb +54 -0
- data/lib/bitbucket_rest_api/repos/commits.rb +40 -0
- data/lib/bitbucket_rest_api/repos/default_reviewers.rb +59 -0
- data/lib/bitbucket_rest_api/repos/download.rb +21 -0
- data/lib/bitbucket_rest_api/repos/following.rb +39 -0
- data/lib/bitbucket_rest_api/repos/forks.rb +69 -0
- data/lib/bitbucket_rest_api/repos/keys.rb +87 -0
- data/lib/bitbucket_rest_api/repos/pull_request.rb +160 -0
- data/lib/bitbucket_rest_api/repos/services.rb +103 -0
- data/lib/bitbucket_rest_api/repos/sources.rb +39 -0
- data/lib/bitbucket_rest_api/repos/webhooks.rb +96 -0
- data/lib/bitbucket_rest_api/request.rb +76 -0
- data/lib/bitbucket_rest_api/request/basic_auth.rb +31 -0
- data/lib/bitbucket_rest_api/request/jsonize.rb +46 -0
- data/lib/bitbucket_rest_api/request/oauth.rb +53 -0
- data/lib/bitbucket_rest_api/response.rb +28 -0
- data/lib/bitbucket_rest_api/response/helpers.rb +21 -0
- data/lib/bitbucket_rest_api/response/jsonize.rb +30 -0
- data/lib/bitbucket_rest_api/response/mashify.rb +24 -0
- data/lib/bitbucket_rest_api/response/raise_error.rb +31 -0
- data/lib/bitbucket_rest_api/response/xmlize.rb +26 -0
- data/lib/bitbucket_rest_api/result.rb +140 -0
- data/lib/bitbucket_rest_api/user.rb +101 -0
- data/lib/bitbucket_rest_api/users.rb +24 -0
- data/lib/bitbucket_rest_api/users/account.rb +53 -0
- data/lib/bitbucket_rest_api/utils/url.rb +56 -0
- data/lib/bitbucket_rest_api/validations.rb +25 -0
- data/lib/bitbucket_rest_api/validations/format.rb +24 -0
- data/lib/bitbucket_rest_api/validations/presence.rb +25 -0
- data/lib/bitbucket_rest_api/validations/required.rb +44 -0
- data/lib/bitbucket_rest_api/validations/token.rb +43 -0
- data/lib/bitbucket_rest_api/version.rb +11 -0
- data/spec/bitbucket_rest_api/api/actions_spec.rb +17 -0
- data/spec/bitbucket_rest_api/api_factory_spec.rb +30 -0
- data/spec/bitbucket_rest_api/api_spec.rb +86 -0
- data/spec/bitbucket_rest_api/authorization_spec.rb +72 -0
- data/spec/bitbucket_rest_api/client_spec.rb +15 -0
- data/spec/bitbucket_rest_api/core_ext/array_spec.rb +12 -0
- data/spec/bitbucket_rest_api/core_ext/hash_spec.rb +49 -0
- data/spec/bitbucket_rest_api/deprecation_spec.rb +30 -0
- data/spec/bitbucket_rest_api/error/bad_events_spec.rb +10 -0
- data/spec/bitbucket_rest_api/error/blank_value_spec.rb +13 -0
- data/spec/bitbucket_rest_api/error/no_events_spec.rb +10 -0
- data/spec/bitbucket_rest_api/invitations_spec.rb +21 -0
- data/spec/bitbucket_rest_api/issues/comments_spec.rb +89 -0
- data/spec/bitbucket_rest_api/issues/components_spec.rb +88 -0
- data/spec/bitbucket_rest_api/issues/milestones_spec.rb +88 -0
- data/spec/bitbucket_rest_api/issues_spec.rb +90 -0
- data/spec/bitbucket_rest_api/normalizer_spec.rb +30 -0
- data/spec/bitbucket_rest_api/parameter_filter_spec.rb +41 -0
- data/spec/bitbucket_rest_api/repos/changesets_spec.rb +43 -0
- data/spec/bitbucket_rest_api/repos/commits_spec.rb +20 -0
- data/spec/bitbucket_rest_api/repos/default_reviewers_spec.rb +64 -0
- data/spec/bitbucket_rest_api/repos/download_spec.rb +9 -0
- data/spec/bitbucket_rest_api/repos/following_spec.rb +52 -0
- data/spec/bitbucket_rest_api/repos/forks_spec.rb +45 -0
- data/spec/bitbucket_rest_api/repos/keys_spec.rb +72 -0
- data/spec/bitbucket_rest_api/repos/pull_request_spec.rb +288 -0
- data/spec/bitbucket_rest_api/repos/sources_spec.rb +77 -0
- data/spec/bitbucket_rest_api/repos/webhooks_spec.rb +245 -0
- data/spec/bitbucket_rest_api/repos_spec.rb +157 -0
- data/spec/bitbucket_rest_api/request/jsonize_spec.rb +18 -0
- data/spec/bitbucket_rest_api/request/oauth_spec.rb +27 -0
- data/spec/bitbucket_rest_api/request_spec.rb +81 -0
- data/spec/bitbucket_rest_api/response/jsonize_spec.rb +12 -0
- data/spec/bitbucket_rest_api/response/mashify_spec.rb +32 -0
- data/spec/bitbucket_rest_api/response/raise_error_spec.rb +41 -0
- data/spec/bitbucket_rest_api/user_spec.rb +77 -0
- data/spec/bitbucket_rest_api/utils/url_spec.rb +33 -0
- data/spec/bitbucket_rest_api/validations/format_spec.rb +29 -0
- data/spec/bitbucket_rest_api/validations/presence_spec.rb +12 -0
- data/spec/bitbucket_rest_api/validations/required_spec.rb +43 -0
- data/spec/bitbucket_rest_api/validations/token_spec.rb +16 -0
- data/spec/bitbucket_rest_api_spec.rb +17 -0
- data/spec/spec_helper.rb +24 -0
- metadata +373 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket
|
4
|
+
module Error
|
5
|
+
class BitBucketError < StandardError
|
6
|
+
attr_reader :response_message, :response_headers
|
7
|
+
|
8
|
+
def initialize(message)
|
9
|
+
super message
|
10
|
+
@response_message = message
|
11
|
+
end
|
12
|
+
|
13
|
+
# def inspect
|
14
|
+
# %(#<#{self.class}>)
|
15
|
+
# end
|
16
|
+
end
|
17
|
+
end # Error
|
18
|
+
end # BitBucket
|
19
|
+
|
20
|
+
%w[
|
21
|
+
service_error
|
22
|
+
not_found
|
23
|
+
forbidden
|
24
|
+
bad_request
|
25
|
+
unauthorized
|
26
|
+
service_unavailable
|
27
|
+
internal_server_error
|
28
|
+
unprocessable_entity
|
29
|
+
client_error
|
30
|
+
invalid_options
|
31
|
+
required_params
|
32
|
+
unknown_value
|
33
|
+
bad_events
|
34
|
+
no_events
|
35
|
+
blank_value
|
36
|
+
].each do |error|
|
37
|
+
require "bitbucket_rest_api/error/#{error}"
|
38
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket #:nodoc
|
4
|
+
# Raised when BitBucket returns the HTTP status code 404
|
5
|
+
module Error
|
6
|
+
class ClientError < BitBucketError
|
7
|
+
attr_reader :problem, :summary, :resolution
|
8
|
+
|
9
|
+
def initialize(message)
|
10
|
+
super(message)
|
11
|
+
end
|
12
|
+
|
13
|
+
def generate_message(attributes)
|
14
|
+
"\nProblem:\n #{attributes[:problem]}"+
|
15
|
+
"\nSummary:\n #{attributes[:summary]}"+
|
16
|
+
"\nResolution:\n #{attributes[:resolution]}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end # Error
|
20
|
+
end # BitBucket
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket #:nodoc
|
4
|
+
# Raised when invalid options are passed to a request body
|
5
|
+
module Error
|
6
|
+
class InvalidOptions < ClientError
|
7
|
+
def initialize(invalid, valid)
|
8
|
+
super(
|
9
|
+
generate_message(
|
10
|
+
:problem => "Invalid option #{invalid.keys.join(', ')} provided for this request.",
|
11
|
+
:summary => "BitBucket gem checks the request parameters passed to ensure that github api is not hit unnecessairly and to fail fast.",
|
12
|
+
:resolution => "Valid options are: #{valid.join(', ')}, make sure these are the ones you are using"
|
13
|
+
)
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end # Error
|
18
|
+
end # BitBucket
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket #:nodoc
|
4
|
+
# Raised when invalid options are passed to a request body
|
5
|
+
module Error
|
6
|
+
class RequiredParams < ClientError
|
7
|
+
def initialize(provided, required)
|
8
|
+
super(
|
9
|
+
generate_message(
|
10
|
+
:problem => "Missing required parameters: #{provided.keys.join(', ')} provided for this request.",
|
11
|
+
:summary => "BitBucket gem checks the request parameters passed to ensure that github api is not hit unnecessairly and to fail fast.",
|
12
|
+
:resolution => "Required parameters are: #{required.join(', ')}, make sure these are the ones you are using"
|
13
|
+
)
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end # Error
|
18
|
+
end # BitBucket
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket #:nodoc
|
4
|
+
# Raised when BitBucket returns any of the HTTP status codes
|
5
|
+
module Error
|
6
|
+
class ServiceError < BitBucketError
|
7
|
+
attr_accessor :http_headers
|
8
|
+
|
9
|
+
def initialize(env)
|
10
|
+
super(generate_message(env))
|
11
|
+
@http_headers = env[:response_headers]
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate_message(env)
|
15
|
+
"#{env[:method].to_s.upcase} #{env[:url].to_s}: #{env[:status]} #{env[:body]}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end # Error
|
19
|
+
end # BitBucket
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket #:nodoc
|
4
|
+
# Raised when invalid options are passed to a request body
|
5
|
+
module Error
|
6
|
+
class UnknownValue < ClientError
|
7
|
+
def initialize(key, value, permitted)
|
8
|
+
super(
|
9
|
+
generate_message(
|
10
|
+
:problem => "Wrong value of '#{value}' for the parameter: #{key} provided for this request.",
|
11
|
+
:summary => "BitBucket gem checks the request parameters passed to ensure that github api is not hit unnecessairly and fails fast.",
|
12
|
+
:resolution => "Permitted values are: #{permitted}, make sure these are the ones you are using"
|
13
|
+
)
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end # Error
|
18
|
+
end # BitBucket
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket #:nodoc
|
4
|
+
# Raised when passed parameters are missing or contain wrong values.
|
5
|
+
module Error
|
6
|
+
class Validations < ClientError
|
7
|
+
def initialize(errors)
|
8
|
+
super(
|
9
|
+
generate_message(
|
10
|
+
:problem => '',
|
11
|
+
:summary => '',
|
12
|
+
:resolution => ''
|
13
|
+
)
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end # Error
|
18
|
+
end # BitBucket
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket
|
4
|
+
class Invitations < API
|
5
|
+
def invite(user_name, repo_name, emailaddress, perm)
|
6
|
+
_update_user_repo_params(user_name, repo_name)
|
7
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
8
|
+
_validate_presence_of emailaddress
|
9
|
+
perm ||= "write"
|
10
|
+
|
11
|
+
post_request("/2.0/invitations/#{user}/#{repo.downcase}/#{emailaddress}",
|
12
|
+
permission: perm)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,230 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket
|
4
|
+
class Issues < API
|
5
|
+
extend AutoloadHelper
|
6
|
+
|
7
|
+
autoload_all 'bitbucket_rest_api/issues',
|
8
|
+
:Comments => 'comments',
|
9
|
+
:Components => 'components',
|
10
|
+
:Milestones => 'milestones'
|
11
|
+
|
12
|
+
VALID_ISSUE_PARAM_NAMES = %w[
|
13
|
+
title
|
14
|
+
content
|
15
|
+
component
|
16
|
+
milestone
|
17
|
+
version
|
18
|
+
responsible
|
19
|
+
priority
|
20
|
+
status
|
21
|
+
kind
|
22
|
+
limit
|
23
|
+
start
|
24
|
+
search
|
25
|
+
sort
|
26
|
+
reported_by
|
27
|
+
].freeze
|
28
|
+
|
29
|
+
VALID_ISSUE_PARAM_VALUES = {
|
30
|
+
'priority' => %w[ trivial minor major critical blocker ],
|
31
|
+
'status' => ['new', 'open', 'resolved', 'on hold', 'invalid', 'duplicate', 'wontfix'],
|
32
|
+
'kind' => %w[ bug enhancement proposal task ]
|
33
|
+
}
|
34
|
+
|
35
|
+
# Creates new Issues API
|
36
|
+
def initialize(options = { })
|
37
|
+
super(options)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Access to Issues::Comments API
|
41
|
+
def comments
|
42
|
+
@comments ||= ApiFactory.new 'Issues::Comments'
|
43
|
+
end
|
44
|
+
|
45
|
+
# Access to Issues::Components API
|
46
|
+
def components
|
47
|
+
@components ||= ApiFactory.new 'Issues::Components'
|
48
|
+
end
|
49
|
+
|
50
|
+
# Access to Issues::Milestones API
|
51
|
+
def milestones
|
52
|
+
@milestones ||= ApiFactory.new 'Issues::Milestones'
|
53
|
+
end
|
54
|
+
|
55
|
+
# List issues for a repository
|
56
|
+
#
|
57
|
+
# = Inputs
|
58
|
+
# <tt>:limit</tt> - Optional - Number of issues to retrieve, default 15
|
59
|
+
# <tt>:start</tt> - Optional - Issue offset, default 0
|
60
|
+
# <tt>:search</tt> - Optional - A string to search for
|
61
|
+
# <tt>:sort</tt> - Optional - Sorts the output by any of the metadata fields
|
62
|
+
# <tt>:title</tt> - Optional - Contains a filter operation to restrict the list of issues by the issue title
|
63
|
+
# <tt>:content</tt> - Optional - Contains a filter operation to restrict the list of issues by the issue content
|
64
|
+
# <tt>:version</tt> - Optional - Contains an is or ! ( is not) filter to restrict the list of issues by the version
|
65
|
+
# <tt>:milestone</tt> - Optional - Contains an is or ! ( is not) filter to restrict the list of issues by the milestone
|
66
|
+
# <tt>:component</tt> - Optional - Contains an is or ! ( is not) filter to restrict the list of issues by the component
|
67
|
+
# <tt>:kind</tt> - Optional - Contains an is or ! ( is not) filter to restrict the list of issues by the issue kind
|
68
|
+
# <tt>:status</tt> - Optional - Contains an is or ! ( is not) filter to restrict the list of issues by the issue status
|
69
|
+
# <tt>:responsible</tt> - Optional - Contains an is or ! ( is not) filter to restrict the list of issues by the user responsible
|
70
|
+
# <tt>:reported_by</tt> - Optional - Contains a filter operation to restrict the list of issues by the user that reported the issue
|
71
|
+
#
|
72
|
+
# = Examples
|
73
|
+
# bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
|
74
|
+
# bitbucket.issues.list_repo :filter => 'kind=bug&kind=enhancement'
|
75
|
+
#
|
76
|
+
def list_repo(user_name, repo_name, params={ })
|
77
|
+
_update_user_repo_params(user_name, repo_name)
|
78
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
79
|
+
|
80
|
+
normalize! params
|
81
|
+
filter! VALID_ISSUE_PARAM_NAMES, params
|
82
|
+
# _merge_mime_type(:issue, params)
|
83
|
+
assert_valid_values(VALID_ISSUE_PARAM_VALUES, params)
|
84
|
+
|
85
|
+
response = get_request("/2.0/repositories/#{user}/#{repo.downcase}/issues", params)
|
86
|
+
return response.issues unless block_given?
|
87
|
+
response.issues.each { |el| yield el }
|
88
|
+
end
|
89
|
+
|
90
|
+
alias :list_repository :list_repo
|
91
|
+
|
92
|
+
# Get a single issue
|
93
|
+
#
|
94
|
+
# = Examples
|
95
|
+
# bitbucket = BitBucket.new
|
96
|
+
# bitbucket.issues.get 'user-name', 'repo-name', 'issue-id'
|
97
|
+
#
|
98
|
+
def get(user_name, repo_name, issue_id, params={ })
|
99
|
+
_update_user_repo_params(user_name, repo_name)
|
100
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
101
|
+
_validate_presence_of issue_id
|
102
|
+
|
103
|
+
normalize! params
|
104
|
+
# _merge_mime_type(:issue, params)
|
105
|
+
|
106
|
+
get_request("/2.0/repositories/#{user}/#{repo.downcase}/issues/#{issue_id}", params)
|
107
|
+
end
|
108
|
+
|
109
|
+
alias :find :get
|
110
|
+
|
111
|
+
# Delete a single issue
|
112
|
+
#
|
113
|
+
# = Examples
|
114
|
+
# bitbucket = BitBucket.new
|
115
|
+
# bitbucket.issues.delete 'user-name', 'repo-name', 'issue-id'
|
116
|
+
#
|
117
|
+
def delete(user_name, repo_name, issue_id, params={ })
|
118
|
+
_update_user_repo_params(user_name, repo_name)
|
119
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
120
|
+
_validate_presence_of issue_id
|
121
|
+
|
122
|
+
normalize! params
|
123
|
+
# _merge_mime_type(:issue, params)
|
124
|
+
|
125
|
+
delete_request("/2.0/repositories/#{user}/#{repo}/issues/#{issue_id}", params)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Create an issue
|
129
|
+
#
|
130
|
+
# = Inputs
|
131
|
+
# <tt>:title</tt> - Required string
|
132
|
+
# <tt>:content</tt> - Optional string
|
133
|
+
# <tt>:responsible</tt> - Optional string - Login for the user that this issue should be assigned to.
|
134
|
+
# <tt>:milestone</tt> - Optional number - Milestone to associate this issue with
|
135
|
+
# <tt>:version</tt> - Optional number - Version to associate this issue with
|
136
|
+
# <tt>:component</tt> - Optional number - Component to associate this issue with
|
137
|
+
# <tt>:priority</tt> - Optional string - The priority of this issue
|
138
|
+
# * <tt>trivial</tt>
|
139
|
+
# * <tt>minor</tt>
|
140
|
+
# * <tt>major</tt>
|
141
|
+
# * <tt>critical</tt>
|
142
|
+
# * <tt>blocker</tt>
|
143
|
+
# <tt>:status</tt> - Optional string - The status of this issue
|
144
|
+
# * <tt>new</tt>
|
145
|
+
# * <tt>open</tt>
|
146
|
+
# * <tt>resolved</tt>
|
147
|
+
# * <tt>on hold</tt>
|
148
|
+
# * <tt>invalid</tt>
|
149
|
+
# * <tt>duplicate</tt>
|
150
|
+
# * <tt>wontfix</tt>
|
151
|
+
# <tt>:kind</tt> - Optional string - The kind of issue
|
152
|
+
# * <tt>bug</tt>
|
153
|
+
# * <tt>enhancement</tt>
|
154
|
+
# * <tt>proposal</tt>
|
155
|
+
# * <tt>task</tt>
|
156
|
+
#
|
157
|
+
# = Examples
|
158
|
+
# bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
|
159
|
+
# bitbucket.issues.create
|
160
|
+
# "title" => "Found a bug",
|
161
|
+
# "content" => "I'm having a problem with this.",
|
162
|
+
# "responsible" => "octocat",
|
163
|
+
# "milestone" => 1,
|
164
|
+
# "priority" => "blocker"
|
165
|
+
#
|
166
|
+
def create(user_name, repo_name, params={ })
|
167
|
+
_update_user_repo_params(user_name, repo_name)
|
168
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
169
|
+
|
170
|
+
normalize! params
|
171
|
+
_merge_user_into_params!(params) unless params.has_key?('user')
|
172
|
+
# _merge_mime_type(:issue, params)
|
173
|
+
filter! VALID_ISSUE_PARAM_NAMES, params
|
174
|
+
assert_required_keys(%w[ title ], params)
|
175
|
+
|
176
|
+
post_request("/2.0/repositories/#{user}/#{repo.downcase}/issues/", params)
|
177
|
+
end
|
178
|
+
|
179
|
+
# Edit an issue
|
180
|
+
#
|
181
|
+
# = Inputs
|
182
|
+
# <tt>:title</tt> - Required string
|
183
|
+
# <tt>:content</tt> - Optional string
|
184
|
+
# <tt>:responsible</tt> - Optional string - Login for the user that this issue should be assigned to.
|
185
|
+
# <tt>:milestone</tt> - Optional number - Milestone to associate this issue with
|
186
|
+
# <tt>:version</tt> - Optional number - Version to associate this issue with
|
187
|
+
# <tt>:component</tt> - Optional number - Component to associate this issue with
|
188
|
+
# <tt>:priority</tt> - Optional string - The priority of this issue
|
189
|
+
# * <tt>trivial</tt>
|
190
|
+
# * <tt>minor</tt>
|
191
|
+
# * <tt>major</tt>
|
192
|
+
# * <tt>critical</tt>
|
193
|
+
# * <tt>blocker</tt>
|
194
|
+
# <tt>:status</tt> - Optional string - The status of this issue
|
195
|
+
# * <tt>new</tt>
|
196
|
+
# * <tt>open</tt>
|
197
|
+
# * <tt>resolved</tt>
|
198
|
+
# * <tt>on hold</tt>
|
199
|
+
# * <tt>invalid</tt>
|
200
|
+
# * <tt>duplicate</tt>
|
201
|
+
# * <tt>wontfix</tt>
|
202
|
+
# <tt>:kind</tt> - Optional string - The kind of issue
|
203
|
+
# * <tt>bug</tt>
|
204
|
+
# * <tt>enhancement</tt>
|
205
|
+
# * <tt>proposal</tt>
|
206
|
+
# * <tt>task</tt>
|
207
|
+
#
|
208
|
+
# = Examples
|
209
|
+
# bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
|
210
|
+
# bitbucket.issues.create
|
211
|
+
# "title" => "Found a bug",
|
212
|
+
# "content" => "I'm having a problem with this.",
|
213
|
+
# "responsible" => "octocat",
|
214
|
+
# "milestone" => 1,
|
215
|
+
# "priority" => "blocker"
|
216
|
+
#
|
217
|
+
def edit(user_name, repo_name, issue_id, params={ })
|
218
|
+
_update_user_repo_params(user_name, repo_name)
|
219
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
220
|
+
_validate_presence_of issue_id
|
221
|
+
|
222
|
+
normalize! params
|
223
|
+
# _merge_mime_type(:issue, params)
|
224
|
+
filter! VALID_ISSUE_PARAM_NAMES, params
|
225
|
+
|
226
|
+
put_request("/2.0/repositories/#{user}/#{repo.downcase}/issues/#{issue_id}/", params)
|
227
|
+
end
|
228
|
+
|
229
|
+
end # Issues
|
230
|
+
end # BitBucket
|