codenamev_bitbucket_api 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +43 -0
  3. data/README.md +169 -0
  4. data/Rakefile +3 -0
  5. data/lib/bitbucket_rest_api/api/actions.rb +50 -0
  6. data/lib/bitbucket_rest_api/api/arguments.rb +248 -0
  7. data/lib/bitbucket_rest_api/api/config/property.rb +30 -0
  8. data/lib/bitbucket_rest_api/api/config/property_set.rb +118 -0
  9. data/lib/bitbucket_rest_api/api/config.rb +107 -0
  10. data/lib/bitbucket_rest_api/api/factory.rb +29 -0
  11. data/lib/bitbucket_rest_api/api.rb +242 -0
  12. data/lib/bitbucket_rest_api/authorization.rb +34 -0
  13. data/lib/bitbucket_rest_api/client/invitations.rb +16 -0
  14. data/lib/bitbucket_rest_api/client/issues/comments.rb +109 -0
  15. data/lib/bitbucket_rest_api/client/issues/components.rb +103 -0
  16. data/lib/bitbucket_rest_api/client/issues/milestones.rb +103 -0
  17. data/lib/bitbucket_rest_api/client/issues.rb +214 -0
  18. data/lib/bitbucket_rest_api/client/repos/changesets.rb +55 -0
  19. data/lib/bitbucket_rest_api/client/repos/following.rb +40 -0
  20. data/lib/bitbucket_rest_api/client/repos/keys.rb +88 -0
  21. data/lib/bitbucket_rest_api/client/repos/pull_requests/comments.rb +42 -0
  22. data/lib/bitbucket_rest_api/client/repos/pull_requests/commits.rb +24 -0
  23. data/lib/bitbucket_rest_api/client/repos/pull_requests.rb +199 -0
  24. data/lib/bitbucket_rest_api/client/repos/services.rb +104 -0
  25. data/lib/bitbucket_rest_api/client/repos/sources.rb +32 -0
  26. data/lib/bitbucket_rest_api/client/repos.rb +224 -0
  27. data/lib/bitbucket_rest_api/client/user.rb +96 -0
  28. data/lib/bitbucket_rest_api/client/users/account.rb +54 -0
  29. data/lib/bitbucket_rest_api/client/users.rb +14 -0
  30. data/lib/bitbucket_rest_api/client.rb +54 -0
  31. data/lib/bitbucket_rest_api/compatibility.rb +23 -0
  32. data/lib/bitbucket_rest_api/configuration.rb +59 -0
  33. data/lib/bitbucket_rest_api/connection.rb +61 -0
  34. data/lib/bitbucket_rest_api/constants.rb +50 -0
  35. data/lib/bitbucket_rest_api/core_ext/array.rb +17 -0
  36. data/lib/bitbucket_rest_api/core_ext/hash.rb +56 -0
  37. data/lib/bitbucket_rest_api/core_ext/ordered_hash.rb +107 -0
  38. data/lib/bitbucket_rest_api/deprecation.rb +39 -0
  39. data/lib/bitbucket_rest_api/error/bad_request.rb +12 -0
  40. data/lib/bitbucket_rest_api/error/client_error.rb +20 -0
  41. data/lib/bitbucket_rest_api/error/forbidden.rb +12 -0
  42. data/lib/bitbucket_rest_api/error/internal_server_error.rb +12 -0
  43. data/lib/bitbucket_rest_api/error/invalid_options.rb +18 -0
  44. data/lib/bitbucket_rest_api/error/not_found.rb +12 -0
  45. data/lib/bitbucket_rest_api/error/required_params.rb +18 -0
  46. data/lib/bitbucket_rest_api/error/service_error.rb +19 -0
  47. data/lib/bitbucket_rest_api/error/service_unavailable.rb +12 -0
  48. data/lib/bitbucket_rest_api/error/unauthorized.rb +12 -0
  49. data/lib/bitbucket_rest_api/error/unknown_value.rb +18 -0
  50. data/lib/bitbucket_rest_api/error/unprocessable_entity.rb +12 -0
  51. data/lib/bitbucket_rest_api/error/validations.rb +18 -0
  52. data/lib/bitbucket_rest_api/error.rb +35 -0
  53. data/lib/bitbucket_rest_api/ext/faraday.rb +38 -0
  54. data/lib/bitbucket_rest_api/middleware.rb +31 -0
  55. data/lib/bitbucket_rest_api/normalizer.rb +27 -0
  56. data/lib/bitbucket_rest_api/null_encoder.rb +25 -0
  57. data/lib/bitbucket_rest_api/page_iterator.rb +90 -0
  58. data/lib/bitbucket_rest_api/page_links.rb +33 -0
  59. data/lib/bitbucket_rest_api/paged_request.rb +29 -0
  60. data/lib/bitbucket_rest_api/pagination.rb +97 -0
  61. data/lib/bitbucket_rest_api/parameter_filter.rb +32 -0
  62. data/lib/bitbucket_rest_api/params_hash.rb +100 -0
  63. data/lib/bitbucket_rest_api/request/basic_auth.rb +33 -0
  64. data/lib/bitbucket_rest_api/request/jsonize.rb +51 -0
  65. data/lib/bitbucket_rest_api/request/oauth.rb +51 -0
  66. data/lib/bitbucket_rest_api/request/verbs.rb +53 -0
  67. data/lib/bitbucket_rest_api/request.rb +91 -0
  68. data/lib/bitbucket_rest_api/response/header.rb +68 -0
  69. data/lib/bitbucket_rest_api/response/helpers.rb +21 -0
  70. data/lib/bitbucket_rest_api/response/jsonize.rb +30 -0
  71. data/lib/bitbucket_rest_api/response/mashify.rb +24 -0
  72. data/lib/bitbucket_rest_api/response/raise_error.rb +31 -0
  73. data/lib/bitbucket_rest_api/response/xmlize.rb +26 -0
  74. data/lib/bitbucket_rest_api/response.rb +28 -0
  75. data/lib/bitbucket_rest_api/response_wrapper.rb +157 -0
  76. data/lib/bitbucket_rest_api/result.rb +68 -0
  77. data/lib/bitbucket_rest_api/users.rb +20 -0
  78. data/lib/bitbucket_rest_api/utils/url.rb +56 -0
  79. data/lib/bitbucket_rest_api/validations/format.rb +24 -0
  80. data/lib/bitbucket_rest_api/validations/presence.rb +30 -0
  81. data/lib/bitbucket_rest_api/validations/required.rb +24 -0
  82. data/lib/bitbucket_rest_api/validations/token.rb +43 -0
  83. data/lib/bitbucket_rest_api/validations.rb +25 -0
  84. data/lib/bitbucket_rest_api/version.rb +11 -0
  85. data/lib/bitbucket_rest_api.rb +136 -0
  86. metadata +238 -0
@@ -0,0 +1,103 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ class Client::Issues::Milestones < API
5
+ @version = '1.0'
6
+
7
+ VALID_MILESTONE_INPUTS = %w[
8
+ name
9
+ ].freeze # :nodoc:
10
+
11
+ # List milestones for a repository
12
+ #
13
+ # = Examples
14
+ # bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
15
+ # bitbucket.issues.milestones.list
16
+ #
17
+ def list(user_name, repo_name, params={})
18
+ _update_user_repo_params(user_name, repo_name)
19
+ _validate_user_repo_params(user, repo) unless user? && repo?
20
+
21
+ normalize! params
22
+
23
+ response = get_request("/repositories/#{user}/#{repo.downcase}/issues/milestones", params)
24
+ return response unless block_given?
25
+ response.each { |el| yield el }
26
+ end
27
+ alias :all :list
28
+
29
+ # Get a single milestone
30
+ #
31
+ # = Examples
32
+ # bitbucket = BitBucket.new
33
+ # bitbucket.issues.milestones.get 'user-name', 'repo-name', 'milestone-id'
34
+ #
35
+ def get(user_name, repo_name, milestone_id, params={})
36
+ _update_user_repo_params(user_name, repo_name)
37
+ _validate_user_repo_params(user, repo) unless user? && repo?
38
+ _validate_presence_of milestone_id
39
+ normalize! params
40
+
41
+ get_request("/repositories/#{user}/#{repo.downcase}/issues/milestones/#{milestone_id}", params)
42
+ end
43
+ alias :find :get
44
+
45
+ # Create a milestone
46
+ #
47
+ # = Inputs
48
+ # <tt>:name</tt> - Required string
49
+ #
50
+ # = Examples
51
+ # bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
52
+ # bitbucket.issues.milestones.create :name => 'hello-world'
53
+ #
54
+ def create(user_name, repo_name, params={})
55
+ _update_user_repo_params(user_name, repo_name)
56
+ _validate_user_repo_params(user, repo) unless user? && repo?
57
+
58
+ normalize! params
59
+ filter! VALID_MILESTONE_INPUTS, params
60
+ assert_required_keys(%w[ name ], params)
61
+
62
+ post_request("/repositories/#{user}/#{repo.downcase}/issues/milestones", params)
63
+ end
64
+
65
+ # Update a milestone
66
+ #
67
+ # = Inputs
68
+ # <tt>:name</tt> - Required string
69
+ #
70
+ # = Examples
71
+ # bitbucket = BitBucket.new
72
+ # bitbucket.issues.milestones.update 'user-name', 'repo-name', 'milestone-id',
73
+ # :name => 'hello-world'
74
+ #
75
+ def update(user_name, repo_name, milestone_id, params={})
76
+ _update_user_repo_params(user_name, repo_name)
77
+ _validate_user_repo_params(user, repo) unless user? && repo?
78
+ _validate_presence_of milestone_id
79
+
80
+ normalize! params
81
+ filter! VALID_MILESTONE_INPUTS, params
82
+ assert_required_keys(%w[ name ], params)
83
+
84
+ put_request("/repositories/#{user}/#{repo.downcase}/issues/milestones/#{milestone_id}", params)
85
+ end
86
+
87
+ # Delete a milestone
88
+ #
89
+ # = Examples
90
+ # bitbucket = BitBucket.new
91
+ # bitbucket.issues.milestones.delete 'user-name', 'repo-name', 'milestone-id'
92
+ #
93
+ def delete(user_name, repo_name, milestone_id, params={})
94
+ _update_user_repo_params(user_name, repo_name)
95
+ _validate_user_repo_params(user, repo) unless user? && repo?
96
+ _validate_presence_of milestone_id
97
+ normalize! params
98
+
99
+ delete_request("/repositories/#{user}/#{repo.downcase}/issues/milestones/#{milestone_id}", params)
100
+ end
101
+
102
+ end # Issues::Milestones
103
+ end # BitBucket
@@ -0,0 +1,214 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ class Client::Issues < API
5
+ @version = '1.0'
6
+
7
+ require_all 'bitbucket_rest_api/client/issues',
8
+ 'comments',
9
+ 'components',
10
+ '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
+ # Access to Issues::Comments API
36
+ namespace :comments
37
+
38
+ # Access to Issues::Components API
39
+ namespace :components
40
+
41
+ # Access to Issues::Milestones API
42
+ namespace :milestones
43
+
44
+ # List issues for a repository
45
+ #
46
+ # = Inputs
47
+ # <tt>:limit</tt> - Optional - Number of issues to retrieve, default 15
48
+ # <tt>:start</tt> - Optional - Issue offset, default 0
49
+ # <tt>:search</tt> - Optional - A string to search for
50
+ # <tt>:sort</tt> - Optional - Sorts the output by any of the metadata fields
51
+ # <tt>:title</tt> - Optional - Contains a filter operation to restrict the list of issues by the issue title
52
+ # <tt>:content</tt> - Optional - Contains a filter operation to restrict the list of issues by the issue content
53
+ # <tt>:version</tt> - Optional - Contains an is or ! ( is not) filter to restrict the list of issues by the version
54
+ # <tt>:milestone</tt> - Optional - Contains an is or ! ( is not) filter to restrict the list of issues by the milestone
55
+ # <tt>:component</tt> - Optional - Contains an is or ! ( is not) filter to restrict the list of issues by the component
56
+ # <tt>:kind</tt> - Optional - Contains an is or ! ( is not) filter to restrict the list of issues by the issue kind
57
+ # <tt>:status</tt> - Optional - Contains an is or ! ( is not) filter to restrict the list of issues by the issue status
58
+ # <tt>:responsible</tt> - Optional - Contains an is or ! ( is not) filter to restrict the list of issues by the user responsible
59
+ # <tt>:reported_by</tt> - Optional - Contains a filter operation to restrict the list of issues by the user that reported the issue
60
+ #
61
+ # = Examples
62
+ # bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
63
+ # bitbucket.issues.list_repo :filter => 'kind=bug&kind=enhancement'
64
+ #
65
+ def list_repo(user_name, repo_name, params={ })
66
+ _update_user_repo_params(user_name, repo_name)
67
+ _validate_user_repo_params(user, repo) unless user? && repo?
68
+
69
+ normalize! params
70
+ filter! VALID_ISSUE_PARAM_NAMES, params
71
+ assert_valid_values(VALID_ISSUE_PARAM_VALUES, params)
72
+
73
+ response = get_request("/repositories/#{user}/#{repo.downcase}/issues", params)
74
+ return response.issues unless block_given?
75
+ response.issues.each { |el| yield el }
76
+ end
77
+
78
+ alias :list_repository :list_repo
79
+
80
+ # Get a single issue
81
+ #
82
+ # = Examples
83
+ # bitbucket = BitBucket.new
84
+ # bitbucket.issues.get 'user-name', 'repo-name', 'issue-id'
85
+ #
86
+ def get(user_name, repo_name, issue_id, params={ })
87
+ _update_user_repo_params(user_name, repo_name)
88
+ _validate_user_repo_params(user, repo) unless user? && repo?
89
+ _validate_presence_of issue_id
90
+
91
+ normalize! params
92
+
93
+ get_request("/repositories/#{user}/#{repo.downcase}/issues/#{issue_id}", params)
94
+ end
95
+
96
+ alias :find :get
97
+
98
+ # Delete a single issue
99
+ #
100
+ # = Examples
101
+ # bitbucket = BitBucket.new
102
+ # bitbucket.issues.delete 'user-name', 'repo-name', 'issue-id'
103
+ #
104
+ def delete(user_name, repo_name, issue_id, params={ })
105
+ _update_user_repo_params(user_name, repo_name)
106
+ _validate_user_repo_params(user, repo) unless user? && repo?
107
+ _validate_presence_of issue_id
108
+
109
+ normalize! params
110
+
111
+ delete_request("/repositories/#{user}/#{repo}/issues/#{issue_id}", params)
112
+ end
113
+
114
+ # Create an issue
115
+ #
116
+ # = Inputs
117
+ # <tt>:title</tt> - Required string
118
+ # <tt>:content</tt> - Optional string
119
+ # <tt>:responsible</tt> - Optional string - Login for the user that this issue should be assigned to.
120
+ # <tt>:milestone</tt> - Optional number - Milestone to associate this issue with
121
+ # <tt>:version</tt> - Optional number - Version to associate this issue with
122
+ # <tt>:component</tt> - Optional number - Component to associate this issue with
123
+ # <tt>:priority</tt> - Optional string - The priority of this issue
124
+ # * <tt>trivial</tt>
125
+ # * <tt>minor</tt>
126
+ # * <tt>major</tt>
127
+ # * <tt>critical</tt>
128
+ # * <tt>blocker</tt>
129
+ # <tt>:status</tt> - Optional string - The status of this issue
130
+ # * <tt>new</tt>
131
+ # * <tt>open</tt>
132
+ # * <tt>resolved</tt>
133
+ # * <tt>on hold</tt>
134
+ # * <tt>invalid</tt>
135
+ # * <tt>duplicate</tt>
136
+ # * <tt>wontfix</tt>
137
+ # <tt>:kind</tt> - Optional string - The kind of issue
138
+ # * <tt>bug</tt>
139
+ # * <tt>enhancement</tt>
140
+ # * <tt>proposal</tt>
141
+ # * <tt>task</tt>
142
+ #
143
+ # = Examples
144
+ # bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
145
+ # bitbucket.issues.create
146
+ # "title" => "Found a bug",
147
+ # "content" => "I'm having a problem with this.",
148
+ # "responsible" => "octocat",
149
+ # "milestone" => 1,
150
+ # "priority" => "blocker"
151
+ #
152
+ def create(user_name, repo_name, params={ })
153
+ _update_user_repo_params(user_name, repo_name)
154
+ _validate_user_repo_params(user, repo) unless user? && repo?
155
+
156
+ normalize! params
157
+ _merge_user_into_params!(params) unless params.has_key?('user')
158
+ filter! VALID_ISSUE_PARAM_NAMES, params
159
+ assert_required_keys(%w[ title ], params)
160
+
161
+ post_request("/repositories/#{user}/#{repo.downcase}/issues/", params)
162
+ end
163
+
164
+ # Edit an issue
165
+ #
166
+ # = Inputs
167
+ # <tt>:title</tt> - Required string
168
+ # <tt>:content</tt> - Optional string
169
+ # <tt>:responsible</tt> - Optional string - Login for the user that this issue should be assigned to.
170
+ # <tt>:milestone</tt> - Optional number - Milestone to associate this issue with
171
+ # <tt>:version</tt> - Optional number - Version to associate this issue with
172
+ # <tt>:component</tt> - Optional number - Component to associate this issue with
173
+ # <tt>:priority</tt> - Optional string - The priority of this issue
174
+ # * <tt>trivial</tt>
175
+ # * <tt>minor</tt>
176
+ # * <tt>major</tt>
177
+ # * <tt>critical</tt>
178
+ # * <tt>blocker</tt>
179
+ # <tt>:status</tt> - Optional string - The status of this issue
180
+ # * <tt>new</tt>
181
+ # * <tt>open</tt>
182
+ # * <tt>resolved</tt>
183
+ # * <tt>on hold</tt>
184
+ # * <tt>invalid</tt>
185
+ # * <tt>duplicate</tt>
186
+ # * <tt>wontfix</tt>
187
+ # <tt>:kind</tt> - Optional string - The kind of issue
188
+ # * <tt>bug</tt>
189
+ # * <tt>enhancement</tt>
190
+ # * <tt>proposal</tt>
191
+ # * <tt>task</tt>
192
+ #
193
+ # = Examples
194
+ # bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
195
+ # bitbucket.issues.create
196
+ # "title" => "Found a bug",
197
+ # "content" => "I'm having a problem with this.",
198
+ # "responsible" => "octocat",
199
+ # "milestone" => 1,
200
+ # "priority" => "blocker"
201
+ #
202
+ def edit(user_name, repo_name, issue_id, params={ })
203
+ _update_user_repo_params(user_name, repo_name)
204
+ _validate_user_repo_params(user, repo) unless user? && repo?
205
+ _validate_presence_of issue_id
206
+
207
+ normalize! params
208
+ filter! VALID_ISSUE_PARAM_NAMES, params
209
+
210
+ put_request("/repositories/#{user}/#{repo.downcase}/issues/#{issue_id}/", params)
211
+ end
212
+
213
+ end # Issues
214
+ end # BitBucket
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ class Client::Repos::Changesets < API
5
+ @version = '1.0'
6
+
7
+ REQUIRED_COMMENT_PARAMS = %w[
8
+ body
9
+ changeset_id
10
+ line
11
+ path
12
+ position
13
+ ].freeze
14
+
15
+ # List changesets on a repository
16
+ #
17
+ # = Parameters
18
+ # * <tt>:limit</tt> Optional integer. An integer representing how many changesets to return. You can specify a limit between 0 and 50.
19
+ # * <tt>:start</tt> Optional string. A hash value representing the earliest node to start with.
20
+ #
21
+ # = Examples
22
+ # bitbucket = BitBucket.new
23
+ # bitbucket.repos.changesets.list 'user-name', 'repo-name', :start => '...'
24
+ # bitbucket.repos.changesets.list 'user-name', 'repo-name', :start => '...' { |changeset| ... }
25
+ #
26
+ def list(user_name, repo_name, params={})
27
+ _update_user_repo_params(user_name, repo_name)
28
+ _validate_user_repo_params(user, repo) unless user? && repo?
29
+ normalize! params
30
+ filter! %w[ limit start], params
31
+
32
+ response = get_request("/repositories/#{user}/#{repo.downcase}/changesets", params)
33
+ return response unless block_given?
34
+ response.each { |el| yield el }
35
+ end
36
+ alias :all :list
37
+
38
+ # Gets a single changeset
39
+ #
40
+ # = Examples
41
+ # @bitbucket = BitBucket.new
42
+ # @bitbucket.repos.changesets.get 'user-name', 'repo-name', '6dcb09b5b57875f334f61aebed6')
43
+ #
44
+ def get(user_name, repo_name, sha, params={})
45
+ _update_user_repo_params(user_name, repo_name)
46
+ _validate_user_repo_params(user, repo) unless user? && repo?
47
+ _validate_presence_of sha
48
+ normalize! params
49
+
50
+ get_request("/repositories/#{user}/#{repo.downcase}/changesets/#{sha}", params)
51
+ end
52
+ alias :find :get
53
+
54
+ end # Repos::Commits
55
+ end # BitBucket
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ class Client::Repos::Following < API
5
+ @version = '1.0'
6
+
7
+ # List repo followers
8
+ #
9
+ # = Examples
10
+ # bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
11
+ # bitbucket.repos.following.followers
12
+ # bitbucket.repos.following.followers { |watcher| ... }
13
+ #
14
+ def followers(user_name, repo_name, params={})
15
+ _update_user_repo_params(user_name, repo_name)
16
+ _validate_user_repo_params(user, repo) unless user? && repo?
17
+ normalize! params
18
+
19
+ response = get_request("/repositories/#{user}/#{repo.downcase}/followers/", params)
20
+ return response unless block_given?
21
+ response.each { |el| yield el }
22
+ end
23
+
24
+ # List repos being followed by the authenticated user
25
+ #
26
+ # = Examples
27
+ # bitbucket = BitBucket.new :oauth_token => '...', :oauth_secret => '...'
28
+ # bitbucket.repos.following.followed
29
+ #
30
+ def followed(*args)
31
+ params = args.extract_options!
32
+ normalize! params
33
+
34
+ response = get_request("/user/follows", params)
35
+ return response unless block_given?
36
+ response.each { |el| yield el }
37
+ end
38
+
39
+ end # Repos::Watching
40
+ end # BitBucket
@@ -0,0 +1,88 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ class Client::Repos::Keys < API
5
+ @version = '1.0'
6
+
7
+ VALID_KEY_PARAM_NAMES = %w[ label key ].freeze
8
+
9
+ # List deploy keys
10
+ #
11
+ # = Examples
12
+ # bitbucket = BitBucket.new
13
+ # bitbucket.repos.keys.list 'user-name', 'repo-name'
14
+ # bitbucket.repos.keys.list 'user-name', 'repo-name' { |key| ... }
15
+ #
16
+ def list(user_name, repo_name, params={})
17
+ _update_user_repo_params(user_name, repo_name)
18
+ _validate_user_repo_params(user, repo) unless user? && repo?
19
+ normalize! params
20
+
21
+ response = get_request("/repositories/#{user}/#{repo.downcase}/deploy-keys/", params)
22
+ return response unless block_given?
23
+ response.each { |el| yield el }
24
+ end
25
+ alias :all :list
26
+
27
+ # Create a key
28
+ #
29
+ # = Inputs
30
+ # * <tt>:title</tt> - Required string.
31
+ # * <tt>:key</tt> - Required string.
32
+ #
33
+ # = Examples
34
+ # bitbucket = BitBucket.new
35
+ # bitbucket.repos.keys.create 'user-name', 'repo-name',
36
+ # "label" => "octocat@octomac",
37
+ # "key" => "ssh-rsa AAA..."
38
+ #
39
+ def create(user_name, repo_name, params={})
40
+ _update_user_repo_params(user_name, repo_name)
41
+ _validate_user_repo_params(user, repo) unless user? && repo?
42
+ normalize! params
43
+ filter! VALID_KEY_PARAM_NAMES, params
44
+ assert_required_keys(VALID_KEY_PARAM_NAMES, params)
45
+
46
+ post_request("/repositories/#{user}/#{repo.downcase}/deploy-keys/", params)
47
+ end
48
+
49
+ # Edit a key
50
+ #
51
+ # = Inputs
52
+ # * <tt>:title</tt> - Required string.
53
+ # * <tt>:key</tt> - Required string.
54
+ #
55
+ # = Examples
56
+ # bitbucket = BitBucket.new
57
+ # bitbucket.repos.keys.edit 'user-name', 'repo-name',
58
+ # "label" => "octocat@octomac",
59
+ # "key" => "ssh-rsa AAA..."
60
+ #
61
+ def edit(user_name, repo_name, key_id, params={})
62
+ _update_user_repo_params(user_name, repo_name)
63
+ _validate_user_repo_params(user, repo) unless user? && repo?
64
+ _validate_presence_of key_id
65
+
66
+ normalize! params
67
+ filter! VALID_KEY_PARAM_NAMES, params
68
+
69
+ put_request("/repositories/#{user}/#{repo.downcase}/deploy-keys/#{key_id}", params)
70
+ end
71
+
72
+ # Delete key
73
+ #
74
+ # = Examples
75
+ # @bitbucket = BitBucket.new
76
+ # @bitbucket.repos.keys.delete 'user-name', 'repo-name', 'key-id'
77
+ #
78
+ def delete(user_name, repo_name, key_id, params={})
79
+ _update_user_repo_params(user_name, repo_name)
80
+ _validate_user_repo_params(user, repo) unless user? && repo?
81
+ _validate_presence_of key_id
82
+ normalize! params
83
+
84
+ delete_request("/repositories/#{user}/#{repo.downcase}/deploy-keys/#{key_id}", params)
85
+ end
86
+
87
+ end # Repos::Keys
88
+ end # BitBucket
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ class Client::Repos::PullRequests::Comments < API
5
+ @version = '2.0'
6
+
7
+ # List comments on a pull request
8
+ #
9
+ # = Examples
10
+ # bitbucket = BitBucket.new
11
+ # bitbucket.repos.pull_requests.comments.all 'user-name', 'repo-name', 'pull-request-id'
12
+ #
13
+ def list(*args)
14
+ arguments(args, required: [:user, :repo, :pull_request_id])
15
+ user = arguments.user
16
+ repo = arguments.repo
17
+ pull_request_id = arguments.pull_request_id
18
+
19
+ response = get_request("/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}/comments")
20
+ return response unless block_given?
21
+ response.each { |el| yield el }
22
+ end
23
+ alias :all :list
24
+
25
+ # Gets a single comment
26
+ #
27
+ # = Examples
28
+ # @bitbucket = BitBucket.new
29
+ # @bitbucket.repos.pull_requests.comments.get 'user-name', 'repo-name', 'pull-request-id')
30
+ #
31
+ def get(*args)
32
+ arguments(args, required: [:user, :repo, :pull_request_id, :comment_id])
33
+ user = arguments.user
34
+ repo = arguments.repo
35
+ pull_request_id = arguments.pull_request_id
36
+ comment_id = arguments.comment_id
37
+
38
+ get_request("/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}/comments/#{comment_id}")
39
+ end
40
+ alias :find :get
41
+ end
42
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ class Client::Repos::PullRequests::Commits < API
5
+ @version = '2.0'
6
+
7
+ # List commits on a pull request
8
+ #
9
+ # = Examples
10
+ # bitbucket = BitBucket.new
11
+ # bitbucket.repos.pull_requests.commits.all 'user-name', 'repo-name', 'pull-request-id'
12
+ #
13
+ def list(user_name, repo_name, pull_request_id)
14
+ _update_user_repo_params(user_name, repo_name)
15
+ _validate_user_repo_params(user, repo) unless user? && repo?
16
+ _validate_presence_of pull_request_id
17
+
18
+ response = get_request("/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}/commits")
19
+ return response unless block_given?
20
+ response.each { |el| yield el }
21
+ end
22
+ alias :all :list
23
+ end
24
+ end