octokit 6.1.1 → 8.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -21
- data/Rakefile +9 -3
- data/lib/octokit/client/actions_secrets.rb +107 -5
- data/lib/octokit/client/apps.rb +25 -0
- data/lib/octokit/client/code_scanning.rb +53 -0
- data/lib/octokit/client/codespaces_secrets.rb +108 -0
- data/lib/octokit/client/dependabot_secrets.rb +108 -0
- data/lib/octokit/client/deployments.rb +2 -2
- data/lib/octokit/client/oauth_applications.rb +1 -1
- data/lib/octokit/client/organizations.rb +1 -1
- data/lib/octokit/client/pull_requests.rb +6 -3
- data/lib/octokit/client/reactions.rb +56 -5
- data/lib/octokit/client/reviews.rb +1 -1
- data/lib/octokit/client/users.rb +27 -0
- data/lib/octokit/client.rb +6 -0
- data/lib/octokit/middleware/follow_redirects.rb +1 -1
- data/lib/octokit/repository.rb +2 -1
- data/lib/octokit/version.rb +2 -2
- data/octokit.gemspec +1 -1
- metadata +10 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dead7bdb61143c1a0b84afa0b02b567a29e117b0b15e0d0ee10271bb9dc62a17
|
4
|
+
data.tar.gz: 648cb60f5d7f8765f925ec2a673dd00331151d3222b392a9814e856e6d303a67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b5d2d09d0665466a4bdca1d523758ad447db67c911284c2738a311c400267dbbabcf4c92079c83550339b1cd5361abe841a672a89bc77a7345940d3041cee65
|
7
|
+
data.tar.gz: ca2ced14c1bb869c41f94806427fbd16917eadd6486c35c58c69c59c44b384c323b282266ae95b84bd6109674051a963d6b2d1fea15609bbc61c033a55b6e90f
|
data/README.md
CHANGED
@@ -213,15 +213,7 @@ user.login
|
|
213
213
|
# => "defunkt"
|
214
214
|
```
|
215
215
|
|
216
|
-
You can [create access tokens through your GitHub Account Settings](https://help.github.com/articles/creating-an-access-token-for-command-line-use)
|
217
|
-
or with a basic authenticated Octokit client:
|
218
|
-
|
219
|
-
```ruby
|
220
|
-
client = Octokit::Client.new(:login => 'defunkt', :password => 'c0d3b4ssssss!')
|
221
|
-
|
222
|
-
client.create_authorization(:scopes => ["user"], :note => "Name of token")
|
223
|
-
# => <your new oauth token>
|
224
|
-
```
|
216
|
+
You can [create access tokens through your GitHub Account Settings](https://help.github.com/articles/creating-an-access-token-for-command-line-use).
|
225
217
|
|
226
218
|
### Two-Factor Authentication
|
227
219
|
|
@@ -237,18 +229,6 @@ client = Octokit::Client.new \
|
|
237
229
|
user = client.user("defunkt", :headers => { "X-GitHub-OTP" => "<your 2FA token>" })
|
238
230
|
```
|
239
231
|
|
240
|
-
As you can imagine, this gets annoying quickly since two-factor auth tokens are very short lived. So it is recommended to create an oauth token for the user to communicate with the API:
|
241
|
-
|
242
|
-
```ruby
|
243
|
-
client = Octokit::Client.new \
|
244
|
-
:login => 'defunkt',
|
245
|
-
:password => 'c0d3b4ssssss!'
|
246
|
-
|
247
|
-
client.create_authorization(:scopes => ["user"], :note => "Name of token",
|
248
|
-
:headers => { "X-GitHub-OTP" => "<your 2FA token>" })
|
249
|
-
# => <your new oauth token>
|
250
|
-
```
|
251
|
-
|
252
232
|
### Using a .netrc file
|
253
233
|
|
254
234
|
Octokit supports reading credentials from a netrc file (defaulting to
|
data/Rakefile
CHANGED
@@ -3,12 +3,18 @@
|
|
3
3
|
require 'bundler'
|
4
4
|
Bundler::GemHelper.install_tasks
|
5
5
|
|
6
|
-
require 'rspec/core/rake_task'
|
7
|
-
RSpec::Core::RakeTask.new(:spec)
|
8
|
-
|
9
6
|
task test: :spec
|
10
7
|
task default: :spec
|
11
8
|
|
9
|
+
desc 'Run RSpec'
|
10
|
+
task :spec do
|
11
|
+
if Process.respond_to?(:fork)
|
12
|
+
sh('rspec-queue')
|
13
|
+
else
|
14
|
+
sh('rspec')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
12
18
|
namespace :doc do
|
13
19
|
require 'yard'
|
14
20
|
YARD::Rake::YardocTask.new do |task|
|
@@ -11,49 +11,151 @@ module Octokit
|
|
11
11
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
12
|
# @return [Hash] key_id and key
|
13
13
|
# @see https://developer.github.com/v3/actions/secrets/#get-your-public-key
|
14
|
-
def
|
14
|
+
def get_actions_public_key(repo)
|
15
15
|
get "#{Repository.path repo}/actions/secrets/public-key"
|
16
16
|
end
|
17
17
|
|
18
|
+
# Get public key for secrets encryption
|
19
|
+
#
|
20
|
+
# @param org [String] A GitHub organization
|
21
|
+
# @return [Hash] key_id and key
|
22
|
+
# @see https://developer.github.com/v3/actions/secrets/#get-your-public-key
|
23
|
+
def get_org_actions_public_key(org)
|
24
|
+
get "#{Organization.path org}/actions/secrets/public-key"
|
25
|
+
end
|
26
|
+
|
18
27
|
# List secrets
|
19
28
|
#
|
20
29
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
21
30
|
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
22
31
|
# @see https://developer.github.com/v3/actions/secrets/#list-secrets-for-a-repository
|
23
|
-
def
|
32
|
+
def list_actions_secrets(repo)
|
24
33
|
paginate "#{Repository.path repo}/actions/secrets" do |data, last_response|
|
25
34
|
data.secrets.concat last_response.data.secrets
|
26
35
|
end
|
27
36
|
end
|
28
37
|
|
38
|
+
# List org secrets
|
39
|
+
#
|
40
|
+
# @param org [String] A GitHub organization
|
41
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
42
|
+
# @see https://developer.github.com/v3/actions/secrets/#list-organization-secrets
|
43
|
+
def list_org_actions_secrets(org)
|
44
|
+
paginate "#{Organization.path org}/actions/secrets" do |data, last_response|
|
45
|
+
data.secrets.concat last_response.data.secrets
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
29
49
|
# Get a secret
|
30
50
|
#
|
31
51
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
32
52
|
# @param name [String] Name of secret
|
33
53
|
# @return [Hash] name, created_at and updated_at
|
34
54
|
# @see https://developer.github.com/v3/actions/secrets/#get-a-secret
|
35
|
-
def
|
55
|
+
def get_actions_secret(repo, name)
|
36
56
|
get "#{Repository.path repo}/actions/secrets/#{name}"
|
37
57
|
end
|
38
58
|
|
59
|
+
# Get an org secret
|
60
|
+
#
|
61
|
+
# @param org [String] A GitHub organization
|
62
|
+
# @param name [String] Name of secret
|
63
|
+
# @return [Hash] name, created_at and updated_at
|
64
|
+
# @see https://developer.github.com/v3/actions/secrets/#get-a-secret
|
65
|
+
def get_org_actions_secret(org, name)
|
66
|
+
get "#{Organization.path org}/actions/secrets/#{name}"
|
67
|
+
end
|
68
|
+
|
39
69
|
# Create or update secrets
|
40
70
|
#
|
41
71
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
42
72
|
# @param name [String] Name of secret
|
43
73
|
# @param options [Hash] encrypted_value and key_id
|
44
74
|
# @see https://developer.github.com/v3/actions/secrets/#create-or-update-a-secret-for-a-repository
|
45
|
-
def
|
75
|
+
def create_or_update_actions_secret(repo, name, options)
|
46
76
|
put "#{Repository.path repo}/actions/secrets/#{name}", options
|
47
77
|
end
|
48
78
|
|
79
|
+
# Create or update org secrets
|
80
|
+
#
|
81
|
+
# @param org [String] A GitHub organization
|
82
|
+
# @param name [String] Name of secret
|
83
|
+
# @param options [Hash] encrypted_value and key_id
|
84
|
+
# @see https://developer.github.com/v3/actions/secrets/#create-or-update-a-secret
|
85
|
+
def create_or_update_org_actions_secret(org, name, options)
|
86
|
+
put "#{Organization.path org}/actions/secrets/#{name}", options
|
87
|
+
end
|
88
|
+
|
49
89
|
# Delete a secret
|
50
90
|
#
|
51
91
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
52
92
|
# @param name [String] Name of secret
|
53
93
|
# @see https://developer.github.com/v3/actions/secrets/#delete-a-secret-from-a-repository
|
54
|
-
def
|
94
|
+
def delete_actions_secret(repo, name)
|
55
95
|
boolean_from_response :delete, "#{Repository.path repo}/actions/secrets/#{name}"
|
56
96
|
end
|
97
|
+
|
98
|
+
# Delete an org secret
|
99
|
+
#
|
100
|
+
# @param org [String] A GitHub organization
|
101
|
+
# @param name [String] Name of secret
|
102
|
+
# @see https://developer.github.com/v3/actions/secrets/#delete-a-secret
|
103
|
+
def delete_org_actions_secret(org, name)
|
104
|
+
boolean_from_response :delete, "#{Organization.path org}/actions/secrets/#{name}"
|
105
|
+
end
|
106
|
+
|
107
|
+
# Get environment public key for secrets encryption
|
108
|
+
#
|
109
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
110
|
+
# @param environment [String] Name of environment
|
111
|
+
# @return [Hash] key_id and key
|
112
|
+
# @see https://docs.github.com/en/rest/actions/secrets#get-an-environment-public-key
|
113
|
+
def get_actions_environment_public_key(repo, environment)
|
114
|
+
get "#{Repository.path repo}/environments/#{environment}/secrets/public-key"
|
115
|
+
end
|
116
|
+
|
117
|
+
# List environment secrets
|
118
|
+
#
|
119
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
120
|
+
# @param environment [String] Name of environment
|
121
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
122
|
+
# @see https://developer.github.com/v3/actions/secrets/#list-environment-secrets
|
123
|
+
def list_actions_environment_secrets(repo, environment)
|
124
|
+
paginate "#{Repository.path repo}/environments/#{environment}/secrets" do |data, last_response|
|
125
|
+
data.secrets.concat last_response.data.secrets
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# Get an environment secret
|
130
|
+
#
|
131
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
132
|
+
# @param environment [String] Name of environment
|
133
|
+
# @param name [String] Name of secret
|
134
|
+
# @return [Hash] name, created_at and updated_at
|
135
|
+
# @see https://docs.github.com/en/rest/actions/secrets#get-an-environment-secret
|
136
|
+
def get_actions_environment_secret(repo, environment, name)
|
137
|
+
get "#{Repository.path repo}/environments/#{environment}/secrets/#{name}"
|
138
|
+
end
|
139
|
+
|
140
|
+
# Create or update an environment secret
|
141
|
+
#
|
142
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
143
|
+
# @param environment [String] Name of environment
|
144
|
+
# @param name [String] Name of secret
|
145
|
+
# @param options [Hash] encrypted_value and key_id
|
146
|
+
# @see https://docs.github.com/en/rest/actions/secrets#create-or-update-an-environment-secret
|
147
|
+
def create_or_update_actions_environment_secret(repo, environment, name, options)
|
148
|
+
put "#{Repository.path repo}/environments/#{environment}/secrets/#{name}", options
|
149
|
+
end
|
150
|
+
|
151
|
+
# Delete environment secret
|
152
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
153
|
+
# @param environment [String] Name of environment
|
154
|
+
# @param name [String] Name of secret
|
155
|
+
# @see https://docs.github.com/en/rest/actions/secrets#delete-an-environment-secret
|
156
|
+
def delete_actions_environment_secret(repo, environment, name)
|
157
|
+
boolean_from_response :delete, "#{Repository.path repo}/environments/#{environment}/secrets/#{name}"
|
158
|
+
end
|
57
159
|
end
|
58
160
|
end
|
59
161
|
end
|
data/lib/octokit/client/apps.rb
CHANGED
@@ -217,6 +217,31 @@ module Octokit
|
|
217
217
|
def delete_installation(installation, options = {})
|
218
218
|
boolean_from_response :delete, "app/installations/#{installation}", options
|
219
219
|
end
|
220
|
+
|
221
|
+
# Returns a list of webhook deliveries for the webhook configured for a GitHub App.
|
222
|
+
#
|
223
|
+
# @param options [Hash] A customizable set of options
|
224
|
+
#
|
225
|
+
# @see https://docs.github.com/en/rest/apps/webhooks#list-deliveries-for-an-app-webhook
|
226
|
+
#
|
227
|
+
# @return [Array<Hash>] an array of hook deliveries
|
228
|
+
def list_app_hook_deliveries(options = {})
|
229
|
+
paginate('app/hook/deliveries', options) do |data, last_response|
|
230
|
+
data.concat last_response.data
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
# Redeliver a delivery for the webhook configured for a GitHub App.
|
235
|
+
#
|
236
|
+
# @param delivery_id [Integer] The id of a GitHub App Hook Delivery
|
237
|
+
# @param options [Hash] A customizable set of options
|
238
|
+
#
|
239
|
+
# @see https://developer.github.com/v3/apps/#redeliver-a-delivery-for-an-app-webhook
|
240
|
+
#
|
241
|
+
# @return [Boolean] Success
|
242
|
+
def deliver_app_hook(delivery_id, options = {})
|
243
|
+
boolean_from_response :post, "app/hook/deliveries/#{delivery_id}/attempts", options
|
244
|
+
end
|
220
245
|
end
|
221
246
|
end
|
222
247
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'base64'
|
4
|
+
require 'tempfile'
|
5
|
+
require 'zlib'
|
6
|
+
|
7
|
+
module Octokit
|
8
|
+
class Client
|
9
|
+
# Methods for the code scanning alerts API
|
10
|
+
#
|
11
|
+
# @see https://docs.github.com/rest/code-scanning
|
12
|
+
module CodeScanning
|
13
|
+
# Uploads SARIF data containing the results of a code scanning analysis
|
14
|
+
#
|
15
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
16
|
+
# @param file [String] Path to the SARIF file to upload
|
17
|
+
# @param sha [String] The SHA of the commit to which the analysis you are uploading relates
|
18
|
+
# @param ref [String] The full Git reference, formatted as `refs/heads/<branch name>`, `refs/pull/<number>/merge`, or `refs/pull/<number>/head`
|
19
|
+
#
|
20
|
+
# @return [Sawyer::Resource] SARIF upload information
|
21
|
+
# @see https://docs.github.com/rest/code-scanning#upload-an-analysis-as-sarif-data
|
22
|
+
def upload_sarif_data(repo, file, sha, ref, options = {})
|
23
|
+
options[:sarif] = compress_sarif_data(file)
|
24
|
+
options[:commit_sha] = sha
|
25
|
+
options[:ref] = ref
|
26
|
+
|
27
|
+
post "#{Repository.path repo}/code-scanning/sarifs", options
|
28
|
+
end
|
29
|
+
|
30
|
+
# Gets information about a SARIF upload
|
31
|
+
#
|
32
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
33
|
+
# @param sarif_id [String] The SARIF ID obtained after uploading
|
34
|
+
#
|
35
|
+
# @return [Sawyer::Resource] SARIF upload information
|
36
|
+
# @see https://docs.github.com/rest/code-scanning#get-information-about-a-sarif-upload
|
37
|
+
def get_sarif_upload_information(repo, sarif_id, options = {})
|
38
|
+
get "#{Repository.path repo}/code-scanning/sarifs/#{sarif_id}", options
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def compress_sarif_data(file)
|
44
|
+
Tempfile.create('sarif.gz') do |tempfile|
|
45
|
+
Zlib::GzipWriter.open(tempfile) do |gz_file|
|
46
|
+
gz_file.write File.binread(file)
|
47
|
+
end
|
48
|
+
Base64.strict_encode64(tempfile.read)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Codespaces Secrets API
|
6
|
+
#
|
7
|
+
# @see https://docs.github.com/en/rest/codespaces/
|
8
|
+
module CodespacesSecrets
|
9
|
+
# Get public key for secrets encryption
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
|
+
# @return [Hash] key_id and key
|
13
|
+
# @see https://docs.github.com/en/rest/codespaces/repository-secrets#get-a-repository-public-key
|
14
|
+
def get_codespaces_public_key(repo)
|
15
|
+
get "#{Repository.path repo}/codespaces/secrets/public-key"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Get public key for secrets encryption
|
19
|
+
#
|
20
|
+
# @param org [String] A GitHub organization
|
21
|
+
# @return [Hash] key_id and key
|
22
|
+
# @see https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#get-an-organization-public-key
|
23
|
+
def get_org_codespaces_public_key(org)
|
24
|
+
get "#{Organization.path org}/codespaces/secrets/public-key"
|
25
|
+
end
|
26
|
+
|
27
|
+
# List secrets
|
28
|
+
#
|
29
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
30
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
31
|
+
# @see https://docs.github.com/en/rest/codespaces/repository-secrets?apiVersion=2022-11-28#list-repository-secrets
|
32
|
+
def list_codespaces_secrets(repo)
|
33
|
+
paginate "#{Repository.path repo}/codespaces/secrets" do |data, last_response|
|
34
|
+
data.secrets.concat last_response.data.secrets
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# List org secrets
|
39
|
+
#
|
40
|
+
# @param org [String] A GitHub organization
|
41
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
42
|
+
# @see https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#list-organization-secrets
|
43
|
+
def list_org_codespaces_secrets(org)
|
44
|
+
paginate "#{Organization.path org}/codespaces/secrets" do |data, last_response|
|
45
|
+
data.secrets.concat last_response.data.secrets
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Get a secret
|
50
|
+
#
|
51
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
52
|
+
# @param name [String] Name of secret
|
53
|
+
# @return [Hash] name, created_at, updated_at, and visibility
|
54
|
+
# @see https://docs.github.com/en/rest/codespaces/repository-secrets?apiVersion=2022-11-28#get-a-repository-secret
|
55
|
+
def get_codespaces_secret(repo, name)
|
56
|
+
get "#{Repository.path repo}/codespaces/secrets/#{name}"
|
57
|
+
end
|
58
|
+
|
59
|
+
# Get an org secret
|
60
|
+
#
|
61
|
+
# @param org [String] A GitHub organization
|
62
|
+
# @param name [String] Name of secret
|
63
|
+
# @return [Hash] name, created_at, updated_at, and visibility
|
64
|
+
# @see https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#get-an-organization-secret
|
65
|
+
def get_org_codespaces_secret(org, name)
|
66
|
+
get "#{Organization.path org}/codespaces/secrets/#{name}"
|
67
|
+
end
|
68
|
+
|
69
|
+
# Create or update secrets
|
70
|
+
#
|
71
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
72
|
+
# @param name [String] Name of secret
|
73
|
+
# @param options [Hash] encrypted_value and key_id
|
74
|
+
# @see https://docs.github.com/en/rest/codespaces/repository-secrets?apiVersion=2022-11-28#create-or-update-a-repository-secret
|
75
|
+
def create_or_update_codespaces_secret(repo, name, options)
|
76
|
+
put "#{Repository.path repo}/codespaces/secrets/#{name}", options
|
77
|
+
end
|
78
|
+
|
79
|
+
# Create or update org secrets
|
80
|
+
#
|
81
|
+
# @param org [String] A GitHub organization
|
82
|
+
# @param name [String] Name of secret
|
83
|
+
# @param options [Hash] encrypted_value and key_id
|
84
|
+
# @see https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#create-or-update-an-organization-secret
|
85
|
+
def create_or_update_org_codespaces_secret(org, name, options)
|
86
|
+
put "#{Organization.path org}/codespaces/secrets/#{name}", options
|
87
|
+
end
|
88
|
+
|
89
|
+
# Delete a secret
|
90
|
+
#
|
91
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
92
|
+
# @param name [String] Name of secret
|
93
|
+
# @see https://docs.github.com/en/rest/codespaces/repository-secrets?apiVersion=2022-11-28#delete-a-repository-secret
|
94
|
+
def delete_codespaces_secret(repo, name)
|
95
|
+
boolean_from_response :delete, "#{Repository.path repo}/codespaces/secrets/#{name}"
|
96
|
+
end
|
97
|
+
|
98
|
+
# Delete an org secret
|
99
|
+
#
|
100
|
+
# @param org [String] A GitHub organization
|
101
|
+
# @param name [String] Name of secret
|
102
|
+
# @see https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#delete-an-organization-secret
|
103
|
+
def delete_org_codespaces_secret(org, name)
|
104
|
+
boolean_from_response :delete, "#{Organization.path org}/codespaces/secrets/#{name}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the dependabot Secrets API
|
6
|
+
#
|
7
|
+
# @see https://docs.github.com/en/rest/dependabot/
|
8
|
+
module DependabotSecrets
|
9
|
+
# Get public key for secrets encryption
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
|
+
# @return [Hash] key_id and key
|
13
|
+
# @see https://docs.github.com/en/rest/dependabot/repository-secrets#get-a-repository-public-key
|
14
|
+
def get_dependabot_public_key(repo)
|
15
|
+
get "#{Repository.path repo}/dependabot/secrets/public-key"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Get public key for secrets encryption
|
19
|
+
#
|
20
|
+
# @param org [String] A GitHub organization
|
21
|
+
# @return [Hash] key_id and key
|
22
|
+
# @see https://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#get-an-organization-public-key
|
23
|
+
def get_org_dependabot_public_key(org)
|
24
|
+
get "#{Organization.path org}/dependabot/secrets/public-key"
|
25
|
+
end
|
26
|
+
|
27
|
+
# List secrets
|
28
|
+
#
|
29
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
30
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
31
|
+
# @see https://docs.github.com/en/rest/dependabot/repository-secrets?apiVersion=2022-11-28#list-repository-secrets
|
32
|
+
def list_dependabot_secrets(repo)
|
33
|
+
paginate "#{Repository.path repo}/dependabot/secrets" do |data, last_response|
|
34
|
+
data.secrets.concat last_response.data.secrets
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# List org secrets
|
39
|
+
#
|
40
|
+
# @param org [String] A GitHub organization
|
41
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
42
|
+
# @see https://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#list-organization-secrets
|
43
|
+
def list_org_dependabot_secrets(org)
|
44
|
+
paginate "#{Organization.path org}/dependabot/secrets" do |data, last_response|
|
45
|
+
data.secrets.concat last_response.data.secrets
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Get a secret
|
50
|
+
#
|
51
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
52
|
+
# @param name [String] Name of secret
|
53
|
+
# @return [Hash] name, created_at, updated_at, and visibility
|
54
|
+
# @see https://docs.github.com/en/rest/dependabot/repository-secrets?apiVersion=2022-11-28#get-a-repository-secret
|
55
|
+
def get_dependabot_secret(repo, name)
|
56
|
+
get "#{Repository.path repo}/dependabot/secrets/#{name}"
|
57
|
+
end
|
58
|
+
|
59
|
+
# Get an org secret
|
60
|
+
#
|
61
|
+
# @param org [String] A GitHub organization
|
62
|
+
# @param name [String] Name of secret
|
63
|
+
# @return [Hash] name, created_at, updated_at, and visibility
|
64
|
+
# @see https://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#get-an-organization-secret
|
65
|
+
def get_org_dependabot_secret(org, name)
|
66
|
+
get "#{Organization.path org}/dependabot/secrets/#{name}"
|
67
|
+
end
|
68
|
+
|
69
|
+
# Create or update secrets
|
70
|
+
#
|
71
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
72
|
+
# @param name [String] Name of secret
|
73
|
+
# @param options [Hash] encrypted_value and key_id
|
74
|
+
# @see https://docs.github.com/en/rest/dependabot/repository-secrets?apiVersion=2022-11-28#create-or-update-a-repository-secret
|
75
|
+
def create_or_update_dependabot_secret(repo, name, options)
|
76
|
+
put "#{Repository.path repo}/dependabot/secrets/#{name}", options
|
77
|
+
end
|
78
|
+
|
79
|
+
# Create or update org secrets
|
80
|
+
#
|
81
|
+
# @param org [String] A GitHub organization
|
82
|
+
# @param name [String] Name of secret
|
83
|
+
# @param options [Hash] encrypted_value and key_id
|
84
|
+
# @see https://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#create-or-update-an-organization-secret
|
85
|
+
def create_or_update_org_dependabot_secret(org, name, options)
|
86
|
+
put "#{Organization.path org}/dependabot/secrets/#{name}", options
|
87
|
+
end
|
88
|
+
|
89
|
+
# Delete a secret
|
90
|
+
#
|
91
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
92
|
+
# @param name [String] Name of secret
|
93
|
+
# @see https://docs.github.com/en/rest/dependabot/repository-secrets?apiVersion=2022-11-28#delete-a-repository-secret
|
94
|
+
def delete_dependabot_secret(repo, name)
|
95
|
+
boolean_from_response :delete, "#{Repository.path repo}/dependabot/secrets/#{name}"
|
96
|
+
end
|
97
|
+
|
98
|
+
# Delete an org secret
|
99
|
+
#
|
100
|
+
# @param org [String] A GitHub organization
|
101
|
+
# @param name [String] Name of secret
|
102
|
+
# @see https://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#delete-an-organization-secret
|
103
|
+
def delete_org_dependabot_secret(org, name)
|
104
|
+
boolean_from_response :delete, "#{Organization.path org}/dependabot/secrets/#{name}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -22,7 +22,7 @@ module Octokit
|
|
22
22
|
# @return [Array<Sawyer::Resource>] A list of deployments
|
23
23
|
# @see https://developer.github.com/v3/repos/deployments/#list-deployments
|
24
24
|
def deployments(repo, options = {})
|
25
|
-
|
25
|
+
paginate("#{Repository.path repo}/deployments", options)
|
26
26
|
end
|
27
27
|
alias list_deployments deployments
|
28
28
|
|
@@ -60,7 +60,7 @@ module Octokit
|
|
60
60
|
# @see https://developer.github.com/v3/repos/deployments/#list-deployment-statuses
|
61
61
|
def deployment_statuses(deployment_url, options = {})
|
62
62
|
deployment = get(deployment_url, accept: options[:accept])
|
63
|
-
|
63
|
+
paginate(deployment.rels[:statuses].href, options)
|
64
64
|
end
|
65
65
|
alias list_deployment_statuses deployment_statuses
|
66
66
|
|
@@ -65,7 +65,7 @@ module Octokit
|
|
65
65
|
#
|
66
66
|
# @example
|
67
67
|
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
68
|
-
# client.
|
68
|
+
# client.delete_app_token('deadbeef1234567890deadbeef987654321')
|
69
69
|
def delete_app_token(access_token, options = {})
|
70
70
|
options[:access_token] = access_token
|
71
71
|
|
@@ -71,7 +71,7 @@ module Octokit
|
|
71
71
|
# Nonauthenticated calls to this method will return organizations that
|
72
72
|
# the user is a public member.
|
73
73
|
#
|
74
|
-
# Use an
|
74
|
+
# Use an authenticated client to get both public and private organizations
|
75
75
|
# for a user.
|
76
76
|
#
|
77
77
|
# Calling this method on a `@client` will return that users organizations.
|
@@ -197,18 +197,21 @@ module Octokit
|
|
197
197
|
# @param body [String] Comment content
|
198
198
|
# @param commit_id [String] Sha of the commit to comment on.
|
199
199
|
# @param path [String] Relative path of the file to comment on.
|
200
|
-
# @param
|
200
|
+
# @param line [Integer] Line index in the diff to comment on.
|
201
|
+
# For a multi-line comment, the last line of the range
|
202
|
+
# and specify 'start_line' in the 'options'.
|
201
203
|
# @return [Sawyer::Resource] Hash representing the new comment
|
204
|
+
# @deprecated The position will be deprecated in the next major version. Please refer to the details below.
|
202
205
|
# @see https://developer.github.com/v3/pulls/comments/#create-a-comment
|
203
206
|
# @example
|
204
207
|
# @client.create_pull_request_comment("octokit/octokit.rb", 163, ":shipit:",
|
205
208
|
# "2d3201e4440903d8b04a5487842053ca4883e5f0", "lib/octokit/request.rb", 47)
|
206
|
-
def create_pull_request_comment(repo, pull_id, body, commit_id, path,
|
209
|
+
def create_pull_request_comment(repo, pull_id, body, commit_id, path, line, options = {})
|
207
210
|
options.merge!({
|
208
211
|
body: body,
|
209
212
|
commit_id: commit_id,
|
210
213
|
path: path,
|
211
|
-
|
214
|
+
line: line
|
212
215
|
})
|
213
216
|
post "#{Repository.path repo}/pulls/#{pull_id}/comments", options
|
214
217
|
end
|
@@ -137,16 +137,67 @@ module Octokit
|
|
137
137
|
|
138
138
|
# Delete a reaction
|
139
139
|
#
|
140
|
-
# @param
|
140
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
141
|
+
# @param issue_id [Integer] The Issue comment id
|
142
|
+
# @param reaction_id [Integer] The Reaction id
|
143
|
+
#
|
144
|
+
# @see https://docs.github.com/en/rest/reactions/reactions#delete-an-issue-reaction
|
145
|
+
#
|
146
|
+
# @example
|
147
|
+
# @client.delete_issue_reaction("octokit/octokit.rb", 1, 2)
|
148
|
+
#
|
149
|
+
# @return [Boolean] Return true if reaction was deleted, false otherwise.
|
150
|
+
def delete_issue_reaction(repo, issue_id, reaction_id, options = {})
|
151
|
+
boolean_from_response :delete, "#{Repository.path repo}/issues/#{issue_id}/reactions/#{reaction_id}", options
|
152
|
+
end
|
153
|
+
|
154
|
+
# List reactions for a release
|
155
|
+
#
|
156
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
157
|
+
# @param id [Integer] The Release id
|
158
|
+
#
|
159
|
+
# @see https://docs.github.com/en/free-pro-team@latest/rest/reactions/reactions?apiVersion=2022-11-28#list-reactions-for-a-release
|
160
|
+
#
|
161
|
+
# @example
|
162
|
+
# @client.release_reactions("octokit/octokit.rb", 1)
|
163
|
+
#
|
164
|
+
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
|
165
|
+
def release_reactions(repo, release_id, options = {})
|
166
|
+
get "#{Repository.path repo}/releases/#{release_id}/reactions", options
|
167
|
+
end
|
168
|
+
|
169
|
+
# Create reaction for a release
|
170
|
+
#
|
171
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
172
|
+
# @param id [Integer] The Release id
|
173
|
+
# @param reaction [String] The Reaction
|
174
|
+
#
|
175
|
+
# @see https://docs.github.com/en/free-pro-team@latest/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-a-release
|
176
|
+
# @see https://developer.github.com/v3/reactions/#reaction-types
|
177
|
+
#
|
178
|
+
# @example
|
179
|
+
# @client.create_release_reaction("octokit/octokit.rb", 1)
|
180
|
+
#
|
181
|
+
# @return [<Sawyer::Resource>] Hash representing the reaction.
|
182
|
+
def create_release_reaction(repo, release_id, reaction, options = {})
|
183
|
+
options = options.merge(content: reaction)
|
184
|
+
post "#{Repository.path repo}/releases/#{release_id}/reactions", options
|
185
|
+
end
|
186
|
+
|
187
|
+
# Delete a reaction for a release
|
188
|
+
#
|
189
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
190
|
+
# @param issue_id [Integer] The Release id
|
191
|
+
# @param reaction_id [Integer] The Reaction id
|
141
192
|
#
|
142
|
-
# @see https://
|
193
|
+
# @see https://docs.github.com/en/free-pro-team@latest/rest/reactions/reactions?apiVersion=2022-11-28#delete-a-release-reaction
|
143
194
|
#
|
144
195
|
# @example
|
145
|
-
# @client.
|
196
|
+
# @client.delete_release_reaction("octokit/octokit.rb", 1, 2)
|
146
197
|
#
|
147
198
|
# @return [Boolean] Return true if reaction was deleted, false otherwise.
|
148
|
-
def
|
149
|
-
boolean_from_response :delete, "reactions/#{
|
199
|
+
def delete_release_reaction(repo, release_id, reaction_id, options = {})
|
200
|
+
boolean_from_response :delete, "#{Repository.path repo}/releases/#{release_id}/reactions/#{reaction_id}", options
|
150
201
|
end
|
151
202
|
end
|
152
203
|
end
|
@@ -151,7 +151,7 @@ module Octokit
|
|
151
151
|
# @param number [Integer] Number ID of the pull request
|
152
152
|
# @param reviewers [Hash] :reviewers [Array<String>] An array of user logins
|
153
153
|
# @param options [Hash] :team_reviewers [Array<String>] An array of team slugs
|
154
|
-
# @see https://developer.github.com/v3/pulls/review_requests/#
|
154
|
+
# @see https://developer.github.com/v3/pulls/review_requests/#request-reviewers-for-a-pull-request
|
155
155
|
#
|
156
156
|
# @example
|
157
157
|
# @client.request_pull_request_review('octokit/octokit.rb', 2, reviewers: ['soudy'])
|
data/lib/octokit/client/users.rb
CHANGED
@@ -57,6 +57,33 @@ module Octokit
|
|
57
57
|
post "#{web_endpoint}login/oauth/access_token", options
|
58
58
|
end
|
59
59
|
|
60
|
+
# Refresh a user's access token with a refresh token.
|
61
|
+
#
|
62
|
+
# Applications can refresh an access token without requiring a user to re-authorize using refresh access token.
|
63
|
+
#
|
64
|
+
# @param code [String] 40 character GitHub OAuth refresh access token
|
65
|
+
#
|
66
|
+
# @return [Sawyer::Resource]
|
67
|
+
# @see https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/refreshing-user-access-tokens#refreshing-a-user-access-token-with-a-refresh-token
|
68
|
+
#
|
69
|
+
# @example
|
70
|
+
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
71
|
+
# client.refresh_access_token('40-character-refresh-token')
|
72
|
+
def refresh_access_token(code, app_id = client_id, app_secret = client_secret, options = {})
|
73
|
+
options = options.merge({
|
74
|
+
refresh_token: code,
|
75
|
+
client_id: app_id,
|
76
|
+
client_secret: app_secret,
|
77
|
+
grant_type: 'refresh_token',
|
78
|
+
headers: {
|
79
|
+
content_type: 'application/json',
|
80
|
+
accept: 'application/json'
|
81
|
+
}
|
82
|
+
})
|
83
|
+
|
84
|
+
post "#{web_endpoint}login/oauth/access_token", options
|
85
|
+
end
|
86
|
+
|
60
87
|
# Validate user username and password
|
61
88
|
#
|
62
89
|
# @param options [Hash] User credentials
|
data/lib/octokit/client.rb
CHANGED
@@ -18,6 +18,8 @@ require 'octokit/client/actions_workflow_jobs'
|
|
18
18
|
require 'octokit/client/actions_workflow_runs'
|
19
19
|
require 'octokit/client/apps'
|
20
20
|
require 'octokit/client/checks'
|
21
|
+
require 'octokit/client/code_scanning'
|
22
|
+
require 'octokit/client/codespaces_secrets'
|
21
23
|
require 'octokit/client/commits'
|
22
24
|
require 'octokit/client/commit_comments'
|
23
25
|
require 'octokit/client/commit_pulls'
|
@@ -25,6 +27,7 @@ require 'octokit/client/commit_branches'
|
|
25
27
|
require 'octokit/client/community_profile'
|
26
28
|
require 'octokit/client/contents'
|
27
29
|
require 'octokit/client/downloads'
|
30
|
+
require 'octokit/client/dependabot_secrets'
|
28
31
|
require 'octokit/client/deployments'
|
29
32
|
require 'octokit/client/environments'
|
30
33
|
require 'octokit/client/emojis'
|
@@ -79,12 +82,15 @@ module Octokit
|
|
79
82
|
include Octokit::Client::ActionsArtifacts
|
80
83
|
include Octokit::Client::ActionsSecrets
|
81
84
|
include Octokit::Client::Checks
|
85
|
+
include Octokit::Client::CodeScanning
|
86
|
+
include Octokit::Client::CodespacesSecrets
|
82
87
|
include Octokit::Client::Commits
|
83
88
|
include Octokit::Client::CommitComments
|
84
89
|
include Octokit::Client::CommitPulls
|
85
90
|
include Octokit::Client::CommitBranches
|
86
91
|
include Octokit::Client::CommunityProfile
|
87
92
|
include Octokit::Client::Contents
|
93
|
+
include Octokit::Client::DependabotSecrets
|
88
94
|
include Octokit::Client::Deployments
|
89
95
|
include Octokit::Client::Downloads
|
90
96
|
include Octokit::Client::Environments
|
data/lib/octokit/repository.rb
CHANGED
data/lib/octokit/version.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Octokit
|
4
4
|
# Current major release.
|
5
5
|
# @return [Integer]
|
6
|
-
MAJOR =
|
6
|
+
MAJOR = 8
|
7
7
|
|
8
8
|
# Current minor release.
|
9
9
|
# @return [Integer]
|
@@ -11,7 +11,7 @@ module Octokit
|
|
11
11
|
|
12
12
|
# Current patch level.
|
13
13
|
# @return [Integer]
|
14
|
-
PATCH =
|
14
|
+
PATCH = 0
|
15
15
|
|
16
16
|
# Full release version.
|
17
17
|
# @return [String]
|
data/octokit.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
require 'octokit/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.
|
8
|
+
spec.add_dependency 'base64'
|
9
9
|
spec.add_dependency 'faraday', '>= 1', '< 3'
|
10
10
|
spec.add_dependency 'sawyer', '~> 0.9'
|
11
11
|
spec.authors = ['Wynn Netherland', 'Erik Michaels-Ober', 'Clint Shryock']
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octokit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 8.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wynn Netherland
|
@@ -10,28 +10,22 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2024-02-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: base64
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
22
|
-
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: '3'
|
25
|
-
type: :development
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
26
23
|
prerelease: false
|
27
24
|
version_requirements: !ruby/object:Gem::Requirement
|
28
25
|
requirements:
|
29
26
|
- - ">="
|
30
27
|
- !ruby/object:Gem::Version
|
31
|
-
version: '
|
32
|
-
- - "<"
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '3'
|
28
|
+
version: '0'
|
35
29
|
- !ruby/object:Gem::Dependency
|
36
30
|
name: faraday
|
37
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,12 +86,15 @@ files:
|
|
92
86
|
- lib/octokit/client/actions_workflows.rb
|
93
87
|
- lib/octokit/client/apps.rb
|
94
88
|
- lib/octokit/client/checks.rb
|
89
|
+
- lib/octokit/client/code_scanning.rb
|
90
|
+
- lib/octokit/client/codespaces_secrets.rb
|
95
91
|
- lib/octokit/client/commit_branches.rb
|
96
92
|
- lib/octokit/client/commit_comments.rb
|
97
93
|
- lib/octokit/client/commit_pulls.rb
|
98
94
|
- lib/octokit/client/commits.rb
|
99
95
|
- lib/octokit/client/community_profile.rb
|
100
96
|
- lib/octokit/client/contents.rb
|
97
|
+
- lib/octokit/client/dependabot_secrets.rb
|
101
98
|
- lib/octokit/client/deployments.rb
|
102
99
|
- lib/octokit/client/downloads.rb
|
103
100
|
- lib/octokit/client/emojis.rb
|
@@ -184,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
181
|
- !ruby/object:Gem::Version
|
185
182
|
version: 1.3.5
|
186
183
|
requirements: []
|
187
|
-
rubygems_version: 3.
|
184
|
+
rubygems_version: 3.4.20
|
188
185
|
signing_key:
|
189
186
|
specification_version: 4
|
190
187
|
summary: Ruby toolkit for working with the GitHub API
|