octokit 4.6.2 → 6.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CONTRIBUTING.md +14 -13
- data/LICENSE.md +1 -1
- data/README.md +239 -118
- data/Rakefile +12 -12
- data/lib/ext/sawyer/relation.rb +4 -2
- data/lib/octokit/arguments.rb +2 -2
- data/lib/octokit/authentication.rb +20 -14
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +59 -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 +222 -0
- data/lib/octokit/client/checks.rb +200 -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 +31 -34
- data/lib/octokit/client/community_profile.rb +21 -0
- data/lib/octokit/client/contents.rb +25 -20
- data/lib/octokit/client/deployments.rb +25 -5
- data/lib/octokit/client/downloads.rb +5 -6
- data/lib/octokit/client/emojis.rb +3 -3
- data/lib/octokit/client/environments.rb +55 -0
- data/lib/octokit/client/events.rb +4 -4
- data/lib/octokit/client/feeds.rb +4 -5
- data/lib/octokit/client/gists.rb +7 -6
- data/lib/octokit/client/gitignore.rb +3 -3
- data/lib/octokit/client/hooks.rb +9 -19
- data/lib/octokit/client/issues.rb +60 -14
- data/lib/octokit/client/labels.rb +17 -17
- data/lib/octokit/client/legacy_search.rb +3 -3
- data/lib/octokit/client/licenses.rb +4 -7
- 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 +5 -5
- data/lib/octokit/client/notifications.rb +6 -10
- data/lib/octokit/client/oauth_applications.rb +116 -0
- data/lib/octokit/client/objects.rb +14 -14
- data/lib/octokit/client/organizations.rb +238 -61
- data/lib/octokit/client/pages.rb +5 -7
- data/lib/octokit/client/projects.rb +50 -70
- data/lib/octokit/client/pub_sub_hubbub.rb +16 -16
- data/lib/octokit/client/pull_requests.rb +58 -46
- data/lib/octokit/client/rate_limit.rb +11 -13
- data/lib/octokit/client/reactions.rb +6 -11
- data/lib/octokit/client/refs.rb +32 -19
- data/lib/octokit/client/releases.rb +14 -13
- data/lib/octokit/client/repositories.rb +195 -54
- data/lib/octokit/client/repository_invitations.rb +4 -11
- 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 +8 -13
- data/lib/octokit/client/stats.rb +12 -9
- data/lib/octokit/client/statuses.rb +6 -6
- data/lib/octokit/client/tokens.rb +31 -0
- data/lib/octokit/client/traffic.rb +6 -11
- data/lib/octokit/client/users.rb +106 -25
- data/lib/octokit/client.rb +66 -17
- data/lib/octokit/configurable.rb +42 -30
- data/lib/octokit/connection.rb +43 -21
- data/lib/octokit/default.rb +63 -34
- 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 +5 -6
- data/lib/octokit/enterprise_admin_client/search_indexing.rb +8 -9
- data/lib/octokit/enterprise_admin_client/users.rb +17 -16
- data/lib/octokit/enterprise_admin_client.rb +9 -3
- data/lib/octokit/enterprise_management_console_client/management_console.rb +33 -33
- data/lib/octokit/enterprise_management_console_client.rb +9 -3
- data/lib/octokit/error.rb +107 -26
- data/lib/octokit/gist.rb +4 -5
- data/lib/octokit/middleware/follow_redirects.rb +17 -13
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +11 -9
- data/lib/octokit/repo_arguments.rb +2 -3
- data/lib/octokit/repository.rb +27 -25
- 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 +5 -3
- data/lib/octokit/warnable.rb +4 -5
- data/lib/octokit.rb +15 -8
- data/octokit.gemspec +13 -10
- metadata +55 -22
- data/lib/octokit/client/authorizations.rb +0 -244
- data/lib/octokit/preview.rb +0 -35
@@ -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,7 +48,23 @@ 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
|
#
|
@@ -76,12 +94,12 @@ module Octokit
|
|
76
94
|
# Octokit.list_orgs('pengwynn')
|
77
95
|
# @example
|
78
96
|
# @client.organizations
|
79
|
-
def organizations(user=nil, options = {})
|
97
|
+
def organizations(user = nil, options = {})
|
80
98
|
paginate "#{User.path user}/orgs", options
|
81
99
|
end
|
82
|
-
alias
|
83
|
-
alias
|
84
|
-
alias
|
100
|
+
alias list_organizations organizations
|
101
|
+
alias list_orgs organizations
|
102
|
+
alias orgs organizations
|
85
103
|
|
86
104
|
# List all GitHub organizations
|
87
105
|
#
|
@@ -96,9 +114,9 @@ module Octokit
|
|
96
114
|
#
|
97
115
|
# @return [Array<Sawyer::Resource>] List of GitHub organizations.
|
98
116
|
def all_organizations(options = {})
|
99
|
-
paginate
|
117
|
+
paginate 'organizations', options
|
100
118
|
end
|
101
|
-
alias
|
119
|
+
alias all_orgs all_organizations
|
102
120
|
|
103
121
|
# List organization repositories
|
104
122
|
#
|
@@ -123,8 +141,8 @@ module Octokit
|
|
123
141
|
def organization_repositories(org, options = {})
|
124
142
|
paginate "#{Organization.path org}/repos", options
|
125
143
|
end
|
126
|
-
alias
|
127
|
-
alias
|
144
|
+
alias org_repositories organization_repositories
|
145
|
+
alias org_repos organization_repositories
|
128
146
|
|
129
147
|
# Get organization members
|
130
148
|
#
|
@@ -140,10 +158,11 @@ module Octokit
|
|
140
158
|
# @example
|
141
159
|
# Octokit.org_members('github')
|
142
160
|
def organization_members(org, options = {})
|
143
|
-
|
161
|
+
options = options.dup
|
162
|
+
path = 'public_' if options.delete(:public)
|
144
163
|
paginate "#{Organization.path org}/#{path}members", options
|
145
164
|
end
|
146
|
-
alias
|
165
|
+
alias org_members organization_members
|
147
166
|
|
148
167
|
# Get organization public members
|
149
168
|
#
|
@@ -157,9 +176,9 @@ module Octokit
|
|
157
176
|
# @example
|
158
177
|
# Octokit.org_public_members('github')
|
159
178
|
def organization_public_members(org, options = {})
|
160
|
-
organization_members org, options.merge(:
|
179
|
+
organization_members org, options.merge(public: true)
|
161
180
|
end
|
162
|
-
alias
|
181
|
+
alias org_public_members organization_public_members
|
163
182
|
|
164
183
|
# Check if a user is a member of an organization.
|
165
184
|
#
|
@@ -185,7 +204,7 @@ module Octokit
|
|
185
204
|
result
|
186
205
|
end
|
187
206
|
end
|
188
|
-
alias
|
207
|
+
alias org_member? organization_member?
|
189
208
|
|
190
209
|
# Check if a user is a public member of an organization.
|
191
210
|
#
|
@@ -205,7 +224,66 @@ module Octokit
|
|
205
224
|
def organization_public_member?(org, user, options = {})
|
206
225
|
boolean_from_response :get, "#{Organization.path org}/public_members/#{user}", options
|
207
226
|
end
|
208
|
-
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
|
209
287
|
|
210
288
|
# List teams
|
211
289
|
#
|
@@ -221,7 +299,7 @@ module Octokit
|
|
221
299
|
def organization_teams(org, options = {})
|
222
300
|
paginate "#{Organization.path org}/teams", options
|
223
301
|
end
|
224
|
-
alias
|
302
|
+
alias org_teams organization_teams
|
225
303
|
|
226
304
|
# Create team
|
227
305
|
#
|
@@ -230,6 +308,8 @@ module Octokit
|
|
230
308
|
# @param org [String, Integer] Organization GitHub login or id.
|
231
309
|
# @option options [String] :name Team name.
|
232
310
|
# @option options [Array<String>] :repo_names Repositories for the team.
|
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.
|
233
313
|
# @return [Sawyer::Resource] Hash representing new team.
|
234
314
|
# @see https://developer.github.com/v3/orgs/teams/#create-team
|
235
315
|
# @example
|
@@ -239,7 +319,7 @@ module Octokit
|
|
239
319
|
# })
|
240
320
|
def create_team(org, options = {})
|
241
321
|
if options.key?(:permission)
|
242
|
-
octokit_warn
|
322
|
+
octokit_warn 'Deprecated: Passing :permission option to #create_team. Assign team repository permission by passing :permission to #add_team_repository instead.'
|
243
323
|
end
|
244
324
|
post "#{Organization.path org}/teams", options
|
245
325
|
end
|
@@ -257,6 +337,54 @@ module Octokit
|
|
257
337
|
get "teams/#{team_id}", options
|
258
338
|
end
|
259
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
|
+
|
260
388
|
# Update team
|
261
389
|
#
|
262
390
|
# Requires authenticated organization owner.
|
@@ -268,6 +396,7 @@ module Octokit
|
|
268
396
|
# `pull` - team members can pull, but not push to or administer these repositories.
|
269
397
|
# `push` - team members can pull and push, but not administer these repositories.
|
270
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.
|
271
400
|
# @return [Sawyer::Resource] Hash representing updated team.
|
272
401
|
# @see https://developer.github.com/v3/orgs/teams/#edit-team
|
273
402
|
# @example
|
@@ -330,7 +459,7 @@ module Octokit
|
|
330
459
|
# There's a bug in this API call. The docs say to leave the body blank,
|
331
460
|
# but it fails if the body is both blank and the content-length header
|
332
461
|
# is not 0.
|
333
|
-
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 })
|
334
463
|
end
|
335
464
|
|
336
465
|
# Remove team member
|
@@ -361,12 +490,26 @@ module Octokit
|
|
361
490
|
# @see https://developer.github.com/v3/orgs/teams/#get-team-member
|
362
491
|
#
|
363
492
|
# @example Check if a user is in your team
|
364
|
-
# @client.team_member?(
|
493
|
+
# @client.team_member?(100000, 'pengwynn')
|
365
494
|
# => false
|
366
495
|
def team_member?(team_id, user, options = {})
|
367
496
|
boolean_from_response :get, "teams/#{team_id}/members/#{user}", options
|
368
497
|
end
|
369
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
|
+
|
370
513
|
# List team repositories
|
371
514
|
#
|
372
515
|
# Requires authenticated organization member.
|
@@ -381,7 +524,7 @@ module Octokit
|
|
381
524
|
def team_repositories(team_id, options = {})
|
382
525
|
paginate "teams/#{team_id}/repos", options
|
383
526
|
end
|
384
|
-
alias
|
527
|
+
alias team_repos team_repositories
|
385
528
|
|
386
529
|
# Check if a repo is managed by a specific team
|
387
530
|
#
|
@@ -395,10 +538,10 @@ module Octokit
|
|
395
538
|
# @client.team_repository?(8675309, 'octokit/octokit.rb')
|
396
539
|
# @example
|
397
540
|
# @client.team_repo?(8675309, 'octokit/octokit.rb')
|
398
|
-
def team_repository?(team_id, repo,
|
541
|
+
def team_repository?(team_id, repo, _options = {})
|
399
542
|
boolean_from_response :get, "teams/#{team_id}/repos/#{Repository.new(repo)}"
|
400
543
|
end
|
401
|
-
alias
|
544
|
+
alias team_repo? team_repository?
|
402
545
|
|
403
546
|
# Add team repository
|
404
547
|
#
|
@@ -425,9 +568,9 @@ module Octokit
|
|
425
568
|
# @example Add a team with admin permissions
|
426
569
|
# @client.add_team_repository(100000, 'github/developer.github.com', permission: 'admin')
|
427
570
|
def add_team_repository(team_id, repo, options = {})
|
428
|
-
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
|
429
572
|
end
|
430
|
-
alias
|
573
|
+
alias add_team_repo add_team_repository
|
431
574
|
|
432
575
|
# Remove team repository
|
433
576
|
#
|
@@ -444,10 +587,10 @@ module Octokit
|
|
444
587
|
# @client.remove_team_repository(100000, 'github/developer.github.com')
|
445
588
|
# @example
|
446
589
|
# @client.remove_team_repo(100000, 'github/developer.github.com')
|
447
|
-
def remove_team_repository(team_id, repo,
|
590
|
+
def remove_team_repository(team_id, repo, _options = {})
|
448
591
|
boolean_from_response :delete, "teams/#{team_id}/repos/#{Repository.new(repo)}"
|
449
592
|
end
|
450
|
-
alias
|
593
|
+
alias remove_team_repo remove_team_repository
|
451
594
|
|
452
595
|
# Remove organization member
|
453
596
|
#
|
@@ -466,7 +609,7 @@ module Octokit
|
|
466
609
|
# provided in the GH API v3
|
467
610
|
boolean_from_response :delete, "#{Organization.path org}/members/#{user}", options
|
468
611
|
end
|
469
|
-
alias
|
612
|
+
alias remove_org_member remove_organization_member
|
470
613
|
|
471
614
|
# Publicize a user's membership of an organization
|
472
615
|
#
|
@@ -497,14 +640,14 @@ module Octokit
|
|
497
640
|
def unpublicize_membership(org, user, options = {})
|
498
641
|
boolean_from_response :delete, "#{Organization.path org}/public_members/#{user}", options
|
499
642
|
end
|
500
|
-
alias
|
643
|
+
alias conceal_membership unpublicize_membership
|
501
644
|
|
502
645
|
# List all teams for the authenticated user across all their orgs
|
503
646
|
#
|
504
647
|
# @return [Array<Sawyer::Resource>] Array of team resources.
|
505
648
|
# @see https://developer.github.com/v3/orgs/teams/#list-user-teams
|
506
649
|
def user_teams(options = {})
|
507
|
-
paginate
|
650
|
+
paginate 'user/teams', options
|
508
651
|
end
|
509
652
|
|
510
653
|
# Check if a user has a team membership.
|
@@ -529,7 +672,7 @@ module Octokit
|
|
529
672
|
#
|
530
673
|
# @return [Sawyer::Resource] Hash of team membership info
|
531
674
|
#
|
532
|
-
# @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
|
533
676
|
#
|
534
677
|
# @example Check if a user has a membership for a team
|
535
678
|
# @client.add_team_membership(1234, 'pengwynn')
|
@@ -554,29 +697,30 @@ module Octokit
|
|
554
697
|
# @return [Array<Sawyer::Resource>] Array of organizations memberships.
|
555
698
|
# @see https://developer.github.com/v3/orgs/members/#list-your-organization-memberships
|
556
699
|
def organization_memberships(options = {})
|
557
|
-
paginate
|
700
|
+
paginate 'user/memberships/orgs', options
|
558
701
|
end
|
559
|
-
alias
|
702
|
+
alias org_memberships organization_memberships
|
560
703
|
|
561
704
|
# Get an organization membership
|
562
705
|
#
|
563
|
-
# @param org [String]
|
706
|
+
# @param org [Integer, String] The GitHub Organization.
|
564
707
|
# @option options [String] :user The login of the user, otherwise authenticated user.
|
565
708
|
# @return [Sawyer::Resource] Hash representing the organization membership.
|
566
709
|
# @see https://developer.github.com/v3/orgs/members/#get-your-organization-membership
|
567
710
|
# @see https://developer.github.com/v3/orgs/members/#get-organization-membership
|
568
711
|
def organization_membership(org, options = {})
|
712
|
+
options = options.dup
|
569
713
|
if user = options.delete(:user)
|
570
|
-
get "
|
714
|
+
get "#{Organization.path(org)}/memberships/#{user}", options
|
571
715
|
else
|
572
716
|
get "user/memberships/orgs/#{org}", options
|
573
717
|
end
|
574
718
|
end
|
575
|
-
alias
|
719
|
+
alias org_membership organization_membership
|
576
720
|
|
577
721
|
# Edit an organization membership
|
578
722
|
#
|
579
|
-
# @param org [String] Organization GitHub login.
|
723
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
580
724
|
# @option options [String] :role The role of the user in the organization.
|
581
725
|
# @option options [String] :state The state that the membership should be in.
|
582
726
|
# @option options [String] :user The login of the user, otherwise authenticated user.
|
@@ -584,23 +728,28 @@ module Octokit
|
|
584
728
|
# @see https://developer.github.com/v3/orgs/members/#edit-your-organization-membership
|
585
729
|
# @see https://developer.github.com/v3/orgs/members/#add-or-update-organization-membership
|
586
730
|
def update_organization_membership(org, options = {})
|
731
|
+
options = options.dup
|
587
732
|
if user = options.delete(:user)
|
588
|
-
|
733
|
+
options.delete(:state)
|
734
|
+
put "#{Organization.path(org)}/memberships/#{user}", options
|
589
735
|
else
|
736
|
+
options.delete(:role)
|
590
737
|
patch "user/memberships/orgs/#{org}", options
|
591
738
|
end
|
592
739
|
end
|
593
|
-
alias
|
740
|
+
alias update_org_membership update_organization_membership
|
594
741
|
|
595
742
|
# Remove an organization membership
|
596
743
|
#
|
597
|
-
# @param org [String] Organization GitHub login.
|
744
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
598
745
|
# @return [Boolean] Success
|
599
746
|
# @see https://developer.github.com/v3/orgs/members/#remove-organization-membership
|
600
747
|
def remove_organization_membership(org, options = {})
|
748
|
+
options = options.dup
|
601
749
|
user = options.delete(:user)
|
602
|
-
user && boolean_from_response(:delete, "
|
750
|
+
user && boolean_from_response(:delete, "#{Organization.path(org)}/memberships/#{user}", options)
|
603
751
|
end
|
752
|
+
alias remove_org_membership remove_organization_membership
|
604
753
|
|
605
754
|
# Initiates the generation of a migration archive.
|
606
755
|
#
|
@@ -612,11 +761,10 @@ module Octokit
|
|
612
761
|
# @return [Sawyer::Resource] Hash representing the new migration.
|
613
762
|
# @example
|
614
763
|
# @client.start_migration('github', ['github/dotfiles'])
|
615
|
-
# @see https://
|
764
|
+
# @see https://docs.github.com/en/rest/reference/migrations#start-an-organization-migration
|
616
765
|
def start_migration(org, repositories, options = {})
|
617
|
-
options = ensure_api_media_type(:migrations, options)
|
618
766
|
options[:repositories] = repositories
|
619
|
-
post "
|
767
|
+
post "#{Organization.path(org)}/migrations", options
|
620
768
|
end
|
621
769
|
|
622
770
|
# Lists the most recent migrations.
|
@@ -625,10 +773,9 @@ module Octokit
|
|
625
773
|
#
|
626
774
|
# @param org [String, Integer] Organization GitHub login or id.
|
627
775
|
# @return [Array<Sawyer::Resource>] Array of migration resources.
|
628
|
-
# @see https://
|
776
|
+
# @see https://docs.github.com/en/rest/reference/migrations#list-organization-migrations
|
629
777
|
def migrations(org, options = {})
|
630
|
-
|
631
|
-
paginate "orgs/#{org}/migrations", options
|
778
|
+
paginate "#{Organization.path(org)}/migrations", options
|
632
779
|
end
|
633
780
|
|
634
781
|
# Fetches the status of a migration.
|
@@ -637,10 +784,9 @@ module Octokit
|
|
637
784
|
#
|
638
785
|
# @param org [String, Integer] Organization GitHub login or id.
|
639
786
|
# @param id [Integer] ID number of the migration.
|
640
|
-
# @see https://
|
787
|
+
# @see https://docs.github.com/en/rest/reference/migrations#get-an-organization-migration-status
|
641
788
|
def migration_status(org, id, options = {})
|
642
|
-
|
643
|
-
get "orgs/#{org}/migrations/#{id}", options
|
789
|
+
get "#{Organization.path(org)}/migrations/#{id}", options
|
644
790
|
end
|
645
791
|
|
646
792
|
# Fetches the URL to a migration archive.
|
@@ -649,10 +795,9 @@ module Octokit
|
|
649
795
|
#
|
650
796
|
# @param org [String, Integer] Organization GitHub login or id.
|
651
797
|
# @param id [Integer] ID number of the migration.
|
652
|
-
# @see https://
|
798
|
+
# @see https://docs.github.com/en/rest/reference/migrations#download-an-organization-migration-archive
|
653
799
|
def migration_archive_url(org, id, options = {})
|
654
|
-
|
655
|
-
url = "orgs/#{org}/migrations/#{id}/archive"
|
800
|
+
url = "#{Organization.path(org)}/migrations/#{id}/archive"
|
656
801
|
|
657
802
|
response = client_without_redirects(options).get(url)
|
658
803
|
response.headers['location']
|
@@ -664,10 +809,9 @@ module Octokit
|
|
664
809
|
#
|
665
810
|
# @param org [String, Integer] Organization GitHub login or id.
|
666
811
|
# @param id [Integer] ID number of the migration.
|
667
|
-
# @see https://
|
812
|
+
# @see https://docs.github.com/en/rest/reference/migrations#delete-an-organization-migration-archive
|
668
813
|
def delete_migration_archive(org, id, options = {})
|
669
|
-
|
670
|
-
delete "orgs/#{org}/migrations/#{id}/archive", options
|
814
|
+
delete "#{Organization.path(org)}/migrations/#{id}/archive", options
|
671
815
|
end
|
672
816
|
|
673
817
|
# Unlock a previous migration archive.
|
@@ -677,10 +821,43 @@ module Octokit
|
|
677
821
|
# @param org [String, Integer] Organization GitHub login or id.
|
678
822
|
# @param id [Integer] ID number of the migration.
|
679
823
|
# @param repo [String] Name of the repository.
|
680
|
-
# @see https://
|
824
|
+
# @see https://docs.github.com/en/rest/reference/migrations#unlock-an-organization-repository
|
681
825
|
def unlock_repository(org, id, repo, options = {})
|
682
|
-
|
683
|
-
|
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
|
684
861
|
end
|
685
862
|
end
|
686
863
|
end
|
data/lib/octokit/client/pages.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Pages API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/pages/
|
7
8
|
module Pages
|
8
|
-
|
9
9
|
# List Pages information for a repository
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
@@ -24,8 +24,7 @@ module Octokit
|
|
24
24
|
# @example
|
25
25
|
# Octokit.pages_build("github/developer.github.com", 5472601)
|
26
26
|
def pages_build(repo, id, options = {})
|
27
|
-
|
28
|
-
get "#{Repository.path repo}/pages/builds/#{id}", opts
|
27
|
+
get "#{Repository.path repo}/pages/builds/#{id}", options
|
29
28
|
end
|
30
29
|
|
31
30
|
# List Pages builds for a repository
|
@@ -36,7 +35,7 @@ module Octokit
|
|
36
35
|
def pages_builds(repo, options = {})
|
37
36
|
get "#{Repository.path repo}/pages/builds", options
|
38
37
|
end
|
39
|
-
alias
|
38
|
+
alias list_pages_builds pages_builds
|
40
39
|
|
41
40
|
# List the latest Pages build information for a repository
|
42
41
|
#
|
@@ -55,8 +54,7 @@ module Octokit
|
|
55
54
|
# @return [Sawyer::Resource] Request result
|
56
55
|
# @see https://developer.github.com/v3/repos/pages/#request-a-page-build
|
57
56
|
def request_page_build(repo, options = {})
|
58
|
-
|
59
|
-
post "#{Repository.path repo}/pages/builds", opts
|
57
|
+
post "#{Repository.path repo}/pages/builds", options
|
60
58
|
end
|
61
59
|
end
|
62
60
|
end
|