octokit 4.2.0 → 9.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 +5 -5
- data/CONTRIBUTING.md +14 -13
- data/LICENSE.md +1 -1
- data/README.md +275 -127
- data/Rakefile +20 -14
- data/lib/ext/sawyer/relation.rb +12 -0
- data/lib/octokit/arguments.rb +3 -3
- data/lib/octokit/authentication.rb +20 -14
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +161 -0
- data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
- data/lib/octokit/client/actions_workflow_runs.rb +125 -0
- data/lib/octokit/client/actions_workflows.rb +68 -0
- data/lib/octokit/client/apps.rb +259 -0
- data/lib/octokit/client/checks.rb +200 -0
- data/lib/octokit/client/code_scanning.rb +190 -0
- data/lib/octokit/client/codespaces_secrets.rb +108 -0
- data/lib/octokit/client/commit_branches.rb +20 -0
- data/lib/octokit/client/commit_comments.rb +8 -8
- data/lib/octokit/client/commit_pulls.rb +20 -0
- data/lib/octokit/client/commits.rb +32 -35
- data/lib/octokit/client/community_profile.rb +21 -0
- data/lib/octokit/client/contents.rb +24 -21
- data/lib/octokit/client/dependabot_secrets.rb +108 -0
- data/lib/octokit/client/deployments.rb +29 -7
- data/lib/octokit/client/downloads.rb +5 -6
- data/lib/octokit/client/emojis.rb +3 -3
- data/lib/octokit/client/environments.rb +58 -0
- data/lib/octokit/client/events.rb +4 -4
- data/lib/octokit/client/feeds.rb +4 -5
- data/lib/octokit/client/gists.rb +36 -8
- data/lib/octokit/client/gitignore.rb +3 -3
- data/lib/octokit/client/hooks.rb +34 -30
- data/lib/octokit/client/issues.rb +97 -14
- data/lib/octokit/client/labels.rb +17 -17
- data/lib/octokit/client/legacy_search.rb +3 -3
- data/lib/octokit/client/licenses.rb +5 -8
- data/lib/octokit/client/markdown.rb +3 -3
- data/lib/octokit/client/marketplace.rb +56 -0
- data/lib/octokit/client/meta.rb +4 -5
- data/lib/octokit/client/milestones.rb +14 -14
- data/lib/octokit/client/notifications.rb +7 -11
- data/lib/octokit/client/oauth_applications.rb +116 -0
- data/lib/octokit/client/objects.rb +14 -14
- data/lib/octokit/client/organizations.rb +256 -73
- data/lib/octokit/client/pages.rb +26 -3
- data/lib/octokit/client/projects.rb +294 -0
- data/lib/octokit/client/pull_requests.rb +74 -51
- data/lib/octokit/client/rate_limit.rb +11 -13
- data/lib/octokit/client/reactions.rb +204 -0
- data/lib/octokit/client/refs.rb +34 -20
- data/lib/octokit/client/releases.rb +16 -13
- data/lib/octokit/client/repositories.rb +276 -60
- data/lib/octokit/client/repository_invitations.rb +96 -0
- data/lib/octokit/client/reviews.rb +227 -0
- data/lib/octokit/client/say.rb +4 -5
- data/lib/octokit/client/search.rb +46 -17
- data/lib/octokit/client/service_status.rb +19 -9
- data/lib/octokit/client/source_import.rb +156 -0
- data/lib/octokit/client/stats.rb +39 -17
- data/lib/octokit/client/statuses.rb +6 -6
- data/lib/octokit/client/tokens.rb +31 -0
- data/lib/octokit/client/traffic.rb +64 -0
- data/lib/octokit/client/users.rb +133 -25
- data/lib/octokit/client.rb +85 -19
- data/lib/octokit/configurable.rb +60 -32
- data/lib/octokit/connection.rb +45 -21
- data/lib/octokit/default.rb +82 -35
- data/lib/octokit/enterprise_admin_client/admin_stats.rb +14 -15
- data/lib/octokit/enterprise_admin_client/license.rb +4 -5
- data/lib/octokit/enterprise_admin_client/orgs.rb +7 -6
- data/lib/octokit/enterprise_admin_client/search_indexing.rb +8 -9
- data/lib/octokit/enterprise_admin_client/users.rb +19 -18
- data/lib/octokit/enterprise_admin_client.rb +11 -3
- data/lib/octokit/enterprise_management_console_client/management_console.rb +52 -34
- data/lib/octokit/enterprise_management_console_client.rb +9 -3
- data/lib/octokit/error.rb +144 -26
- data/lib/octokit/gist.rb +4 -5
- data/lib/octokit/manage_ghes_client/manage_ghes.rb +178 -0
- data/lib/octokit/manage_ghes_client.rb +64 -0
- data/lib/octokit/middleware/follow_redirects.rb +18 -14
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +11 -9
- data/lib/octokit/repo_arguments.rb +3 -4
- data/lib/octokit/repository.rb +35 -23
- data/lib/octokit/response/base_middleware.rb +10 -0
- data/lib/octokit/response/feed_parser.rb +5 -9
- data/lib/octokit/response/raise_error.rb +4 -6
- data/lib/octokit/user.rb +4 -2
- data/lib/octokit/version.rb +3 -1
- data/lib/octokit/warnable.rb +4 -5
- data/lib/octokit.rb +30 -8
- data/octokit.gemspec +12 -10
- metadata +47 -24
- data/lib/octokit/client/authorizations.rb +0 -256
- data/lib/octokit/client/pub_sub_hubbub.rb +0 -111
- data/lib/octokit/preview.rb +0 -28
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Organizations API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/orgs/
|
7
8
|
module Organizations
|
8
|
-
|
9
9
|
# Get an organization
|
10
10
|
#
|
11
11
|
# @param org [String, Integer] Organization GitHub login or id.
|
@@ -18,7 +18,7 @@ module Octokit
|
|
18
18
|
def organization(org, options = {})
|
19
19
|
get Organization.path(org), options
|
20
20
|
end
|
21
|
-
alias
|
21
|
+
alias org organization
|
22
22
|
|
23
23
|
# Update an organization.
|
24
24
|
#
|
@@ -31,6 +31,8 @@ module Octokit
|
|
31
31
|
# @option values [String] :email Publicly visible email address.
|
32
32
|
# @option values [String] :location Location of organization.
|
33
33
|
# @option values [String] :name GitHub username for organization.
|
34
|
+
# @option values [String] :default_repository_permission The default permission members have on organization repositories.
|
35
|
+
# @option values [Boolean] :members_can_create_repositories Set true to allow members to create repositories on the organization.
|
34
36
|
# @return [Sawyer::Resource] Hash representing GitHub organization.
|
35
37
|
# @see https://developer.github.com/v3/orgs/#edit-an-organization
|
36
38
|
# @example
|
@@ -46,14 +48,30 @@ module Octokit
|
|
46
48
|
def update_organization(org, values, options = {})
|
47
49
|
patch Organization.path(org), options.merge(values)
|
48
50
|
end
|
49
|
-
alias
|
51
|
+
alias update_org update_organization
|
52
|
+
|
53
|
+
# Delete an organization.
|
54
|
+
#
|
55
|
+
# Requires authenticated organization owner.
|
56
|
+
#
|
57
|
+
# @param org [String, Integer] Organization login or ID.
|
58
|
+
# @return [Boolean] True if deletion successful, otherwise false.
|
59
|
+
# @see https://docs.github.com/rest/orgs/orgs#delete-an-organization
|
60
|
+
# @example
|
61
|
+
# @client.delete_organization("my-org")
|
62
|
+
# @example
|
63
|
+
# @client.delete_org("my-org")
|
64
|
+
def delete_organization(org)
|
65
|
+
boolean_from_response :delete, Organization.path(org)
|
66
|
+
end
|
67
|
+
alias delete_org delete_organization
|
50
68
|
|
51
69
|
# Get organizations for a user.
|
52
70
|
#
|
53
71
|
# Nonauthenticated calls to this method will return organizations that
|
54
72
|
# the user is a public member.
|
55
73
|
#
|
56
|
-
# Use an
|
74
|
+
# Use an authenticated client to get both public and private organizations
|
57
75
|
# for a user.
|
58
76
|
#
|
59
77
|
# Calling this method on a `@client` will return that users organizations.
|
@@ -62,6 +80,7 @@ module Octokit
|
|
62
80
|
# @param user [Integer, String] GitHub user login or id of the user to get
|
63
81
|
# list of organizations.
|
64
82
|
# @return [Array<Sawyer::Resource>] Array of hashes representing organizations.
|
83
|
+
# @see https://developer.github.com/v3/orgs/#list-your-organizations
|
65
84
|
# @see https://developer.github.com/v3/orgs/#list-user-organizations
|
66
85
|
# @example
|
67
86
|
# Octokit.organizations('pengwynn')
|
@@ -75,12 +94,12 @@ module Octokit
|
|
75
94
|
# Octokit.list_orgs('pengwynn')
|
76
95
|
# @example
|
77
96
|
# @client.organizations
|
78
|
-
def organizations(user=nil, options = {})
|
97
|
+
def organizations(user = nil, options = {})
|
79
98
|
paginate "#{User.path user}/orgs", options
|
80
99
|
end
|
81
|
-
alias
|
82
|
-
alias
|
83
|
-
alias
|
100
|
+
alias list_organizations organizations
|
101
|
+
alias list_orgs organizations
|
102
|
+
alias orgs organizations
|
84
103
|
|
85
104
|
# List all GitHub organizations
|
86
105
|
#
|
@@ -95,9 +114,9 @@ module Octokit
|
|
95
114
|
#
|
96
115
|
# @return [Array<Sawyer::Resource>] List of GitHub organizations.
|
97
116
|
def all_organizations(options = {})
|
98
|
-
paginate
|
117
|
+
paginate 'organizations', options
|
99
118
|
end
|
100
|
-
alias
|
119
|
+
alias all_orgs all_organizations
|
101
120
|
|
102
121
|
# List organization repositories
|
103
122
|
#
|
@@ -122,8 +141,8 @@ module Octokit
|
|
122
141
|
def organization_repositories(org, options = {})
|
123
142
|
paginate "#{Organization.path org}/repos", options
|
124
143
|
end
|
125
|
-
alias
|
126
|
-
alias
|
144
|
+
alias org_repositories organization_repositories
|
145
|
+
alias org_repos organization_repositories
|
127
146
|
|
128
147
|
# Get organization members
|
129
148
|
#
|
@@ -139,10 +158,11 @@ module Octokit
|
|
139
158
|
# @example
|
140
159
|
# Octokit.org_members('github')
|
141
160
|
def organization_members(org, options = {})
|
142
|
-
|
161
|
+
options = options.dup
|
162
|
+
path = 'public_' if options.delete(:public)
|
143
163
|
paginate "#{Organization.path org}/#{path}members", options
|
144
164
|
end
|
145
|
-
alias
|
165
|
+
alias org_members organization_members
|
146
166
|
|
147
167
|
# Get organization public members
|
148
168
|
#
|
@@ -156,9 +176,9 @@ module Octokit
|
|
156
176
|
# @example
|
157
177
|
# Octokit.org_public_members('github')
|
158
178
|
def organization_public_members(org, options = {})
|
159
|
-
organization_members org, options.merge(:
|
179
|
+
organization_members org, options.merge(public: true)
|
160
180
|
end
|
161
|
-
alias
|
181
|
+
alias org_public_members organization_public_members
|
162
182
|
|
163
183
|
# Check if a user is a member of an organization.
|
164
184
|
#
|
@@ -184,7 +204,7 @@ module Octokit
|
|
184
204
|
result
|
185
205
|
end
|
186
206
|
end
|
187
|
-
alias
|
207
|
+
alias org_member? organization_member?
|
188
208
|
|
189
209
|
# Check if a user is a public member of an organization.
|
190
210
|
#
|
@@ -204,7 +224,66 @@ module Octokit
|
|
204
224
|
def organization_public_member?(org, user, options = {})
|
205
225
|
boolean_from_response :get, "#{Organization.path org}/public_members/#{user}", options
|
206
226
|
end
|
207
|
-
alias
|
227
|
+
alias org_public_member? organization_public_member?
|
228
|
+
|
229
|
+
# List pending organization invitations
|
230
|
+
#
|
231
|
+
# Requires authenticated organization member.
|
232
|
+
#
|
233
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
234
|
+
# @return [Array<Sawyer::Resource>] Array of hashes representing invitations.
|
235
|
+
# @see https://developer.github.com/v3/orgs/members/#list-pending-organization-invitations
|
236
|
+
#
|
237
|
+
# @example
|
238
|
+
# @client.organization_invitations('github')
|
239
|
+
def organization_invitations(org, options = {})
|
240
|
+
get "#{Organization.path org}/invitations", options
|
241
|
+
end
|
242
|
+
alias org_invitations organization_invitations
|
243
|
+
|
244
|
+
# List outside collaborators for an organization
|
245
|
+
#
|
246
|
+
# Requires authenticated organization members.
|
247
|
+
#
|
248
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
249
|
+
# @return [Array<Sawyer::Resource>] Array of hashes representing users.
|
250
|
+
# @see https://developer.github.com/v3/orgs/outside_collaborators/#list-outside-collaborators
|
251
|
+
#
|
252
|
+
# @example
|
253
|
+
# @client.outside_collaborators('github')
|
254
|
+
def outside_collaborators(org, options = {})
|
255
|
+
paginate "#{Organization.path org}/outside_collaborators", options
|
256
|
+
end
|
257
|
+
|
258
|
+
# Remove outside collaborator from an organization
|
259
|
+
#
|
260
|
+
# Requires authenticated organization members.
|
261
|
+
#
|
262
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
263
|
+
# @param user [String] GitHub username to be removed as outside collaborator
|
264
|
+
# @return [Boolean] Return true if outside collaborator removed from organization, false otherwise.
|
265
|
+
# @see https://developer.github.com/v3/orgs/outside-collaborators/#remove-outside-collaborator
|
266
|
+
#
|
267
|
+
# @example
|
268
|
+
# @client.remove_outside_collaborator('github', 'lizzhale')
|
269
|
+
def remove_outside_collaborator(org, user, options = {})
|
270
|
+
boolean_from_response :delete, "#{Organization.path org}/outside_collaborators/#{user}", options
|
271
|
+
end
|
272
|
+
|
273
|
+
# Converts an organization member to an outside collaborator
|
274
|
+
#
|
275
|
+
# Requires authenticated organization members.
|
276
|
+
#
|
277
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
278
|
+
# @param user [String] GitHub username to be removed as outside collaborator
|
279
|
+
# @return [Boolean] Return true if outside collaborator removed from organization, false otherwise.
|
280
|
+
# @see https://developer.github.com/v3/orgs/outside-collaborators/#convert-member-to-outside-collaborator
|
281
|
+
#
|
282
|
+
# @example
|
283
|
+
# @client.convert_to_outside_collaborator('github', 'lizzhale')
|
284
|
+
def convert_to_outside_collaborator(org, user, options = {})
|
285
|
+
boolean_from_response :put, "#{Organization.path org}/outside_collaborators/#{user}", options
|
286
|
+
end
|
208
287
|
|
209
288
|
# List teams
|
210
289
|
#
|
@@ -220,7 +299,7 @@ module Octokit
|
|
220
299
|
def organization_teams(org, options = {})
|
221
300
|
paginate "#{Organization.path org}/teams", options
|
222
301
|
end
|
223
|
-
alias
|
302
|
+
alias org_teams organization_teams
|
224
303
|
|
225
304
|
# Create team
|
226
305
|
#
|
@@ -229,21 +308,19 @@ module Octokit
|
|
229
308
|
# @param org [String, Integer] Organization GitHub login or id.
|
230
309
|
# @option options [String] :name Team name.
|
231
310
|
# @option options [Array<String>] :repo_names Repositories for the team.
|
232
|
-
# @option options [String
|
233
|
-
#
|
234
|
-
#
|
235
|
-
# `pull` - team members can pull, but not push to or administer these repositories.
|
236
|
-
# `push` - team members can pull and push, but not administer these repositories.
|
237
|
-
# `admin` - team members can pull, push and administer these repositories.
|
311
|
+
# @option options [Array<String>] :maintainers Maintainers for the team.
|
312
|
+
# @option options [Integer] :parent_team_id ID of a team to set as the parent team.
|
238
313
|
# @return [Sawyer::Resource] Hash representing new team.
|
239
314
|
# @see https://developer.github.com/v3/orgs/teams/#create-team
|
240
315
|
# @example
|
241
316
|
# @client.create_team('github', {
|
242
317
|
# :name => 'Designers',
|
243
|
-
# :repo_names => ['github/dotfiles']
|
244
|
-
# :permission => 'push'
|
318
|
+
# :repo_names => ['github/dotfiles']
|
245
319
|
# })
|
246
320
|
def create_team(org, options = {})
|
321
|
+
if options.key?(:permission)
|
322
|
+
octokit_warn 'Deprecated: Passing :permission option to #create_team. Assign team repository permission by passing :permission to #add_team_repository instead.'
|
323
|
+
end
|
247
324
|
post "#{Organization.path org}/teams", options
|
248
325
|
end
|
249
326
|
|
@@ -260,6 +337,54 @@ module Octokit
|
|
260
337
|
get "teams/#{team_id}", options
|
261
338
|
end
|
262
339
|
|
340
|
+
# Get team by name and org
|
341
|
+
#
|
342
|
+
# Requires authenticated organization member.
|
343
|
+
#
|
344
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
345
|
+
# @param team_slug [String] Team slug.
|
346
|
+
# @return [Sawyer::Resource] Hash representing team.
|
347
|
+
# @see https://developer.github.com/v3/teams/#get-team-by-name
|
348
|
+
# @example
|
349
|
+
# @client.team_by_name("github", "justice-league")
|
350
|
+
def team_by_name(org, team_slug, options = {})
|
351
|
+
get "#{Organization.path(org)}/teams/#{team_slug}", options
|
352
|
+
end
|
353
|
+
|
354
|
+
# Check team permissions for a repository
|
355
|
+
#
|
356
|
+
# Requires authenticated organization member.
|
357
|
+
#
|
358
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
359
|
+
# @param team_slug_or_id [String, Integer] Team slug or Team ID.
|
360
|
+
# @param owner [String] Owner name for the repository.
|
361
|
+
# @param repo [String] Name of the repo to check permissions against.
|
362
|
+
# @return [String, Sawyer::Resource] Depending on options it may be an empty string or a resource.
|
363
|
+
# @example
|
364
|
+
# # Check whether the team has any permissions with the repository
|
365
|
+
# @client.team_permissions_for_repo("github", "justice-league", "octocat", "hello-world")
|
366
|
+
#
|
367
|
+
# @example
|
368
|
+
# # Get the full repository object including the permissions level and role for the team
|
369
|
+
# @client.team_permissions_for_repo("github", "justice-league", "octocat", "hello-world", :accept => 'application/vnd.github.v3.repository+json')
|
370
|
+
# @see https://docs.github.com/en/rest/teams/teams#check-team-permissions-for-a-repository
|
371
|
+
def team_permissions_for_repo(org, team_slug_or_id, owner, repo, options = {})
|
372
|
+
get "#{Organization.path(org)}/teams/#{team_slug_or_id}/repos/#{owner}/#{repo}", options
|
373
|
+
end
|
374
|
+
|
375
|
+
# List child teams
|
376
|
+
#
|
377
|
+
# Requires authenticated organization member.
|
378
|
+
#
|
379
|
+
# @param team_id [Integer] Team id.
|
380
|
+
# @return [Sawyer::Resource] Hash representing team.
|
381
|
+
# @see https://developer.github.com/v3/orgs/teams/#list-child-teams
|
382
|
+
# @example
|
383
|
+
# @client.child_teams(100000, :accept => "application/vnd.github.hellcat-preview+json")
|
384
|
+
def child_teams(team_id, options = {})
|
385
|
+
paginate "teams/#{team_id}/teams", options
|
386
|
+
end
|
387
|
+
|
263
388
|
# Update team
|
264
389
|
#
|
265
390
|
# Requires authenticated organization owner.
|
@@ -271,6 +396,7 @@ module Octokit
|
|
271
396
|
# `pull` - team members can pull, but not push to or administer these repositories.
|
272
397
|
# `push` - team members can pull and push, but not administer these repositories.
|
273
398
|
# `admin` - team members can pull, push and administer these repositories.
|
399
|
+
# @option options [Integer] :parent_team_id ID of a team to set as the parent team.
|
274
400
|
# @return [Sawyer::Resource] Hash representing updated team.
|
275
401
|
# @see https://developer.github.com/v3/orgs/teams/#edit-team
|
276
402
|
# @example
|
@@ -333,7 +459,7 @@ module Octokit
|
|
333
459
|
# There's a bug in this API call. The docs say to leave the body blank,
|
334
460
|
# but it fails if the body is both blank and the content-length header
|
335
461
|
# is not 0.
|
336
|
-
boolean_from_response :put, "teams/#{team_id}/members/#{user}", options.merge({:
|
462
|
+
boolean_from_response :put, "teams/#{team_id}/members/#{user}", options.merge({ name: user })
|
337
463
|
end
|
338
464
|
|
339
465
|
# Remove team member
|
@@ -364,12 +490,26 @@ module Octokit
|
|
364
490
|
# @see https://developer.github.com/v3/orgs/teams/#get-team-member
|
365
491
|
#
|
366
492
|
# @example Check if a user is in your team
|
367
|
-
# @client.team_member?(
|
493
|
+
# @client.team_member?(100000, 'pengwynn')
|
368
494
|
# => false
|
369
495
|
def team_member?(team_id, user, options = {})
|
370
496
|
boolean_from_response :get, "teams/#{team_id}/members/#{user}", options
|
371
497
|
end
|
372
498
|
|
499
|
+
# List pending team invitations
|
500
|
+
#
|
501
|
+
# Requires authenticated organization member.
|
502
|
+
#
|
503
|
+
# @param team_id [Integer] Team id.
|
504
|
+
# @return [Array<Sawyer::Resource>] Array of hashes representing invitations.
|
505
|
+
# @see https://developer.github.com/v3/orgs/teams/#list-pending-team-invitations
|
506
|
+
#
|
507
|
+
# @example
|
508
|
+
# @client.team_invitations('github')
|
509
|
+
def team_invitations(team_id, options = {})
|
510
|
+
get "teams/#{team_id}/invitations", options
|
511
|
+
end
|
512
|
+
|
373
513
|
# List team repositories
|
374
514
|
#
|
375
515
|
# Requires authenticated organization member.
|
@@ -384,7 +524,7 @@ module Octokit
|
|
384
524
|
def team_repositories(team_id, options = {})
|
385
525
|
paginate "teams/#{team_id}/repos", options
|
386
526
|
end
|
387
|
-
alias
|
527
|
+
alias team_repos team_repositories
|
388
528
|
|
389
529
|
# Check if a repo is managed by a specific team
|
390
530
|
#
|
@@ -393,35 +533,44 @@ module Octokit
|
|
393
533
|
# @return [Boolean] True if managed by a team. False if not managed by
|
394
534
|
# the team OR the requesting user does not have authorization to access
|
395
535
|
# the team information.
|
396
|
-
# @see https://developer.github.com/v3/orgs/teams/#
|
536
|
+
# @see https://developer.github.com/v3/orgs/teams/#check-if-a-team-manages-a-repository
|
397
537
|
# @example
|
398
538
|
# @client.team_repository?(8675309, 'octokit/octokit.rb')
|
399
539
|
# @example
|
400
540
|
# @client.team_repo?(8675309, 'octokit/octokit.rb')
|
401
|
-
def team_repository?(team_id, repo,
|
541
|
+
def team_repository?(team_id, repo, _options = {})
|
402
542
|
boolean_from_response :get, "teams/#{team_id}/repos/#{Repository.new(repo)}"
|
403
543
|
end
|
404
|
-
alias
|
544
|
+
alias team_repo? team_repository?
|
405
545
|
|
406
546
|
# Add team repository
|
407
547
|
#
|
548
|
+
# This can also be used to update the permission of an existing team
|
549
|
+
#
|
408
550
|
# Requires authenticated user to be an owner of the organization that the
|
409
551
|
# team is associated with. Also, the repo must be owned by the
|
410
552
|
# organization, or a direct form of a repo owned by the organization.
|
411
553
|
#
|
412
554
|
# @param team_id [Integer] Team id.
|
413
555
|
# @param repo [String, Hash, Repository] A GitHub repository.
|
556
|
+
# @option options [String] :permission The permission to grant the team.
|
557
|
+
# Only valid on organization-owned repositories.
|
558
|
+
# Can be one of: <tt>pull</tt>, <tt>push</tt>, or <tt>admin</tt>.
|
559
|
+
# If not specified, the team's <tt>permission</tt> attribute will be
|
560
|
+
# used to determine what permission to grant the team on this repository.
|
414
561
|
# @return [Boolean] True if successful, false otherwise.
|
415
562
|
# @see Octokit::Repository
|
416
|
-
# @see https://developer.github.com/v3/orgs/teams/#add-team-
|
563
|
+
# @see https://developer.github.com/v3/orgs/teams/#add-or-update-team-repository
|
417
564
|
# @example
|
418
565
|
# @client.add_team_repository(100000, 'github/developer.github.com')
|
419
566
|
# @example
|
420
567
|
# @client.add_team_repo(100000, 'github/developer.github.com')
|
568
|
+
# @example Add a team with admin permissions
|
569
|
+
# @client.add_team_repository(100000, 'github/developer.github.com', permission: 'admin')
|
421
570
|
def add_team_repository(team_id, repo, options = {})
|
422
|
-
boolean_from_response :put, "teams/#{team_id}/repos/#{Repository.new(repo)}", options
|
571
|
+
boolean_from_response :put, "teams/#{team_id}/repos/#{Repository.new(repo)}", options
|
423
572
|
end
|
424
|
-
alias
|
573
|
+
alias add_team_repo add_team_repository
|
425
574
|
|
426
575
|
# Remove team repository
|
427
576
|
#
|
@@ -433,15 +582,15 @@ module Octokit
|
|
433
582
|
# @param repo [String, Hash, Repository] A GitHub repository.
|
434
583
|
# @return [Boolean] Return true if repo removed from team, false otherwise.
|
435
584
|
# @see Octokit::Repository
|
436
|
-
# @see https://developer.github.com/v3/orgs/teams/#remove-team-
|
585
|
+
# @see https://developer.github.com/v3/orgs/teams/#remove-team-repository
|
437
586
|
# @example
|
438
587
|
# @client.remove_team_repository(100000, 'github/developer.github.com')
|
439
588
|
# @example
|
440
589
|
# @client.remove_team_repo(100000, 'github/developer.github.com')
|
441
|
-
def remove_team_repository(team_id, repo,
|
590
|
+
def remove_team_repository(team_id, repo, _options = {})
|
442
591
|
boolean_from_response :delete, "teams/#{team_id}/repos/#{Repository.new(repo)}"
|
443
592
|
end
|
444
|
-
alias
|
593
|
+
alias remove_team_repo remove_team_repository
|
445
594
|
|
446
595
|
# Remove organization member
|
447
596
|
#
|
@@ -460,7 +609,7 @@ module Octokit
|
|
460
609
|
# provided in the GH API v3
|
461
610
|
boolean_from_response :delete, "#{Organization.path org}/members/#{user}", options
|
462
611
|
end
|
463
|
-
alias
|
612
|
+
alias remove_org_member remove_organization_member
|
464
613
|
|
465
614
|
# Publicize a user's membership of an organization
|
466
615
|
#
|
@@ -491,14 +640,14 @@ module Octokit
|
|
491
640
|
def unpublicize_membership(org, user, options = {})
|
492
641
|
boolean_from_response :delete, "#{Organization.path org}/public_members/#{user}", options
|
493
642
|
end
|
494
|
-
alias
|
643
|
+
alias conceal_membership unpublicize_membership
|
495
644
|
|
496
645
|
# List all teams for the authenticated user across all their orgs
|
497
646
|
#
|
498
647
|
# @return [Array<Sawyer::Resource>] Array of team resources.
|
499
648
|
# @see https://developer.github.com/v3/orgs/teams/#list-user-teams
|
500
649
|
def user_teams(options = {})
|
501
|
-
paginate
|
650
|
+
paginate 'user/teams', options
|
502
651
|
end
|
503
652
|
|
504
653
|
# Check if a user has a team membership.
|
@@ -523,7 +672,7 @@ module Octokit
|
|
523
672
|
#
|
524
673
|
# @return [Sawyer::Resource] Hash of team membership info
|
525
674
|
#
|
526
|
-
# @see https://developer.github.com/v3/orgs/teams/#add-team-membership
|
675
|
+
# @see https://developer.github.com/v3/orgs/teams/#add-or-update-team-membership
|
527
676
|
#
|
528
677
|
# @example Check if a user has a membership for a team
|
529
678
|
# @client.add_team_membership(1234, 'pengwynn')
|
@@ -548,29 +697,30 @@ module Octokit
|
|
548
697
|
# @return [Array<Sawyer::Resource>] Array of organizations memberships.
|
549
698
|
# @see https://developer.github.com/v3/orgs/members/#list-your-organization-memberships
|
550
699
|
def organization_memberships(options = {})
|
551
|
-
paginate
|
700
|
+
paginate 'user/memberships/orgs', options
|
552
701
|
end
|
553
|
-
alias
|
702
|
+
alias org_memberships organization_memberships
|
554
703
|
|
555
704
|
# Get an organization membership
|
556
705
|
#
|
557
|
-
# @param org [String]
|
706
|
+
# @param org [Integer, String] The GitHub Organization.
|
558
707
|
# @option options [String] :user The login of the user, otherwise authenticated user.
|
559
708
|
# @return [Sawyer::Resource] Hash representing the organization membership.
|
560
709
|
# @see https://developer.github.com/v3/orgs/members/#get-your-organization-membership
|
561
710
|
# @see https://developer.github.com/v3/orgs/members/#get-organization-membership
|
562
711
|
def organization_membership(org, options = {})
|
712
|
+
options = options.dup
|
563
713
|
if user = options.delete(:user)
|
564
|
-
get "
|
714
|
+
get "#{Organization.path(org)}/memberships/#{user}", options
|
565
715
|
else
|
566
716
|
get "user/memberships/orgs/#{org}", options
|
567
717
|
end
|
568
718
|
end
|
569
|
-
alias
|
719
|
+
alias org_membership organization_membership
|
570
720
|
|
571
721
|
# Edit an organization membership
|
572
722
|
#
|
573
|
-
# @param org [String] Organization GitHub login.
|
723
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
574
724
|
# @option options [String] :role The role of the user in the organization.
|
575
725
|
# @option options [String] :state The state that the membership should be in.
|
576
726
|
# @option options [String] :user The login of the user, otherwise authenticated user.
|
@@ -578,23 +728,28 @@ module Octokit
|
|
578
728
|
# @see https://developer.github.com/v3/orgs/members/#edit-your-organization-membership
|
579
729
|
# @see https://developer.github.com/v3/orgs/members/#add-or-update-organization-membership
|
580
730
|
def update_organization_membership(org, options = {})
|
731
|
+
options = options.dup
|
581
732
|
if user = options.delete(:user)
|
582
|
-
|
733
|
+
options.delete(:state)
|
734
|
+
put "#{Organization.path(org)}/memberships/#{user}", options
|
583
735
|
else
|
736
|
+
options.delete(:role)
|
584
737
|
patch "user/memberships/orgs/#{org}", options
|
585
738
|
end
|
586
739
|
end
|
587
|
-
alias
|
740
|
+
alias update_org_membership update_organization_membership
|
588
741
|
|
589
742
|
# Remove an organization membership
|
590
743
|
#
|
591
|
-
# @param org [String] Organization GitHub login.
|
744
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
592
745
|
# @return [Boolean] Success
|
593
746
|
# @see https://developer.github.com/v3/orgs/members/#remove-organization-membership
|
594
747
|
def remove_organization_membership(org, options = {})
|
748
|
+
options = options.dup
|
595
749
|
user = options.delete(:user)
|
596
|
-
user && boolean_from_response(:delete, "
|
750
|
+
user && boolean_from_response(:delete, "#{Organization.path(org)}/memberships/#{user}", options)
|
597
751
|
end
|
752
|
+
alias remove_org_membership remove_organization_membership
|
598
753
|
|
599
754
|
# Initiates the generation of a migration archive.
|
600
755
|
#
|
@@ -604,13 +759,12 @@ module Octokit
|
|
604
759
|
# @param repositories [Array<String>] :repositories Repositories for the organization.
|
605
760
|
# @option options [Boolean, optional] :lock_repositories Indicates whether repositories should be locked during migration
|
606
761
|
# @return [Sawyer::Resource] Hash representing the new migration.
|
607
|
-
# @see https://developer.github.com/v3/orgs/teams/#create-team
|
608
762
|
# @example
|
609
763
|
# @client.start_migration('github', ['github/dotfiles'])
|
610
|
-
# @see https://
|
764
|
+
# @see https://docs.github.com/en/rest/reference/migrations#start-an-organization-migration
|
611
765
|
def start_migration(org, repositories, options = {})
|
612
|
-
options =
|
613
|
-
post "
|
766
|
+
options[:repositories] = repositories
|
767
|
+
post "#{Organization.path(org)}/migrations", options
|
614
768
|
end
|
615
769
|
|
616
770
|
# Lists the most recent migrations.
|
@@ -619,10 +773,9 @@ module Octokit
|
|
619
773
|
#
|
620
774
|
# @param org [String, Integer] Organization GitHub login or id.
|
621
775
|
# @return [Array<Sawyer::Resource>] Array of migration resources.
|
622
|
-
# @see https://
|
776
|
+
# @see https://docs.github.com/en/rest/reference/migrations#list-organization-migrations
|
623
777
|
def migrations(org, options = {})
|
624
|
-
|
625
|
-
paginate "orgs/#{org}/migrations", options
|
778
|
+
paginate "#{Organization.path(org)}/migrations", options
|
626
779
|
end
|
627
780
|
|
628
781
|
# Fetches the status of a migration.
|
@@ -631,10 +784,9 @@ module Octokit
|
|
631
784
|
#
|
632
785
|
# @param org [String, Integer] Organization GitHub login or id.
|
633
786
|
# @param id [Integer] ID number of the migration.
|
634
|
-
# @see https://
|
787
|
+
# @see https://docs.github.com/en/rest/reference/migrations#get-an-organization-migration-status
|
635
788
|
def migration_status(org, id, options = {})
|
636
|
-
|
637
|
-
get "orgs/#{org}/migrations/#{id}", options
|
789
|
+
get "#{Organization.path(org)}/migrations/#{id}", options
|
638
790
|
end
|
639
791
|
|
640
792
|
# Fetches the URL to a migration archive.
|
@@ -643,10 +795,9 @@ module Octokit
|
|
643
795
|
#
|
644
796
|
# @param org [String, Integer] Organization GitHub login or id.
|
645
797
|
# @param id [Integer] ID number of the migration.
|
646
|
-
# @see https://
|
798
|
+
# @see https://docs.github.com/en/rest/reference/migrations#download-an-organization-migration-archive
|
647
799
|
def migration_archive_url(org, id, options = {})
|
648
|
-
|
649
|
-
url = "orgs/#{org}/migrations/#{id}/archive"
|
800
|
+
url = "#{Organization.path(org)}/migrations/#{id}/archive"
|
650
801
|
|
651
802
|
response = client_without_redirects(options).get(url)
|
652
803
|
response.headers['location']
|
@@ -658,10 +809,9 @@ module Octokit
|
|
658
809
|
#
|
659
810
|
# @param org [String, Integer] Organization GitHub login or id.
|
660
811
|
# @param id [Integer] ID number of the migration.
|
661
|
-
# @see https://
|
812
|
+
# @see https://docs.github.com/en/rest/reference/migrations#delete-an-organization-migration-archive
|
662
813
|
def delete_migration_archive(org, id, options = {})
|
663
|
-
|
664
|
-
delete "orgs/#{org}/migrations/#{id}/archive", options
|
814
|
+
delete "#{Organization.path(org)}/migrations/#{id}/archive", options
|
665
815
|
end
|
666
816
|
|
667
817
|
# Unlock a previous migration archive.
|
@@ -671,10 +821,43 @@ module Octokit
|
|
671
821
|
# @param org [String, Integer] Organization GitHub login or id.
|
672
822
|
# @param id [Integer] ID number of the migration.
|
673
823
|
# @param repo [String] Name of the repository.
|
674
|
-
# @see https://
|
824
|
+
# @see https://docs.github.com/en/rest/reference/migrations#unlock-an-organization-repository
|
675
825
|
def unlock_repository(org, id, repo, options = {})
|
676
|
-
|
677
|
-
|
826
|
+
delete "#{Organization.path(org)}/migrations/#{id}/repos/#{repo}/lock", options
|
827
|
+
end
|
828
|
+
|
829
|
+
# Get GitHub Actions billing for an organization
|
830
|
+
#
|
831
|
+
# Requires authenticated organization owner.
|
832
|
+
#
|
833
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
834
|
+
# @return [Sawyer::Resource] Hash representing GitHub Actions billing for an organization.
|
835
|
+
# @see https://docs.github.com/en/rest/reference/billing#get-github-actions-billing-for-an-organization
|
836
|
+
#
|
837
|
+
# @example
|
838
|
+
# @client.billing_actions('github')
|
839
|
+
def billing_actions(org)
|
840
|
+
get "#{Organization.path(org)}/settings/billing/actions"
|
841
|
+
end
|
842
|
+
|
843
|
+
# Get organization audit log.
|
844
|
+
#
|
845
|
+
# Gets the audit log for an organization.
|
846
|
+
#
|
847
|
+
# @param org [String, Integer] Organization GitHub login or id for which
|
848
|
+
# to retrieve the audit log.
|
849
|
+
# @option options [String] :include ('all') Filter by event type.
|
850
|
+
# `all`, `git` or `web`.
|
851
|
+
# @option options [String] :phrase A search phrase.
|
852
|
+
# @option options [String] :order ('desc') The order of audit log events. To list newest events first, specify desc.
|
853
|
+
# To list oldest events first, specify asc.
|
854
|
+
#
|
855
|
+
# @return [Array<Sawyer::Resource>] List of events
|
856
|
+
# @see https://docs.github.com/en/enterprise-cloud@latest/rest/orgs/orgs#get-the-audit-log-for-an-organization
|
857
|
+
# @example
|
858
|
+
# Octokit.organization_audit_log('github', {include: 'all', phrase: 'action:org.add_member created:>2022-08-29 user:octocat'})
|
859
|
+
def organization_audit_log(org, options = {})
|
860
|
+
paginate "#{Organization.path org}/audit-log", options
|
678
861
|
end
|
679
862
|
end
|
680
863
|
end
|