github_api 0.4.11 → 0.5.0.rc1
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.
- data/README.md +76 -72
- data/features/cassettes/gists/starred.yml +48 -0
- data/features/cassettes/pagination/repos/commits/list.yml +193 -0
- data/features/cassettes/pagination/repos/commits/next.yml +183 -0
- data/features/cassettes/pagination/repos/diff/next.yml +45 -0
- data/features/cassettes/pagination/repos/list.yml +176 -0
- data/features/cassettes/pagination/repos/list/next.yml +222 -0
- data/features/cassettes/pagination/repos/per_page/each_page.yml +45 -0
- data/features/cassettes/repos/list.yml +92 -0
- data/features/error_codes.feature +1 -1
- data/features/gists.feature +12 -3
- data/features/gists/comments.feature +3 -3
- data/features/github_api.feature +13 -2
- data/features/pagination.feature +40 -39
- data/features/repos.feature +2 -2
- data/features/step_definitions/common_steps.rb +12 -0
- data/features/step_definitions/github_api_steps.rb +12 -1
- data/lib/github_api.rb +1 -1
- data/lib/github_api/api.rb +4 -2
- data/lib/github_api/api_factory.rb +11 -5
- data/lib/github_api/authorizations.rb +23 -32
- data/lib/github_api/client.rb +1 -0
- data/lib/github_api/events.rb +38 -38
- data/lib/github_api/filter.rb +1 -1
- data/lib/github_api/gists.rb +47 -42
- data/lib/github_api/gists/comments.rb +77 -84
- data/lib/github_api/git_data.rb +25 -6
- data/lib/github_api/git_data/blobs.rb +48 -45
- data/lib/github_api/git_data/commits.rb +76 -73
- data/lib/github_api/git_data/references.rb +137 -118
- data/lib/github_api/git_data/tags.rb +74 -70
- data/lib/github_api/git_data/trees.rb +88 -85
- data/lib/github_api/issues.rb +43 -31
- data/lib/github_api/issues/comments.rb +116 -119
- data/lib/github_api/issues/events.rb +20 -19
- data/lib/github_api/issues/labels.rb +200 -197
- data/lib/github_api/issues/milestones.rb +137 -134
- data/lib/github_api/orgs.rb +27 -23
- data/lib/github_api/orgs/members.rb +105 -108
- data/lib/github_api/orgs/teams.rb +236 -237
- data/lib/github_api/paged_request.rb +1 -1
- data/lib/github_api/pull_requests.rb +40 -42
- data/lib/github_api/pull_requests/comments.rb +140 -143
- data/lib/github_api/repos.rb +101 -67
- data/lib/github_api/repos/collaborators.rb +64 -68
- data/lib/github_api/repos/commits.rb +50 -39
- data/lib/github_api/repos/downloads.rb +107 -110
- data/lib/github_api/repos/forks.rb +38 -39
- data/lib/github_api/repos/hooks.rb +161 -167
- data/lib/github_api/repos/keys.rb +86 -86
- data/lib/github_api/repos/pub_sub_hubbub.rb +99 -87
- data/lib/github_api/repos/watching.rb +80 -82
- data/lib/github_api/request.rb +5 -9
- data/lib/github_api/users.rb +26 -16
- data/lib/github_api/users/emails.rb +47 -47
- data/lib/github_api/users/followers.rb +85 -86
- data/lib/github_api/users/keys.rb +73 -75
- data/lib/github_api/validations.rb +25 -0
- data/lib/github_api/validations/format.rb +23 -0
- data/lib/github_api/validations/presence.rb +25 -0
- data/lib/github_api/validations/required.rb +21 -0
- data/lib/github_api/validations/token.rb +41 -0
- data/lib/github_api/version.rb +3 -3
- data/spec/fixtures/repos/commit_comparison.json +112 -0
- data/spec/github/api_factory_spec.rb +17 -1
- data/spec/github/authorizations_spec.rb +36 -34
- data/spec/github/gists/comments_spec.rb +39 -45
- data/spec/github/gists_spec.rb +50 -53
- data/spec/github/git_data/blobs_spec.rb +27 -20
- data/spec/github/git_data/commits_spec.rb +20 -19
- data/spec/github/git_data/references_spec.rb +83 -46
- data/spec/github/git_data/tags_spec.rb +16 -15
- data/spec/github/git_data/trees_spec.rb +20 -19
- data/spec/github/git_data_spec.rb +10 -1
- data/spec/github/issues/comments_spec.rb +78 -68
- data/spec/github/issues/events_spec.rb +42 -34
- data/spec/github/issues/labels_spec.rb +89 -101
- data/spec/github/issues/milestones_spec.rb +76 -54
- data/spec/github/issues_spec.rb +53 -57
- data/spec/github/orgs/members_spec.rb +64 -49
- data/spec/github/orgs/teams_spec.rb +112 -101
- data/spec/github/orgs_spec.rb +41 -31
- data/spec/github/paged_request_spec.rb +6 -5
- data/spec/github/pull_requests/comments_spec.rb +39 -44
- data/spec/github/pull_requests_spec.rb +32 -48
- data/spec/github/repos/collaborators_spec.rb +40 -29
- data/spec/github/repos/commits_spec.rb +108 -64
- data/spec/github/repos/downloads_spec.rb +46 -45
- data/spec/github/repos/forks_spec.rb +23 -24
- data/spec/github/repos/hooks_spec.rb +69 -71
- data/spec/github/repos/keys_spec.rb +39 -34
- data/spec/github/repos/pub_sub_hubbub_spec.rb +4 -4
- data/spec/github/repos/watching_spec.rb +31 -33
- data/spec/github/repos_spec.rb +74 -83
- data/spec/github/request_spec.rb +31 -2
- data/spec/github/users/emails_spec.rb +19 -17
- data/spec/github/users/followers_spec.rb +30 -28
- data/spec/github/users/keys_spec.rb +37 -33
- data/spec/github/users_spec.rb +124 -125
- data/spec/github/validations/format_spec.rb +42 -0
- data/spec/github/validations/presence_spec.rb +18 -0
- data/spec/github/validations/required_spec.rb +28 -0
- data/spec/github/validations/token_spec.rb +19 -0
- data/spec/github/validations_spec.rb +23 -0
- metadata +33 -10
- data/features/cassettes/pagination/repos.yml +0 -177
- data/features/cassettes/pagination/repos/next.yml +0 -177
- data/lib/github_api/validation.rb +0 -53
- data/spec/github/validation_spec.rb +0 -62
data/lib/github_api/orgs.rb
CHANGED
|
@@ -8,9 +8,6 @@ module Github
|
|
|
8
8
|
:Members => 'members',
|
|
9
9
|
:Teams => 'teams'
|
|
10
10
|
|
|
11
|
-
include Github::Orgs::Members
|
|
12
|
-
include Github::Orgs::Teams
|
|
13
|
-
|
|
14
11
|
VALID_ORG_PARAM_NAMES = %w[
|
|
15
12
|
billing_email
|
|
16
13
|
company
|
|
@@ -24,44 +21,52 @@ module Github
|
|
|
24
21
|
super(options)
|
|
25
22
|
end
|
|
26
23
|
|
|
24
|
+
# Access to Orgs::Members API
|
|
25
|
+
def members
|
|
26
|
+
@members ||= ApiFactory.new 'Orgs::Members'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Access to Orgs::Teams API
|
|
30
|
+
def teams
|
|
31
|
+
@teams ||= ApiFactory.new 'Orgs::Teams'
|
|
32
|
+
end
|
|
33
|
+
|
|
27
34
|
# List all public organizations for a user.
|
|
28
35
|
#
|
|
29
36
|
# = Examples
|
|
30
|
-
#
|
|
31
|
-
#
|
|
37
|
+
# github = Github.new :user => 'user-name'
|
|
38
|
+
# github.orgs.list
|
|
32
39
|
#
|
|
33
40
|
# List public and private organizations for the authenticated user.
|
|
34
41
|
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
42
|
+
# github = Github.new :oauth_token => '..'
|
|
43
|
+
# github.orgs.list 'github'
|
|
37
44
|
#
|
|
38
|
-
def
|
|
45
|
+
def list(user_name=nil, params={})
|
|
39
46
|
_update_user_repo_params(user_name)
|
|
40
47
|
_normalize_params_keys(params)
|
|
41
48
|
|
|
42
49
|
response = if user?
|
|
43
|
-
|
|
50
|
+
get_request("/users/#{user}/orgs", params)
|
|
44
51
|
else
|
|
45
|
-
|
|
52
|
+
get_request("/user/orgs", params)
|
|
46
53
|
end
|
|
47
54
|
return response unless block_given?
|
|
48
55
|
response.each { |el| yield el }
|
|
49
56
|
end
|
|
50
|
-
alias :
|
|
51
|
-
alias :list_organizations :orgs
|
|
57
|
+
alias :all :list
|
|
52
58
|
|
|
53
59
|
# Get properties for a single organization
|
|
54
60
|
#
|
|
55
61
|
# = Examples
|
|
56
|
-
#
|
|
57
|
-
#
|
|
62
|
+
# github = Github.new
|
|
63
|
+
# github.orgs.get 'github'
|
|
58
64
|
#
|
|
59
|
-
def
|
|
65
|
+
def get(org_name, params={})
|
|
60
66
|
_validate_presence_of org_name
|
|
61
|
-
|
|
67
|
+
get_request("/orgs/#{org_name}", params)
|
|
62
68
|
end
|
|
63
|
-
alias :
|
|
64
|
-
alias :organisation :org
|
|
69
|
+
alias :find :get
|
|
65
70
|
|
|
66
71
|
# Edit organization
|
|
67
72
|
#
|
|
@@ -73,8 +78,8 @@ module Github
|
|
|
73
78
|
# <tt>:name</tt> - Optional string
|
|
74
79
|
#
|
|
75
80
|
# = Examples
|
|
76
|
-
#
|
|
77
|
-
#
|
|
81
|
+
# github = Github.new :oauth_token => '...'
|
|
82
|
+
# github.orgs.edit 'github',
|
|
78
83
|
# "billing_email" => "support@github.com",
|
|
79
84
|
# "blog" => "https://github.com/blog",
|
|
80
85
|
# "company" => "GitHub",
|
|
@@ -82,14 +87,13 @@ module Github
|
|
|
82
87
|
# "location" => "San Francisco",
|
|
83
88
|
# "name" => "github"
|
|
84
89
|
#
|
|
85
|
-
def
|
|
90
|
+
def edit(org_name, params={})
|
|
86
91
|
_validate_presence_of org_name
|
|
87
92
|
_normalize_params_keys(params)
|
|
88
93
|
_filter_params_keys(VALID_ORG_PARAM_NAMES, params)
|
|
89
94
|
|
|
90
|
-
|
|
95
|
+
patch_request("/orgs/#{org_name}", params)
|
|
91
96
|
end
|
|
92
|
-
alias :edit_organization :edit_org
|
|
93
97
|
|
|
94
98
|
end # Orgs
|
|
95
99
|
end # Github
|
|
@@ -1,120 +1,117 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
module Github
|
|
4
|
-
class Orgs
|
|
5
|
-
module Members
|
|
4
|
+
class Orgs::Members < API
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
# List members
|
|
7
|
+
#
|
|
8
|
+
# List all users who are members of an organization. A member is a user
|
|
9
|
+
# that belongs to at least 1 team in the organization.
|
|
10
|
+
# If the authenticated user is also a member of this organization then
|
|
11
|
+
# both concealed and public members will be returned.
|
|
12
|
+
# Otherwise only public members are returned.
|
|
13
|
+
#
|
|
14
|
+
# = Examples
|
|
15
|
+
# github = Github.new
|
|
16
|
+
# github.orgs.members.list 'org-name'
|
|
17
|
+
# github.orgs.members.list 'org-name' { |memb| ... }
|
|
18
|
+
#
|
|
19
|
+
def list(org_name, params={})
|
|
20
|
+
_validate_presence_of org_name
|
|
21
|
+
_normalize_params_keys(params)
|
|
22
|
+
response = get_request("/orgs/#{org_name}/members", params)
|
|
23
|
+
return response unless block_given?
|
|
24
|
+
response.each { |el| yield el }
|
|
25
|
+
end
|
|
26
|
+
alias :all :list
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
alias :is_member? :member?
|
|
28
|
+
# Check if user is a member of an organization
|
|
29
|
+
#
|
|
30
|
+
# = Examples
|
|
31
|
+
# github = Github.new
|
|
32
|
+
# github.orgs.members.member? 'org-name', 'member-name'
|
|
33
|
+
#
|
|
34
|
+
def member?(org_name, member_name, params={})
|
|
35
|
+
_validate_presence_of org_name, member_name
|
|
36
|
+
_normalize_params_keys(params)
|
|
37
|
+
get_request("/orgs/#{org_name}/members/#{member_name}", params)
|
|
38
|
+
true
|
|
39
|
+
rescue Github::Error::NotFound
|
|
40
|
+
false
|
|
41
|
+
end
|
|
44
42
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
43
|
+
# Remove a member
|
|
44
|
+
# Removing a user from this list will remove them from all teams and
|
|
45
|
+
# they will no longer have any access to the organization’s repositories.
|
|
46
|
+
#
|
|
47
|
+
# = Examples
|
|
48
|
+
# github = Github.new
|
|
49
|
+
# github.orgs.members.remove 'org-name', 'member-name'
|
|
50
|
+
#
|
|
51
|
+
def delete(org_name, member_name, params={})
|
|
52
|
+
_validate_presence_of org_name, member_name
|
|
53
|
+
_normalize_params_keys(params)
|
|
54
|
+
delete_request("/orgs/#{org_name}/members/#{member_name}", params)
|
|
55
|
+
end
|
|
56
|
+
alias :remove :delete
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
58
|
+
# List public members
|
|
59
|
+
# Members of an organization can choose to have their membership publicized or not.
|
|
60
|
+
# = Examples
|
|
61
|
+
# github = Github.new
|
|
62
|
+
# github.orgs.members.list_public 'org-name'
|
|
63
|
+
# github.orgs.members.list_public 'org-name' { |memb| ... }
|
|
64
|
+
#
|
|
65
|
+
def list_public(org_name, params={})
|
|
66
|
+
_validate_presence_of org_name
|
|
67
|
+
_normalize_params_keys(params)
|
|
68
|
+
response = get_request("/orgs/#{org_name}/public_members", params)
|
|
69
|
+
return response unless block_given?
|
|
70
|
+
response.each { |el| yield el }
|
|
71
|
+
end
|
|
72
|
+
alias :public_members :list_public
|
|
75
73
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
74
|
+
# Get if a user is a public member of an organization
|
|
75
|
+
#
|
|
76
|
+
# = Examples
|
|
77
|
+
# github = Github.new
|
|
78
|
+
# github.orgs.members.public_member? 'org-name', 'member-name'
|
|
79
|
+
#
|
|
80
|
+
def public_member?(org_name, member_name, params={})
|
|
81
|
+
_validate_presence_of org_name, member_name
|
|
82
|
+
_normalize_params_keys(params)
|
|
83
|
+
get_request("/orgs/#{org_name}/public_members/#{member_name}", params)
|
|
84
|
+
true
|
|
85
|
+
rescue Github::Error::NotFound
|
|
86
|
+
false
|
|
87
|
+
end
|
|
90
88
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
89
|
+
# Publicize a user’s membership
|
|
90
|
+
#
|
|
91
|
+
# = Examples
|
|
92
|
+
# github = Github.new :oauth_token => '...'
|
|
93
|
+
# github.orgs.members.publicize 'org-name', 'member-name'
|
|
94
|
+
#
|
|
95
|
+
def publicize(org_name, member_name, params={})
|
|
96
|
+
_validate_presence_of org_name, member_name
|
|
97
|
+
_normalize_params_keys(params)
|
|
98
|
+
put_request("/orgs/#{org_name}/public_members/#{member_name}", params)
|
|
99
|
+
end
|
|
100
|
+
alias :make_public :publicize
|
|
101
|
+
alias :publicize_membership :publicize
|
|
104
102
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
103
|
+
# Conceal a user’s membership
|
|
104
|
+
#
|
|
105
|
+
# = Examples
|
|
106
|
+
# github = Github.new :oauth_token => '...'
|
|
107
|
+
# github.orgs.members.conceal 'org-name', 'member-name'
|
|
108
|
+
#
|
|
109
|
+
def conceal(org_name, member_name, params={})
|
|
110
|
+
_validate_presence_of org_name, member_name
|
|
111
|
+
_normalize_params_keys(params)
|
|
112
|
+
delete_request("/orgs/#{org_name}/public_members/#{member_name}", params)
|
|
113
|
+
end
|
|
114
|
+
alias :conceal_membership :conceal
|
|
117
115
|
|
|
118
|
-
|
|
119
|
-
end # Orgs
|
|
116
|
+
end # Orgs::Members
|
|
120
117
|
end # Github
|
|
@@ -1,244 +1,243 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
module Github
|
|
4
|
-
class Orgs
|
|
4
|
+
class Orgs::Teams < API
|
|
5
5
|
# All actions against teams require at a minimum an authenticated user
|
|
6
6
|
# who is a member of the owner’s team in the :org being managed.
|
|
7
7
|
# Api calls that require explicit permissions are noted.
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
end # Orgs
|
|
8
|
+
|
|
9
|
+
VALID_TEAM_PARAM_NAMES = %w[ name repo_names permission ].freeze
|
|
10
|
+
VALID_TEAM_PARAM_VALUES = {
|
|
11
|
+
'permission' => %w[ pull push admin ].freeze
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
# List teams
|
|
15
|
+
#
|
|
16
|
+
# = Examples
|
|
17
|
+
# github = Github.new :oauth_token => '...'
|
|
18
|
+
# github.orgs.teams.list 'org-name'
|
|
19
|
+
#
|
|
20
|
+
def list(org_name, params={})
|
|
21
|
+
_validate_presence_of org_name
|
|
22
|
+
_normalize_params_keys(params)
|
|
23
|
+
|
|
24
|
+
response = get_request("/orgs/#{org_name}/teams", params)
|
|
25
|
+
return response unless block_given?
|
|
26
|
+
response.each { |el| yield el }
|
|
27
|
+
end
|
|
28
|
+
alias :all :list
|
|
29
|
+
|
|
30
|
+
# Get a team
|
|
31
|
+
#
|
|
32
|
+
# = Examples
|
|
33
|
+
# github = Github.new :oauth_token => '...'
|
|
34
|
+
# github.orgs.teams.get 'team-name'
|
|
35
|
+
#
|
|
36
|
+
def get(team_name, params={})
|
|
37
|
+
_validate_presence_of team_name
|
|
38
|
+
_normalize_params_keys(params)
|
|
39
|
+
|
|
40
|
+
get_request("/teams/#{team_name}", params)
|
|
41
|
+
end
|
|
42
|
+
alias :find :get
|
|
43
|
+
|
|
44
|
+
# Create a team
|
|
45
|
+
#
|
|
46
|
+
# In order to create a team, the authenticated user must be an owner of<tt>:org</tt>.
|
|
47
|
+
# = Inputs
|
|
48
|
+
# <tt>:name</tt> - Required string
|
|
49
|
+
# <tt>:repo_names</tt> - Optional array of strings
|
|
50
|
+
# <tt>:permission</tt> - Optional string
|
|
51
|
+
# * <tt>pull</tt> - team members can pull, but not push or administor this repositories. Default
|
|
52
|
+
# * <tt>push</tt> - team members can pull and push, but not administor this repositores.
|
|
53
|
+
# * <tt>admin</tt> - team members can pull, push and administor these repositories.
|
|
54
|
+
#
|
|
55
|
+
# = Examples
|
|
56
|
+
# github = Github.new :oauth_token => '...'
|
|
57
|
+
# github.orgs.teams.create 'org-name',
|
|
58
|
+
# "name" => "new team",
|
|
59
|
+
# "permission" => "push",
|
|
60
|
+
# "repo_names" => [
|
|
61
|
+
# "github/dotfiles"
|
|
62
|
+
# ]
|
|
63
|
+
#
|
|
64
|
+
def create(org_name, params={})
|
|
65
|
+
_validate_presence_of org_name
|
|
66
|
+
_normalize_params_keys(params)
|
|
67
|
+
_filter_params_keys(VALID_TEAM_PARAM_NAMES, params)
|
|
68
|
+
_validate_params_values(VALID_TEAM_PARAM_VALUES, params)
|
|
69
|
+
_validate_inputs(%w[ name ], params)
|
|
70
|
+
|
|
71
|
+
post_request("/orgs/#{org_name}/teams", params)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Edit a team
|
|
75
|
+
# In order to edit a team, the authenticated user must be an owner of the org that the team is associated with.
|
|
76
|
+
#
|
|
77
|
+
# = Inputs
|
|
78
|
+
# <tt>:name</tt> - Required string
|
|
79
|
+
# <tt>:permission</tt> - Optional string
|
|
80
|
+
# * <tt>pull</tt> - team members can pull, but not push or administor this repositories. Default
|
|
81
|
+
# * <tt>push</tt> - team members can pull and push, but not administor this repositores.
|
|
82
|
+
# * <tt>admin</tt> - team members can pull, push and administor these repositories.
|
|
83
|
+
#
|
|
84
|
+
# = Examples
|
|
85
|
+
# github = Github.new :oauth_token => '...'
|
|
86
|
+
# github.orgs.teams.edit 'team-name',
|
|
87
|
+
# "name" => "new team name",
|
|
88
|
+
# "permission" => "push"
|
|
89
|
+
#
|
|
90
|
+
def edit(team_name, params={})
|
|
91
|
+
_validate_presence_of team_name
|
|
92
|
+
_normalize_params_keys(params)
|
|
93
|
+
|
|
94
|
+
_filter_params_keys(VALID_TEAM_PARAM_NAMES, params)
|
|
95
|
+
_validate_params_values(VALID_TEAM_PARAM_VALUES, params)
|
|
96
|
+
_validate_inputs(%w[ name ], params)
|
|
97
|
+
|
|
98
|
+
patch_request("/teams/#{team_name}", params)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Delete a team
|
|
102
|
+
# In order to delete a team, the authenticated user must be an owner of the org that the team is associated with
|
|
103
|
+
#
|
|
104
|
+
# = Examples
|
|
105
|
+
# github = Github.new :oauth_token => '...'
|
|
106
|
+
# github.orgs.teams.delete 'team-name'
|
|
107
|
+
#
|
|
108
|
+
def delete(team_name, params={})
|
|
109
|
+
_validate_presence_of team_name
|
|
110
|
+
_normalize_params_keys(params)
|
|
111
|
+
delete_request("/teams/#{team_name}", params)
|
|
112
|
+
end
|
|
113
|
+
alias :remove :delete
|
|
114
|
+
|
|
115
|
+
# List team members
|
|
116
|
+
# In order to list members in a team, the authenticated user must be a member of the team.
|
|
117
|
+
#
|
|
118
|
+
# = Examples
|
|
119
|
+
# github = Github.new :oauth_token => '...'
|
|
120
|
+
# github.orgs.teams.list_members 'team-name'
|
|
121
|
+
# github.orgs.teams.list_members 'team-name' { |member| ... }
|
|
122
|
+
#
|
|
123
|
+
def list_members(team_name, params={})
|
|
124
|
+
_validate_presence_of team_name
|
|
125
|
+
_normalize_params_keys(params)
|
|
126
|
+
|
|
127
|
+
response = get_request("/teams/#{team_name}/members", params)
|
|
128
|
+
return response unless block_given?
|
|
129
|
+
response.each { |el| yield el }
|
|
130
|
+
end
|
|
131
|
+
alias :all_members :list_members
|
|
132
|
+
|
|
133
|
+
# Check if a user is a member of a team
|
|
134
|
+
#
|
|
135
|
+
# = Examples
|
|
136
|
+
# github = Github.new :oauth_token => '...'
|
|
137
|
+
# github.orgs.teams.team_member? 'team-name', 'user-name'
|
|
138
|
+
#
|
|
139
|
+
def team_member?(team_name, member_name, params={})
|
|
140
|
+
_validate_presence_of team_name, member_name
|
|
141
|
+
_normalize_params_keys(params)
|
|
142
|
+
get_request("/teams/#{team_name}/members/#{member_name}", params)
|
|
143
|
+
true
|
|
144
|
+
rescue Github::Error::NotFound
|
|
145
|
+
false
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Add a team member
|
|
149
|
+
# In order to add a user to a team, the authenticated user must have ‘admin’ permissions to the team or be an owner of the org that the team is associated with.
|
|
150
|
+
#
|
|
151
|
+
# = Examples
|
|
152
|
+
# github = Github.new :oauth_token => '...'
|
|
153
|
+
# github.orgs.teams.add_member 'team-name', 'user-name'
|
|
154
|
+
#
|
|
155
|
+
def add_member(team_name, member_name, params={})
|
|
156
|
+
_validate_presence_of team_name, member_name
|
|
157
|
+
_normalize_params_keys(params)
|
|
158
|
+
put_request("/teams/#{team_name}/members/#{member_name}", params)
|
|
159
|
+
end
|
|
160
|
+
alias :add_team_member :add_member
|
|
161
|
+
|
|
162
|
+
# Remove a team member
|
|
163
|
+
# In order to remove a user from a team, the authenticated user must
|
|
164
|
+
# have ‘admin’ permissions to the team or be an owner of the org that
|
|
165
|
+
# the team is associated with.
|
|
166
|
+
# note: This does not delete the user, it just remove them from the team.
|
|
167
|
+
#
|
|
168
|
+
# = Examples
|
|
169
|
+
# github = Github.new :oauth_token => '...'
|
|
170
|
+
# github.orgs.teams.remove_member 'team-name', 'member-name'
|
|
171
|
+
#
|
|
172
|
+
def remove_member(team_name, member_name, params={})
|
|
173
|
+
_validate_presence_of team_name, member_name
|
|
174
|
+
_normalize_params_keys(params)
|
|
175
|
+
delete_request("/teams/#{team_name}/members/#{member_name}", params)
|
|
176
|
+
end
|
|
177
|
+
alias :remove_team_member :remove_member
|
|
178
|
+
|
|
179
|
+
# List team repositories
|
|
180
|
+
#
|
|
181
|
+
# = Examples
|
|
182
|
+
# github = Github.new :oauth_token => '...'
|
|
183
|
+
# github.orgs.teams.list_repos 'team-name'
|
|
184
|
+
#
|
|
185
|
+
def list_repos(team_name, params={})
|
|
186
|
+
_validate_presence_of team_name
|
|
187
|
+
_normalize_params_keys(params)
|
|
188
|
+
|
|
189
|
+
response = get_request("/teams/#{team_name}/repos", params)
|
|
190
|
+
return response unless block_given?
|
|
191
|
+
response.each { |el| yield el }
|
|
192
|
+
end
|
|
193
|
+
alias :repos :list_repos
|
|
194
|
+
|
|
195
|
+
# Check if a repository belongs to a team
|
|
196
|
+
#
|
|
197
|
+
# = Examples
|
|
198
|
+
# github = Github.new :oauth_token => '...'
|
|
199
|
+
# github.orgs.teams.team_repo? 'team-name', 'user-name', 'repo-name'
|
|
200
|
+
#
|
|
201
|
+
def team_repo?(team_name, user_name, repo_name, params={})
|
|
202
|
+
_validate_presence_of team_name, user_name, repo_name
|
|
203
|
+
_normalize_params_keys(params)
|
|
204
|
+
get_request("/teams/#{team_name}/repos/#{user_name}/#{repo_name}", params)
|
|
205
|
+
true
|
|
206
|
+
rescue Github::Error::NotFound
|
|
207
|
+
false
|
|
208
|
+
end
|
|
209
|
+
alias :team_repository? :team_repo?
|
|
210
|
+
|
|
211
|
+
# Add a team repository
|
|
212
|
+
# In order to add a repo to a team, the authenticated user must be
|
|
213
|
+
# an owner of the org that the team is associated with.
|
|
214
|
+
#
|
|
215
|
+
# = Examples
|
|
216
|
+
# github = Github.new :oauth_token => '...'
|
|
217
|
+
# github.orgs.teams.add_repo 'team-name', 'user-name', 'repo-name'
|
|
218
|
+
#
|
|
219
|
+
def add_repo(team_name, user_name, repo_name, params={})
|
|
220
|
+
_validate_presence_of team_name, user_name, repo_name
|
|
221
|
+
_normalize_params_keys(params)
|
|
222
|
+
put_request("/teams/#{team_name}/repos/#{user_name}/#{repo_name}", params)
|
|
223
|
+
end
|
|
224
|
+
alias :add_repository :add_repo
|
|
225
|
+
|
|
226
|
+
# Remove a team repository
|
|
227
|
+
# In order to add a repo to a team, the authenticated user must be
|
|
228
|
+
# an owner of the org that the team is associated with.
|
|
229
|
+
# note: This does not delete the repo, it just removes it from the team.
|
|
230
|
+
#
|
|
231
|
+
# = Examples
|
|
232
|
+
# github = Github.new :oauth_token => '...'
|
|
233
|
+
# github.orgs.teams.remove_repo 'team-name', 'user-name', 'repo-name'
|
|
234
|
+
#
|
|
235
|
+
def remove_repo(team_name, user_name, repo_name, params={})
|
|
236
|
+
_validate_presence_of team_name, user_name, repo_name
|
|
237
|
+
_normalize_params_keys(params)
|
|
238
|
+
delete_request("/teams/#{team_name}/repos/#{user_name}/#{repo_name}", params)
|
|
239
|
+
end
|
|
240
|
+
alias :remove_repository :remove_repo
|
|
241
|
+
|
|
242
|
+
end # Orgs::Teams
|
|
244
243
|
end # Github
|