reenhanced_bitbucket_api 0.1.6
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 +43 -0
- data/README.md +169 -0
- data/Rakefile +3 -0
- data/lib/bitbucket_rest_api/api/actions.rb +50 -0
- data/lib/bitbucket_rest_api/api.rb +120 -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 +58 -0
- data/lib/bitbucket_rest_api/compatibility.rb +23 -0
- data/lib/bitbucket_rest_api/configuration.rb +101 -0
- data/lib/bitbucket_rest_api/connection.rb +96 -0
- data/lib/bitbucket_rest_api/constants.rb +58 -0
- data/lib/bitbucket_rest_api/core_ext/array.rb +17 -0
- data/lib/bitbucket_rest_api/core_ext/hash.rb +56 -0
- data/lib/bitbucket_rest_api/core_ext/ordered_hash.rb +107 -0
- data/lib/bitbucket_rest_api/deprecation.rb +39 -0
- data/lib/bitbucket_rest_api/error/bad_request.rb +12 -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/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/error.rb +35 -0
- data/lib/bitbucket_rest_api/invitations.rb +15 -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/issues.rb +230 -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/changesets.rb +54 -0
- data/lib/bitbucket_rest_api/repos/following.rb +39 -0
- data/lib/bitbucket_rest_api/repos/keys.rb +87 -0
- data/lib/bitbucket_rest_api/repos/services.rb +103 -0
- data/lib/bitbucket_rest_api/repos/sources.rb +31 -0
- data/lib/bitbucket_rest_api/repos.rb +238 -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 +51 -0
- data/lib/bitbucket_rest_api/request.rb +67 -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/response.rb +28 -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/account.rb +53 -0
- data/lib/bitbucket_rest_api/users.rb +24 -0
- data/lib/bitbucket_rest_api/utils/url.rb +56 -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 +24 -0
- data/lib/bitbucket_rest_api/validations/token.rb +43 -0
- data/lib/bitbucket_rest_api/validations.rb +25 -0
- data/lib/bitbucket_rest_api/version.rb +11 -0
- data/lib/bitbucket_rest_api.rb +91 -0
- metadata +338 -0
@@ -0,0 +1,118 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket
|
4
|
+
class Issues::Comments < API
|
5
|
+
|
6
|
+
VALID_ISSUE_COMMENT_PARAM_NAME = %w[
|
7
|
+
content
|
8
|
+
].freeze
|
9
|
+
|
10
|
+
# Creates new Issues::Comments API
|
11
|
+
def initialize(options = {})
|
12
|
+
super(options)
|
13
|
+
end
|
14
|
+
|
15
|
+
# List comments on an issue
|
16
|
+
#
|
17
|
+
# = Examples
|
18
|
+
# bitbucket = BitBucket.new
|
19
|
+
# bitbucket.issues.comments.all 'user-name', 'repo-name', 'issue-id'
|
20
|
+
# bitbucket.issues.comments.all 'user-name', 'repo-name', 'issue-id' {|com| .. }
|
21
|
+
#
|
22
|
+
def list(user_name, repo_name, issue_id, params={})
|
23
|
+
_update_user_repo_params(user_name, repo_name)
|
24
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
25
|
+
_validate_presence_of issue_id
|
26
|
+
|
27
|
+
normalize! params
|
28
|
+
# _merge_mime_type(:issue_comment, params)
|
29
|
+
|
30
|
+
response = get_request("/repositories/#{user}/#{repo.downcase}/issues/#{issue_id}/comments/", params)
|
31
|
+
return response unless block_given?
|
32
|
+
response.each { |el| yield el }
|
33
|
+
end
|
34
|
+
alias :all :list
|
35
|
+
|
36
|
+
# Get a single comment
|
37
|
+
#
|
38
|
+
# = Examples
|
39
|
+
# bitbucket = BitBucket.new
|
40
|
+
# bitbucket.issues.comments.find 'user-name', 'repo-name', 'comment-id'
|
41
|
+
#
|
42
|
+
def get(user_name, repo_name, comment_id, params={})
|
43
|
+
_update_user_repo_params(user_name, repo_name)
|
44
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
45
|
+
_validate_presence_of comment_id
|
46
|
+
|
47
|
+
normalize! params
|
48
|
+
# _merge_mime_type(:issue_comment, params)
|
49
|
+
|
50
|
+
get_request("/repositories/#{user}/#{repo.downcase}/issues/comments/#{comment_id}", params)
|
51
|
+
end
|
52
|
+
alias :find :get
|
53
|
+
|
54
|
+
# Create a comment
|
55
|
+
#
|
56
|
+
# = Inputs
|
57
|
+
# <tt>:content</tt> Required string
|
58
|
+
#
|
59
|
+
# = Examples
|
60
|
+
# bitbucket = BitBucket.new
|
61
|
+
# bitbucket.issues.comments.create 'user-name', 'repo-name', 'issue-id',
|
62
|
+
# "content" => 'a new comment'
|
63
|
+
#
|
64
|
+
def create(user_name, repo_name, issue_id, params={})
|
65
|
+
_update_user_repo_params(user_name, repo_name)
|
66
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
67
|
+
_validate_presence_of issue_id
|
68
|
+
|
69
|
+
normalize! params
|
70
|
+
# _merge_mime_type(:issue_comment, params)
|
71
|
+
filter! VALID_ISSUE_COMMENT_PARAM_NAME, params
|
72
|
+
assert_required_keys(%w[ content ], params)
|
73
|
+
|
74
|
+
post_request("/repositories/#{user}/#{repo.downcase}/issues/#{issue_id}/comments/", params)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Edit a comment
|
78
|
+
#
|
79
|
+
# = Inputs
|
80
|
+
# <tt>:content</tt> Required string
|
81
|
+
#
|
82
|
+
# = Examples
|
83
|
+
# bitbucket = BitBucket.new
|
84
|
+
# bitbucket.issues.comments.edit 'user-name', 'repo-name', 'comment-id',
|
85
|
+
# "content" => 'a new comment'
|
86
|
+
#
|
87
|
+
def edit(user_name, repo_name, comment_id, params={})
|
88
|
+
_update_user_repo_params(user_name, repo_name)
|
89
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
90
|
+
_validate_presence_of comment_id
|
91
|
+
|
92
|
+
normalize! params
|
93
|
+
# _merge_mime_type(:issue_comment, params)
|
94
|
+
filter! VALID_ISSUE_COMMENT_PARAM_NAME, params
|
95
|
+
assert_required_keys(%w[ content ], params)
|
96
|
+
|
97
|
+
put_request("/repositories/#{user}/#{repo.downcase}/issues/comments/#{comment_id}")
|
98
|
+
end
|
99
|
+
|
100
|
+
# Delete a comment
|
101
|
+
#
|
102
|
+
# = Examples
|
103
|
+
# bitbucket = BitBucket.new
|
104
|
+
# bitbucket.issues.comments.delete 'user-name', 'repo-name', 'comment-id'
|
105
|
+
#
|
106
|
+
def delete(user_name, repo_name, comment_id, params={})
|
107
|
+
_update_user_repo_params(user_name, repo_name)
|
108
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
109
|
+
_validate_presence_of comment_id
|
110
|
+
|
111
|
+
normalize! params
|
112
|
+
# _merge_mime_type(:issue_comment, params)
|
113
|
+
|
114
|
+
delete_request("/repositories/#{user}/#{repo.downcase}/issues/comments/#{comment_id}", params)
|
115
|
+
end
|
116
|
+
|
117
|
+
end # Issues::Comments
|
118
|
+
end # BitBucket
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket
|
4
|
+
class Issues::Components < API
|
5
|
+
|
6
|
+
VALID_COMPONENT_INPUTS = %w[ name ].freeze
|
7
|
+
|
8
|
+
# Creates new Issues::Components API
|
9
|
+
def initialize(options = {})
|
10
|
+
super(options)
|
11
|
+
end
|
12
|
+
# List all components for a repository
|
13
|
+
#
|
14
|
+
# = Examples
|
15
|
+
# bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
|
16
|
+
# bitbucket.issues.components.list
|
17
|
+
# bitbucket.issues.components.list { |component| ... }
|
18
|
+
#
|
19
|
+
def list(user_name, repo_name, params={})
|
20
|
+
_update_user_repo_params(user_name, repo_name)
|
21
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
22
|
+
normalize! params
|
23
|
+
|
24
|
+
response = get_request("/repositories/#{user}/#{repo.downcase}/issues/components", params)
|
25
|
+
return response unless block_given?
|
26
|
+
response.each { |el| yield el }
|
27
|
+
end
|
28
|
+
alias :all :list
|
29
|
+
|
30
|
+
# Get a single component
|
31
|
+
#
|
32
|
+
# = Examples
|
33
|
+
# bitbucket = BitBucket.new
|
34
|
+
# bitbucket.issues.components.find 'user-name', 'repo-name', 'component-id'
|
35
|
+
#
|
36
|
+
def get(user_name, repo_name, component_id, params={})
|
37
|
+
_update_user_repo_params(user_name, repo_name)
|
38
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
39
|
+
_validate_presence_of component_id
|
40
|
+
normalize! params
|
41
|
+
|
42
|
+
get_request("/repositories/#{user}/#{repo.downcase}/issues/components/#{component_id}", params)
|
43
|
+
end
|
44
|
+
alias :find :get
|
45
|
+
|
46
|
+
# Create a component
|
47
|
+
#
|
48
|
+
# = Inputs
|
49
|
+
# <tt>:name</tt> - Required string
|
50
|
+
#
|
51
|
+
# = Examples
|
52
|
+
# bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
|
53
|
+
# bitbucket.issues.components.create :name => 'API'
|
54
|
+
#
|
55
|
+
def create(user_name, repo_name, params={})
|
56
|
+
_update_user_repo_params(user_name, repo_name)
|
57
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
58
|
+
|
59
|
+
normalize! params
|
60
|
+
filter! VALID_COMPONENT_INPUTS, params
|
61
|
+
assert_required_keys(VALID_COMPONENT_INPUTS, params)
|
62
|
+
|
63
|
+
post_request("/repositories/#{user}/#{repo.downcase}/issues/components", params)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Update a component
|
67
|
+
#
|
68
|
+
# = Inputs
|
69
|
+
# <tt>:name</tt> - Required string
|
70
|
+
#
|
71
|
+
# = Examples
|
72
|
+
# @bitbucket = BitBucket.new
|
73
|
+
# @bitbucket.issues.components.update 'user-name', 'repo-name', 'component-id',
|
74
|
+
# :name => 'API'
|
75
|
+
#
|
76
|
+
def update(user_name, repo_name, component_id, params={})
|
77
|
+
_update_user_repo_params(user_name, repo_name)
|
78
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
79
|
+
_validate_presence_of component_id
|
80
|
+
|
81
|
+
normalize! params
|
82
|
+
filter! VALID_COMPONENT_INPUTS, params
|
83
|
+
assert_required_keys(VALID_COMPONENT_INPUTS, params)
|
84
|
+
|
85
|
+
put_request("/repositories/#{user}/#{repo.downcase}/issues/components/#{component_id}", params)
|
86
|
+
end
|
87
|
+
alias :edit :update
|
88
|
+
|
89
|
+
# Delete a component
|
90
|
+
#
|
91
|
+
# = Examples
|
92
|
+
# bitbucket = BitBucket.new
|
93
|
+
# bitbucket.issues.components.delete 'user-name', 'repo-name', 'component-id'
|
94
|
+
#
|
95
|
+
def delete(user_name, repo_name, component_id, params={})
|
96
|
+
_update_user_repo_params(user_name, repo_name)
|
97
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
98
|
+
|
99
|
+
_validate_presence_of component_id
|
100
|
+
normalize! params
|
101
|
+
|
102
|
+
delete_request("/repositories/#{user}/#{repo.downcase}/labels/components/#{component_id}", params)
|
103
|
+
end
|
104
|
+
|
105
|
+
end # Issues::Components
|
106
|
+
end # BitBucket
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket
|
4
|
+
class Issues::Milestones < API
|
5
|
+
|
6
|
+
VALID_MILESTONE_INPUTS = %w[
|
7
|
+
name
|
8
|
+
].freeze # :nodoc:
|
9
|
+
|
10
|
+
# Creates new Issues::Milestones API
|
11
|
+
def initialize(options = {})
|
12
|
+
super(options)
|
13
|
+
end
|
14
|
+
|
15
|
+
# List milestones for a repository
|
16
|
+
#
|
17
|
+
# = Examples
|
18
|
+
# bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
|
19
|
+
# bitbucket.issues.milestones.list
|
20
|
+
#
|
21
|
+
def list(user_name, repo_name, params={})
|
22
|
+
_update_user_repo_params(user_name, repo_name)
|
23
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
24
|
+
|
25
|
+
normalize! params
|
26
|
+
|
27
|
+
response = get_request("/repositories/#{user}/#{repo.downcase}/issues/milestones", params)
|
28
|
+
return response unless block_given?
|
29
|
+
response.each { |el| yield el }
|
30
|
+
end
|
31
|
+
alias :all :list
|
32
|
+
|
33
|
+
# Get a single milestone
|
34
|
+
#
|
35
|
+
# = Examples
|
36
|
+
# bitbucket = BitBucket.new
|
37
|
+
# bitbucket.issues.milestones.get 'user-name', 'repo-name', 'milestone-id'
|
38
|
+
#
|
39
|
+
def get(user_name, repo_name, milestone_id, params={})
|
40
|
+
_update_user_repo_params(user_name, repo_name)
|
41
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
42
|
+
_validate_presence_of milestone_id
|
43
|
+
normalize! params
|
44
|
+
|
45
|
+
get_request("/repositories/#{user}/#{repo.downcase}/issues/milestones/#{milestone_id}", params)
|
46
|
+
end
|
47
|
+
alias :find :get
|
48
|
+
|
49
|
+
# Create a milestone
|
50
|
+
#
|
51
|
+
# = Inputs
|
52
|
+
# <tt>:name</tt> - Required string
|
53
|
+
#
|
54
|
+
# = Examples
|
55
|
+
# bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
|
56
|
+
# bitbucket.issues.milestones.create :name => 'hello-world'
|
57
|
+
#
|
58
|
+
def create(user_name, repo_name, params={})
|
59
|
+
_update_user_repo_params(user_name, repo_name)
|
60
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
61
|
+
|
62
|
+
normalize! params
|
63
|
+
filter! VALID_MILESTONE_INPUTS, params
|
64
|
+
assert_required_keys(%w[ name ], params)
|
65
|
+
|
66
|
+
post_request("/repositories/#{user}/#{repo.downcase}/issues/milestones", params)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Update a milestone
|
70
|
+
#
|
71
|
+
# = Inputs
|
72
|
+
# <tt>:name</tt> - Required string
|
73
|
+
#
|
74
|
+
# = Examples
|
75
|
+
# bitbucket = BitBucket.new
|
76
|
+
# bitbucket.issues.milestones.update 'user-name', 'repo-name', 'milestone-id',
|
77
|
+
# :name => 'hello-world'
|
78
|
+
#
|
79
|
+
def update(user_name, repo_name, milestone_id, params={})
|
80
|
+
_update_user_repo_params(user_name, repo_name)
|
81
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
82
|
+
_validate_presence_of milestone_id
|
83
|
+
|
84
|
+
normalize! params
|
85
|
+
filter! VALID_MILESTONE_INPUTS, params
|
86
|
+
assert_required_keys(%w[ name ], params)
|
87
|
+
|
88
|
+
put_request("/repositories/#{user}/#{repo.downcase}/issues/milestones/#{milestone_id}", params)
|
89
|
+
end
|
90
|
+
|
91
|
+
# Delete a milestone
|
92
|
+
#
|
93
|
+
# = Examples
|
94
|
+
# bitbucket = BitBucket.new
|
95
|
+
# bitbucket.issues.milestones.delete 'user-name', 'repo-name', 'milestone-id'
|
96
|
+
#
|
97
|
+
def delete(user_name, repo_name, milestone_id, params={})
|
98
|
+
_update_user_repo_params(user_name, repo_name)
|
99
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
100
|
+
_validate_presence_of milestone_id
|
101
|
+
normalize! params
|
102
|
+
|
103
|
+
delete_request("/repositories/#{user}/#{repo.downcase}/issues/milestones/#{milestone_id}", params)
|
104
|
+
end
|
105
|
+
|
106
|
+
end # Issues::Milestones
|
107
|
+
end # BitBucket
|
@@ -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("/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("/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("/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("/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("/repositories/#{user}/#{repo.downcase}/issues/#{issue_id}/", params)
|
227
|
+
end
|
228
|
+
|
229
|
+
end # Issues
|
230
|
+
end # BitBucket
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module BitBucket
|
4
|
+
# Deals with normalizing client supplied parameter keys.
|
5
|
+
module Normalizer
|
6
|
+
|
7
|
+
# Turns any keys from nested hashes including nested arrays into strings
|
8
|
+
#
|
9
|
+
def normalize!(params)
|
10
|
+
case params
|
11
|
+
when Hash
|
12
|
+
params.keys.each do |k|
|
13
|
+
params[k.to_s] = params.delete(k)
|
14
|
+
normalize!(params[k.to_s])
|
15
|
+
end
|
16
|
+
when Array
|
17
|
+
params.map! do |el|
|
18
|
+
normalize!(el)
|
19
|
+
end
|
20
|
+
else
|
21
|
+
params.to_s
|
22
|
+
end
|
23
|
+
return params
|
24
|
+
end
|
25
|
+
|
26
|
+
end # Normalizer
|
27
|
+
end # BitBucket
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module BitBucket
|
4
|
+
# Allows you to specify parameters keys which will be preserved
|
5
|
+
# in parameters hash and its subhashes. Any keys from the nested
|
6
|
+
# hash that do not match will be removed.
|
7
|
+
module ParameterFilter
|
8
|
+
|
9
|
+
# Removes any keys from nested hashes that don't match predefiend keys
|
10
|
+
#
|
11
|
+
def filter!(keys, params, options={:recursive => true}) # :nodoc:
|
12
|
+
case params
|
13
|
+
when Hash
|
14
|
+
params.keys.each do |k, v|
|
15
|
+
unless (keys.include?(k) or BitBucket::Validations::VALID_API_KEYS.include?(k))
|
16
|
+
params.delete(k)
|
17
|
+
else
|
18
|
+
filter!(keys, params[k]) if options[:recursive]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
when Array
|
22
|
+
params.map! do |el|
|
23
|
+
filter!(keys, el) if options[:recursive]
|
24
|
+
end
|
25
|
+
else
|
26
|
+
params
|
27
|
+
end
|
28
|
+
return params
|
29
|
+
end
|
30
|
+
|
31
|
+
end # Filter
|
32
|
+
end # BitBucket
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BitBucket
|
4
|
+
class Repos::Changesets < API
|
5
|
+
|
6
|
+
REQUIRED_COMMENT_PARAMS = %w[
|
7
|
+
body
|
8
|
+
changeset_id
|
9
|
+
line
|
10
|
+
path
|
11
|
+
position
|
12
|
+
].freeze
|
13
|
+
|
14
|
+
# List changesets on a repository
|
15
|
+
#
|
16
|
+
# = Parameters
|
17
|
+
# * <tt>:limit</tt> Optional integer. An integer representing how many changesets to return. You can specify a limit between 0 and 50.
|
18
|
+
# * <tt>:start</tt> Optional string. A hash value representing the earliest node to start with.
|
19
|
+
#
|
20
|
+
# = Examples
|
21
|
+
# bitbucket = BitBucket.new
|
22
|
+
# bitbucket.repos.changesets.list 'user-name', 'repo-name', :start => '...'
|
23
|
+
# bitbucket.repos.changesets.list 'user-name', 'repo-name', :start => '...' { |changeset| ... }
|
24
|
+
#
|
25
|
+
def list(user_name, repo_name, params={})
|
26
|
+
_update_user_repo_params(user_name, repo_name)
|
27
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
28
|
+
normalize! params
|
29
|
+
filter! %w[ limit start], params
|
30
|
+
|
31
|
+
response = get_request("/repositories/#{user}/#{repo.downcase}/changesets", params)
|
32
|
+
return response unless block_given?
|
33
|
+
response.each { |el| yield el }
|
34
|
+
end
|
35
|
+
alias :all :list
|
36
|
+
|
37
|
+
# Gets a single changeset
|
38
|
+
#
|
39
|
+
# = Examples
|
40
|
+
# @bitbucket = BitBucket.new
|
41
|
+
# @bitbucket.repos.changesets.get 'user-name', 'repo-name', '6dcb09b5b57875f334f61aebed6')
|
42
|
+
#
|
43
|
+
def get(user_name, repo_name, sha, params={})
|
44
|
+
_update_user_repo_params(user_name, repo_name)
|
45
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
46
|
+
_validate_presence_of sha
|
47
|
+
normalize! params
|
48
|
+
|
49
|
+
get_request("/repositories/#{user}/#{repo.downcase}/changesets/#{sha}", params)
|
50
|
+
end
|
51
|
+
alias :find :get
|
52
|
+
|
53
|
+
end # Repos::Commits
|
54
|
+
end # BitBucket
|