-
Notifications
You must be signed in to change notification settings - Fork 171
Expand file tree
/
Copy pathprivileges.rb
More file actions
56 lines (48 loc) · 1.73 KB
/
Copy pathprivileges.rb
File metadata and controls
56 lines (48 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# encoding: utf-8
module BitBucket
class Privileges < API
VALID_KEY_PARAM_NAMES = %w(filter).freeze
# Creates new Privileges API
def initialize(options = {})
super(options)
end
# Gets a list of the privileges granted on a repository.
#
# = Parameters
# *<tt>filter</tt> - Filters for a particular privilege. The acceptable values are:<tt>read</tt>, <tt>write</tt> and <tt>admin</tt>.
#
# = Examples
# bitbucket = BitBucket.new
# bitbucket.privileges.list 'user-name', 'repo-name', :filter => "admin"
#
def list_on_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_KEY_PARAM_NAMES, params
response = get_request("/1.0/privileges/#{user}/#{repo.downcase}/", params)
return response unless block_given?
response.each { |el| yield el }
end
alias :all_on_repo :list_on_repo
# Gets a list of all the privilege across all an account's repositories.
#
# = Parameters
# *<tt>filter</tt> - Filters for a particular privilege. The acceptable values are:<tt>read</tt>, <tt>write</tt> and <tt>admin</tt>.
#
# = Examples
# bitbucket = BitBucket.new
# bitbucket.privileges.list 'user-name', :filter => "admin"
#
def list(user_name, params={})
_update_user_repo_params(user_name)
_validate_presence_of user_name
normalize! params
filter! VALID_KEY_PARAM_NAMES, params
response = get_request("/1.0/privileges/#{user}/", params)
return response unless block_given?
response.each { |el| yield el }
end
alias :all :list
end # Privileges
end # BitBucket