octokit 4.14.0 → 4.19.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.
@@ -81,6 +81,7 @@ module Octokit
81
81
  # @param body [String] An optional concise description
82
82
  # @param options [Hash] A customizable set of options.
83
83
  # @option options [String] :assignee User login.
84
+ # @option options [Array<String>] :assignees User login.
84
85
  # @option options [Integer] :milestone Milestone number.
85
86
  # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
86
87
  # @return [Sawyer::Resource] Your newly created issue
@@ -120,6 +121,7 @@ module Octokit
120
121
  # @param number [Integer] Number ID of the issue
121
122
  # @param options [Hash] A customizable set of options.
122
123
  # @option options [String] :assignee User login.
124
+ # @option options [Array<String>] :assignees User login.
123
125
  # @option options [Integer] :milestone Milestone number.
124
126
  # @option options [Array<String>] :labels List of Label names. Example: <tt>['bug', 'ui', '@high']</tt>.
125
127
  # @return [Sawyer::Resource] The updated Issue
@@ -136,6 +138,7 @@ module Octokit
136
138
  # @param number [Integer] Number ID of the issue
137
139
  # @param options [Hash] A customizable set of options.
138
140
  # @option options [String] :assignee User login.
141
+ # @option options [Array<String>] :assignees User login.
139
142
  # @option options [Integer] :milestone Milestone number.
140
143
  # @option options [Array<String>] :labels List of Label names. Example: <tt>['bug', 'ui', '@high']</tt>.
141
144
  # @return [Sawyer::Resource] The updated Issue
@@ -179,6 +182,7 @@ module Octokit
179
182
  # @param body [String] Updated body of the issue
180
183
  # @param options [Hash] A customizable set of options.
181
184
  # @option options [String] :assignee User login.
185
+ # @option options [Array<String>] :assignees User login.
182
186
  # @option options [Integer] :milestone Milestone number.
183
187
  # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
184
188
  # @option options [String] :state State of the issue. <tt>open</tt> or <tt>closed</tt>
@@ -190,6 +194,7 @@ module Octokit
190
194
  # @option options [String] :title Updated title for the issue
191
195
  # @option options [String] :body Updated body of the issue
192
196
  # @option options [String] :assignee User login.
197
+ # @option options [Array<String>] :assignees User login.
193
198
  # @option options [Integer] :milestone Milestone number.
194
199
  # @option options [Array<String>] :labels List of Label names. Example: <tt>['bug', 'ui', '@high']</tt>.
195
200
  # @option options [String] :state State of the issue. <tt>open</tt> or <tt>closed</tt>
@@ -332,7 +337,7 @@ module Octokit
332
337
  #
333
338
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
334
339
  # @param number [Integer] Issue number
335
- # @param assignees [Array] Assignees to be added
340
+ # @param assignees [Array<String>] Assignees to be added
336
341
  # @return [Sawyer::Resource] Issue
337
342
  # @see https://developer.github.com/v3/issues/assignees/#add-assignees-to-an-issue
338
343
  # @example Add assignees "pengwynn" and "joeyw" to Issue #23 on octokit/octokit.rb
@@ -345,7 +350,7 @@ module Octokit
345
350
  #
346
351
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
347
352
  # @param number [Integer] Issue number
348
- # @param assignees [Array] Assignees to be removed
353
+ # @param assignees [Array<String>] Assignees to be removed
349
354
  # @param options [Hash] Header params for request
350
355
  # @return [Sawyer::Resource] Issue
351
356
  # @see https://developer.github.com/v3/issues/assignees/#remove-assignees-from-an-issue
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Octokit
4
+ class Client
5
+
6
+ # Methods for the OauthApplications API
7
+ #
8
+ # @see https://developer.github.com/v3/apps/oauth_applications
9
+ module OauthApplications
10
+
11
+ # Check if a token is valid.
12
+ #
13
+ # Applications can check if a token is valid without rate limits.
14
+ #
15
+ # @param access_token [String] 40 character GitHub OAuth access token
16
+ #
17
+ # @return [Sawyer::Resource] A single authorization for the authenticated user
18
+ # @see https://developer.github.com/v3/apps/oauth_applications/#check-a-token
19
+ #
20
+ # @example
21
+ # client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
22
+ # client.check_token('deadbeef1234567890deadbeef987654321')
23
+ def check_token(access_token, options = {})
24
+ options = ensure_api_media_type(:applications_api, options.dup)
25
+ options[:access_token] = access_token
26
+
27
+ key = options.delete(:client_id) || client_id
28
+ secret = options.delete(:client_secret) || client_secret
29
+
30
+ as_app(key, secret) do |app_client|
31
+ app_client.post "applications/#{client_id}/token", options
32
+ end
33
+ end
34
+ alias check_application_authorization check_token
35
+
36
+ # Reset a token
37
+ #
38
+ # Applications can reset a token without requiring a user to re-authorize.
39
+ #
40
+ # @param access_token [String] 40 character GitHub OAuth access token
41
+ #
42
+ # @return [Sawyer::Resource] A single authorization for the authenticated user
43
+ # @see https://developer.github.com/v3/apps/oauth_applications/#reset-a-token
44
+ #
45
+ # @example
46
+ # client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
47
+ # client.reset_token('deadbeef1234567890deadbeef987654321')
48
+ def reset_token(access_token, options = {})
49
+ options = ensure_api_media_type(:applications_api, options.dup)
50
+ options[:access_token] = access_token
51
+
52
+ key = options.delete(:client_id) || client_id
53
+ secret = options.delete(:client_secret) || client_secret
54
+
55
+ as_app(key, secret) do |app_client|
56
+ app_client.patch "applications/#{client_id}/token", options
57
+ end
58
+ end
59
+ alias reset_application_authorization reset_token
60
+
61
+ # Delete an app token
62
+ #
63
+ # Applications can revoke (delete) a token
64
+ #
65
+ # @param access_token [String] 40 character GitHub OAuth access token
66
+ #
67
+ # @return [Boolean] Result
68
+ # @see https://developer.github.com/v3/apps/oauth_applications/#delete-an-app-token
69
+ #
70
+ # @example
71
+ # client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
72
+ # client.delete_token('deadbeef1234567890deadbeef987654321')
73
+ def delete_app_token(access_token, options = {})
74
+ options = ensure_api_media_type(:applications_api, options.dup)
75
+ options[:access_token] = access_token
76
+
77
+ key = options.delete(:client_id) || client_id
78
+ secret = options.delete(:client_secret) || client_secret
79
+
80
+ begin
81
+ as_app(key, secret) do |app_client|
82
+ app_client.delete "applications/#{client_id}/token", options
83
+ app_client.last_response.status == 204
84
+ end
85
+ rescue Octokit::NotFound
86
+ false
87
+ end
88
+ end
89
+ alias delete_application_authorization delete_app_token
90
+ alias revoke_application_authorization delete_app_token
91
+
92
+ # Delete an app authorization
93
+ #
94
+ # OAuth application owners can revoke a grant for their OAuth application and a specific user.
95
+ #
96
+ # @param access_token [String] 40 character GitHub OAuth access token
97
+ #
98
+ # @return [Boolean] Result
99
+ # @see https://developer.github.com/v3/apps/oauth_applications/#delete-an-app-token
100
+ #
101
+ # @example
102
+ # client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
103
+ # client.delete_app_authorization('deadbeef1234567890deadbeef987654321')
104
+ def delete_app_authorization(access_token, options = {})
105
+ options = ensure_api_media_type(:applications_api, options.dup)
106
+ options[:access_token] = access_token
107
+
108
+ key = options.delete(:client_id) || client_id
109
+ secret = options.delete(:client_secret) || client_secret
110
+
111
+ begin
112
+ as_app(key, secret) do |app_client|
113
+ app_client.delete "applications/#{client_id}/grant", options
114
+ app_client.last_response.status == 204
115
+ end
116
+ rescue Octokit::NotFound
117
+ false
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
@@ -324,6 +324,20 @@ module Octokit
324
324
  get "teams/#{team_id}", options
325
325
  end
326
326
 
327
+ # Get team by name and org
328
+ #
329
+ # Requires authenticated organization member.
330
+ #
331
+ # @param org [String, Integer] Organization GitHub login or id.
332
+ # @param team_slug [String] Team slug.
333
+ # @return [Sawyer::Resource] Hash representing team.
334
+ # @see https://developer.github.com/v3/teams/#get-team-by-name
335
+ # @example
336
+ # @client.team_by_name("github", "justice-league")
337
+ def team_by_name(org, team_slug, options = {})
338
+ get "#{Organization.path(org)}/teams/#{team_slug}", options
339
+ end
340
+
327
341
  # List child teams
328
342
  #
329
343
  # Requires authenticated organization member.
@@ -676,7 +690,7 @@ module Octokit
676
690
 
677
691
  # Edit an organization membership
678
692
  #
679
- # @param org [String] Organization GitHub login.
693
+ # @param org [String, Integer] Organization GitHub login or id.
680
694
  # @option options [String] :role The role of the user in the organization.
681
695
  # @option options [String] :state The state that the membership should be in.
682
696
  # @option options [String] :user The login of the user, otherwise authenticated user.
@@ -687,7 +701,7 @@ module Octokit
687
701
  options = options.dup
688
702
  if user = options.delete(:user)
689
703
  options.delete(:state)
690
- put "orgs/#{org}/memberships/#{user}", options
704
+ put "#{Organization.path(org)}/memberships/#{user}", options
691
705
  else
692
706
  options.delete(:role)
693
707
  patch "user/memberships/orgs/#{org}", options
@@ -697,13 +711,13 @@ module Octokit
697
711
 
698
712
  # Remove an organization membership
699
713
  #
700
- # @param org [String] Organization GitHub login.
714
+ # @param org [String, Integer] Organization GitHub login or id.
701
715
  # @return [Boolean] Success
702
716
  # @see https://developer.github.com/v3/orgs/members/#remove-organization-membership
703
717
  def remove_organization_membership(org, options = {})
704
718
  options = options.dup
705
719
  user = options.delete(:user)
706
- user && boolean_from_response(:delete, "orgs/#{org}/memberships/#{user}", options)
720
+ user && boolean_from_response(:delete, "#{Organization.path(org)}/memberships/#{user}", options)
707
721
  end
708
722
  alias :remove_org_membership :remove_organization_membership
709
723
 
@@ -721,7 +735,7 @@ module Octokit
721
735
  def start_migration(org, repositories, options = {})
722
736
  options = ensure_api_media_type(:migrations, options)
723
737
  options[:repositories] = repositories
724
- post "orgs/#{org}/migrations", options
738
+ post "#{Organization.path(org)}/migrations", options
725
739
  end
726
740
 
727
741
  # Lists the most recent migrations.
@@ -733,7 +747,7 @@ module Octokit
733
747
  # @see https://developer.github.com/v3/orgs/migrations/#get-a-list-of-migrations
734
748
  def migrations(org, options = {})
735
749
  options = ensure_api_media_type(:migrations, options)
736
- paginate "orgs/#{org}/migrations", options
750
+ paginate "#{Organization.path(org)}/migrations", options
737
751
  end
738
752
 
739
753
  # Fetches the status of a migration.
@@ -745,7 +759,7 @@ module Octokit
745
759
  # @see https://developer.github.com/v3/orgs/migrations/#get-the-status-of-a-migration
746
760
  def migration_status(org, id, options = {})
747
761
  options = ensure_api_media_type(:migrations, options)
748
- get "orgs/#{org}/migrations/#{id}", options
762
+ get "#{Organization.path(org)}/migrations/#{id}", options
749
763
  end
750
764
 
751
765
  # Fetches the URL to a migration archive.
@@ -757,7 +771,7 @@ module Octokit
757
771
  # @see https://developer.github.com/v3/orgs/migrations/#download-a-migration-archive
758
772
  def migration_archive_url(org, id, options = {})
759
773
  options = ensure_api_media_type(:migrations, options)
760
- url = "orgs/#{org}/migrations/#{id}/archive"
774
+ url = "#{Organization.path(org)}/migrations/#{id}/archive"
761
775
 
762
776
  response = client_without_redirects(options).get(url)
763
777
  response.headers['location']
@@ -772,7 +786,7 @@ module Octokit
772
786
  # @see https://developer.github.com/v3/orgs/migrations/#delete-a-migration-archive
773
787
  def delete_migration_archive(org, id, options = {})
774
788
  options = ensure_api_media_type(:migrations, options)
775
- delete "orgs/#{org}/migrations/#{id}/archive", options
789
+ delete "#{Organization.path(org)}/migrations/#{id}/archive", options
776
790
  end
777
791
 
778
792
  # Unlock a previous migration archive.
@@ -785,7 +799,7 @@ module Octokit
785
799
  # @see https://developer.github.com/v3/orgs/migrations/#unlock-a-repository
786
800
  def unlock_repository(org, id, repo, options = {})
787
801
  options = ensure_api_media_type(:migrations, options)
788
- delete "orgs/#{org}/migrations/#{id}/repos/#{repo}/lock", options
802
+ delete "#{Organization.path(org)}/migrations/#{id}/repos/#{repo}/lock", options
789
803
  end
790
804
  end
791
805
  end
@@ -11,7 +11,7 @@ module Octokit
11
11
  # @overload pull_requests(repo, options)
12
12
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
13
13
  # @param options [Hash] Method options
14
- # @option options [String] :state `open` or `closed`.
14
+ # @option options [String] :state `open` or `closed` or `all`.
15
15
  # @return [Array<Sawyer::Resource>] Array of pulls
16
16
  # @see https://developer.github.com/v3/pulls/#list-pull-requests
17
17
  # @example
@@ -60,11 +60,13 @@ module Octokit
60
60
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
61
61
  # @param ref [String] The ref, e.g. <tt>tags/v0.0.3</tt>
62
62
  # @param sha [String] A SHA, e.g. <tt>827efc6d56897b048c772eb4087f854f46256132</tt>
63
- # @param force [Boolean] A flag indicating one wants to force the update to make sure the update is a fast-forward update.
63
+ # @param force [Boolean] A flag indicating whether to force the update or to make sure the update is a fast-forward update.
64
64
  # @return [Array<Sawyer::Resource>] The list of references updated
65
65
  # @see https://developer.github.com/v3/git/refs/#update-a-reference
66
66
  # @example Force update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
67
67
  # Octokit.update_ref("octocat/Hello-World", "heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd")
68
+ # @example Fast-forward update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
69
+ # Octokit.update_ref("octocat/Hello-World", "heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd", false)
68
70
  def update_ref(repo, ref, sha, force = true, options = {})
69
71
  parameters = {
70
72
  :sha => sha,
@@ -79,11 +81,13 @@ module Octokit
79
81
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
80
82
  # @param branch [String] The ref, e.g. <tt>feature/new-shiny</tt>
81
83
  # @param sha [String] A SHA, e.g. <tt>827efc6d56897b048c772eb4087f854f46256132</tt>
82
- # @param force [Boolean] A flag indicating one wants to force the update to make sure the update is a fast-forward update.
84
+ # @param force [Boolean] A flag indicating whether to force the update or to make sure the update is a fast-forward update.
83
85
  # @return [Array<Sawyer::Resource>] The list of references updated
84
86
  # @see https://developer.github.com/v3/git/refs/#update-a-reference
85
87
  # @example Force update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
86
- # Octokit.update_ref("octocat/Hello-World","sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd")
88
+ # Octokit.update_branch("octocat/Hello-World", "sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd")
89
+ # @example Fast-forward update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
90
+ # Octokit.update_branch("octocat/Hello-World", "sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd", false)
87
91
  def update_branch(repo, branch, sha, force = true, options = {})
88
92
  update_ref repo, "heads/#{branch}", sha, force, options
89
93
  end
@@ -32,7 +32,7 @@ module Octokit
32
32
 
33
33
  # Edit a repository
34
34
  #
35
- # @see https://developer.github.com/v3/repos/#edit
35
+ # @see https://developer.github.com/v3/repos/#update-a-repository
36
36
  # @param repo [String, Hash, Repository] A GitHub repository
37
37
  # @param options [Hash] Repository information to update
38
38
  # @option options [String] :name Name of the repo
@@ -41,11 +41,15 @@ module Octokit
41
41
  # @option options [String] :private `true` makes the repository private, and `false` makes it public.
42
42
  # @option options [String] :has_issues `true` enables issues for this repo, `false` disables issues.
43
43
  # @option options [String] :has_wiki `true` enables wiki for this repo, `false` disables wiki.
44
+ # @option options [Boolean] :is_template `true` makes the repository a template, `false` makes it not a template.
44
45
  # @option options [String] :has_downloads `true` enables downloads for this repo, `false` disables downloads.
45
46
  # @option options [String] :default_branch Update the default branch for this repository.
46
47
  # @return [Sawyer::Resource] Repository information
47
48
  def edit_repository(repo, options = {})
48
49
  repo = Repository.new(repo)
50
+ if options.include? :is_template
51
+ options = ensure_api_media_type(:template_repositories, options)
52
+ end
49
53
  options[:name] ||= repo.name
50
54
  patch "repos/#{repo}", options
51
55
  end
@@ -144,6 +148,7 @@ module Octokit
144
148
  # @option options [String] :private `true` makes the repository private, and `false` makes it public.
145
149
  # @option options [String] :has_issues `true` enables issues for this repo, `false` disables issues.
146
150
  # @option options [String] :has_wiki `true` enables wiki for this repo, `false` disables wiki.
151
+ # @option options [Boolean] :is_template `true` makes this repo available as a template repository, `false` to prevent it.
147
152
  # @option options [String] :has_downloads `true` enables downloads for this repo, `false` disables downloads.
148
153
  # @option options [String] :organization Short name for the org under which to create the repo.
149
154
  # @option options [Integer] :team_id The id of the team that will be granted access to this repository. This is only valid when creating a repo in an organization.
@@ -155,6 +160,9 @@ module Octokit
155
160
  opts = options.dup
156
161
  organization = opts.delete :organization
157
162
  opts.merge! :name => name
163
+ if opts.include? :is_template
164
+ opts = ensure_api_media_type(:template_repositories, opts)
165
+ end
158
166
 
159
167
  if organization.nil?
160
168
  post 'user/repos', opts
@@ -192,6 +200,22 @@ module Octokit
192
200
  end
193
201
  alias :transfer_repo :transfer_repository
194
202
 
203
+ # Create a repository for a user or organization generated from a template repository
204
+ #
205
+ # @param repo [Integer, String, Hash, Repository] A GitHub template repository
206
+ # @param name [String] Name of the new repo
207
+ # @option options [String] :owner Organization or user who the new repository will belong to.
208
+ # @option options [String] :description Description of the repo
209
+ # @option options [String] :private `true` makes the repository private, and `false` makes it public.
210
+ # @option options [Boolean] :include_all_branches `true` copies all branches from the template repository, `false` (default) makes it only copy the master branch.
211
+ # @return [Sawyer::Resource] Repository info for the new repository
212
+ def create_repository_from_template(repo, name, options = {})
213
+ options.merge! :name => name
214
+ options = ensure_api_media_type(:template_repositories, options)
215
+ post "#{Repository.path repo}/generate", options
216
+ end
217
+ alias :create_repo_from_template :create_repository_from_template
218
+
195
219
  # Hide a public repository
196
220
  #
197
221
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
@@ -405,7 +429,7 @@ module Octokit
405
429
  # @example List topics for octokit/octokit.rb
406
430
  # Octokit.topics('octokit/octokit.rb')
407
431
  # @example List topics for octokit/octokit.rb
408
- # client.topics('octokit/octokit.rb')
432
+ # client.topics('octokit/octokit.rb')
409
433
  def topics(repo, options = {})
410
434
  opts = ensure_api_media_type(:topics, options)
411
435
  paginate "#{Repository.path repo}/topics", opts
@@ -562,14 +586,14 @@ module Octokit
562
586
  #
563
587
  # @param repo [Integer, String, Hash, Repository] A GitHub repository.
564
588
  # @param branch [String] Branch name
565
- # @option options [Hash] :required_status_checks If not null, the following keys are required:
566
- # <tt>:enforce_admins [boolean] Enforce required status checks for repository administrators.</tt>
567
- # <tt>:strict [boolean] Require branches to be up to date before merging.</tt>
568
- # <tt>:contexts [Array] The list of status checks to require in order to merge into this branch</tt>
589
+ # @option options [Hash] :required_status_checks If not null, the following keys are required:
590
+ # <tt>:enforce_admins [boolean] Enforce required status checks for repository administrators.</tt>
591
+ # <tt>:strict [boolean] Require branches to be up to date before merging.</tt>
592
+ # <tt>:contexts [Array] The list of status checks to require in order to merge into this branch</tt>
569
593
  #
570
594
  # @option options [Hash] :restrictions If not null, the following keys are required:
571
- # <tt>:users [Array] The list of user logins with push access</tt>
572
- # <tt>:teams [Array] The list of team slugs with push access</tt>.
595
+ # <tt>:users [Array] The list of user logins with push access</tt>
596
+ # <tt>:teams [Array] The list of team slugs with push access</tt>.
573
597
  #
574
598
  # Teams and users restrictions are only available for organization-owned repositories.
575
599
  # @return [Sawyer::Resource] The protected branch
@@ -696,6 +720,19 @@ module Octokit
696
720
  def delete_subscription(repo, options = {})
697
721
  boolean_from_response :delete, "#{Repository.path repo}/subscription", options
698
722
  end
723
+
724
+ # Create a repository dispatch event
725
+ #
726
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
727
+ # @param event_type [String] A custom webhook event name.
728
+ # @option options [Hash] :client_payload payload with extra information
729
+ # about the webhook event that your action or worklow may use.
730
+ #
731
+ # @return [Boolean] True if event was dispatched, false otherwise.
732
+ # @see https://developer.github.com/v3/repos/#create-a-repository-dispatch-event
733
+ def dispatch_event(repo, event_type, options = {})
734
+ boolean_from_response :post, "#{Repository.path repo}/dispatches", options.merge({ event_type: event_type })
735
+ end
699
736
  end
700
737
  end
701
738
  end
@@ -13,7 +13,7 @@ module Octokit
13
13
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
14
14
  # @param user [String] User GitHub username to add
15
15
  # @return [Sawyer::Resource] The repository invitation
16
- # @see https://developer.github.com/v3/repos/invitations/#invite-a-user-to-a-repository
16
+ # @see https://developer.github.com/v3/repos/collaborators/#add-user-as-a-collaborator
17
17
  def invite_user_to_repository(repo, user, options = {})
18
18
  put "#{Repository.path repo}/collaborators/#{user}", options
19
19
  end
@@ -204,6 +204,24 @@ module Octokit
204
204
  options = options.merge(reviewers)
205
205
  delete "#{Repository.path repo}/pulls/#{id}/requested_reviewers", options
206
206
  end
207
+
208
+ # Update a review request comment
209
+ #
210
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
211
+ # @param number [Integer] Number ID of the pull request
212
+ # @param review [Integer] The id of the review
213
+ # @param body [String] body text of the pull request review.
214
+ # @param options [Hash] Method options
215
+ # @see https://developer.github.com/v3/pulls/reviews/#update-a-pull-request-review
216
+ #
217
+ # @example
218
+ # @client.update_pull_request_review('octokit/octokit.rb', 825, 6505518, 'This is close to perfect! Please address the suggested inline change. And add more about this.')
219
+ #
220
+ # @return [Sawyer::Resource] Hash representing the review comment
221
+ def update_pull_request_review(repo, number, review, body, options = {})
222
+ options[:body] = body
223
+ put "#{Repository.path repo}/pulls/#{number}/reviews/#{review}", options
224
+ end
207
225
  end
208
226
  end
209
227
  end
@@ -44,7 +44,7 @@ module Octokit
44
44
  # @option options [Integer] :page Page of paginated results
45
45
  # @option options [Integer] :per_page Number of items per page
46
46
  # @return [Sawyer::Resource] Search results object
47
- # @see https://developer.github.com/v3/search/#search-issues
47
+ # @see https://developer.github.com/v3/search/#search-issues-and-pull-requests
48
48
  def search_issues(query, options = {})
49
49
  search "search/issues", query, options
50
50
  end
@@ -340,6 +340,92 @@ module Octokit
340
340
  end
341
341
  alias :watched :subscriptions
342
342
 
343
+ # Initiates the generation of a migration archive.
344
+ #
345
+ # Requires authenticated user.
346
+ #
347
+ # @param repositories [Array<String>] :repositories Repositories for the organization.
348
+ # @option options [Boolean, optional] :lock_repositories Indicates whether repositories should be locked during migration
349
+ # @option options [Boolean, optional] :exclude_attachments Exclude attachments fro the migration data
350
+ # @return [Sawyer::Resource] Hash representing the new migration.
351
+ # @example
352
+ # @client.start_migration(['octocat/hello-world'])
353
+ # @see https://docs.github.com/en/rest/reference/migrations#start-a-user-migration
354
+ def start_user_migration(repositories, options = {})
355
+ options = ensure_api_media_type(:migrations, options)
356
+ options[:repositories] = repositories
357
+ post "user/migrations", options
358
+ end
359
+
360
+ # Lists the most recent migrations.
361
+ #
362
+ # Requires authenticated user.
363
+ #
364
+ # @return [Array<Sawyer::Resource>] Array of migration resources.
365
+ # @see https://docs.github.com/en/rest/reference/migrations#list-user-migrations
366
+ def user_migrations(options = {})
367
+ options = ensure_api_media_type(:migrations, options)
368
+ paginate "user/migrations", options
369
+ end
370
+
371
+ # Fetches the status of a migration.
372
+ #
373
+ # Requires authenticated user.
374
+ #
375
+ # @param id [Integer] ID number of the migration.
376
+ # @see https://docs.github.com/en/rest/reference/migrations#get-a-user-migration-status
377
+ def user_migration_status(id, options = {})
378
+ options = ensure_api_media_type(:migrations, options)
379
+ get "user/migrations/#{id}", options
380
+ end
381
+
382
+ # Fetches the URL to a migration archive.
383
+ #
384
+ # Requires authenticated user.
385
+ #
386
+ # @param id [Integer] ID number of the migration.
387
+ # @see https://docs.github.com/en/rest/reference/migrations#download-a-user-migration-archive
388
+ def user_migration_archive_url(id, options = {})
389
+ options = ensure_api_media_type(:migrations, options)
390
+ url = "user/migrations/#{id}/archive"
391
+
392
+ response = client_without_redirects(options).get(url)
393
+ response.headers['location']
394
+ end
395
+
396
+ # Deletes a previous migration archive.
397
+ #
398
+ # Requires authenticated user.
399
+ #
400
+ # @param id [Integer] ID number of the migration.
401
+ # @see https://docs.github.com/en/rest/reference/migrations#delete-a-user-migration-archive
402
+ def delete_user_migration_archive(id, options = {})
403
+ options = ensure_api_media_type(:migrations, options)
404
+ delete "user/migrations/#{id}/archive", options
405
+ end
406
+
407
+ # List repositories for a user migration.
408
+ #
409
+ # Requires authenticated user.
410
+ #
411
+ # @param id [Integer] ID number of the migration.
412
+ # @see https://docs.github.com/en/rest/reference/migrations#list-repositories-for-a-user-migration
413
+ def user_migration_repositories(id, options = {})
414
+ options = ensure_api_media_type(:migrations, options)
415
+ get "user/migrations/#{id}/repositories", options
416
+ end
417
+
418
+ # Unlock a user repository which has been locked by a migration.
419
+ #
420
+ # Requires authenticated user.
421
+ #
422
+ # @param id [Integer] ID number of the migration.
423
+ # @param repo [String] Name of the repository.
424
+ # @see https://docs.github.com/en/rest/reference/migrations#unlock-a-user-repository
425
+ def unlock_user_repository(id, repo, options = {})
426
+ options = ensure_api_media_type(:migrations, options)
427
+ delete "user/migrations/#{id}/repos/#{repo}/lock", options
428
+ end
343
429
  end
344
430
 
345
431
  private
@@ -10,11 +10,16 @@ require 'octokit/repository'
10
10
  require 'octokit/user'
11
11
  require 'octokit/organization'
12
12
  require 'octokit/preview'
13
+ require 'octokit/client/actions_secrets'
14
+ require 'octokit/client/actions_workflows'
15
+ require 'octokit/client/actions_workflow_runs'
13
16
  require 'octokit/client/apps'
14
17
  require 'octokit/client/authorizations'
15
18
  require 'octokit/client/checks'
16
19
  require 'octokit/client/commits'
17
20
  require 'octokit/client/commit_comments'
21
+ require 'octokit/client/commit_pulls'
22
+ require 'octokit/client/commit_branches'
18
23
  require 'octokit/client/community_profile'
19
24
  require 'octokit/client/contents'
20
25
  require 'octokit/client/downloads'
@@ -34,6 +39,7 @@ require 'octokit/client/markdown'
34
39
  require 'octokit/client/marketplace'
35
40
  require 'octokit/client/milestones'
36
41
  require 'octokit/client/notifications'
42
+ require 'octokit/client/oauth_applications'
37
43
  require 'octokit/client/objects'
38
44
  require 'octokit/client/organizations'
39
45
  require 'octokit/client/pages'
@@ -69,10 +75,13 @@ module Octokit
69
75
  include Octokit::Connection
70
76
  include Octokit::Preview
71
77
  include Octokit::Warnable
78
+ include Octokit::Client::ActionsSecrets
72
79
  include Octokit::Client::Authorizations
73
80
  include Octokit::Client::Checks
74
81
  include Octokit::Client::Commits
75
82
  include Octokit::Client::CommitComments
83
+ include Octokit::Client::CommitPulls
84
+ include Octokit::Client::CommitBranches
76
85
  include Octokit::Client::CommunityProfile
77
86
  include Octokit::Client::Contents
78
87
  include Octokit::Client::Deployments
@@ -83,6 +92,8 @@ module Octokit
83
92
  include Octokit::Client::Gists
84
93
  include Octokit::Client::Gitignore
85
94
  include Octokit::Client::Hooks
95
+ include Octokit::Client::ActionsWorkflows
96
+ include Octokit::Client::ActionsWorkflowRuns
86
97
  include Octokit::Client::Apps
87
98
  include Octokit::Client::Issues
88
99
  include Octokit::Client::Labels
@@ -93,6 +104,7 @@ module Octokit
93
104
  include Octokit::Client::Marketplace
94
105
  include Octokit::Client::Milestones
95
106
  include Octokit::Client::Notifications
107
+ include Octokit::Client::OauthApplications
96
108
  include Octokit::Client::Objects
97
109
  include Octokit::Client::Organizations
98
110
  include Octokit::Client::Pages