octokit 4.6.0 → 4.21.0
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 +141 -60
- data/lib/ext/sawyer/relation.rb +10 -0
- data/lib/octokit/authentication.rb +10 -11
- data/lib/octokit/client/actions_secrets.rb +58 -0
- data/lib/octokit/client/actions_workflow_runs.rb +105 -0
- data/lib/octokit/client/actions_workflows.rb +43 -0
- data/lib/octokit/client/apps.rb +222 -0
- data/lib/octokit/client/authorizations.rb +12 -74
- data/lib/octokit/client/checks.rb +191 -0
- data/lib/octokit/client/commit_branches.rb +20 -0
- data/lib/octokit/client/commit_pulls.rb +20 -0
- data/lib/octokit/client/community_profile.rb +22 -0
- data/lib/octokit/client/contents.rb +6 -0
- data/lib/octokit/client/deployments.rb +20 -0
- data/lib/octokit/client/events.rb +1 -0
- data/lib/octokit/client/gists.rb +3 -2
- data/lib/octokit/client/issues.rb +48 -1
- data/lib/octokit/client/labels.rb +7 -7
- data/lib/octokit/client/licenses.rb +1 -1
- data/lib/octokit/client/marketplace.rb +56 -0
- data/lib/octokit/client/notifications.rb +0 -4
- data/lib/octokit/client/oauth_applications.rb +122 -0
- data/lib/octokit/client/organizations.rb +149 -16
- data/lib/octokit/client/projects.rb +7 -7
- data/lib/octokit/client/pull_requests.rb +7 -5
- data/lib/octokit/client/rate_limit.rb +2 -2
- data/lib/octokit/client/refs.rb +19 -3
- data/lib/octokit/client/releases.rb +1 -0
- data/lib/octokit/client/repositories.rb +169 -8
- data/lib/octokit/client/repository_invitations.rb +1 -8
- data/lib/octokit/client/reviews.rb +227 -0
- data/lib/octokit/client/search.rb +24 -9
- data/lib/octokit/client/source_import.rb +1 -1
- data/lib/octokit/client/stats.rb +2 -0
- data/lib/octokit/client/statuses.rb +2 -2
- data/lib/octokit/client/users.rb +88 -1
- data/lib/octokit/client.rb +41 -9
- data/lib/octokit/configurable.rb +10 -2
- data/lib/octokit/connection.rb +19 -4
- data/lib/octokit/default.rb +17 -1
- data/lib/octokit/enterprise_admin_client/admin_stats.rb +1 -1
- data/lib/octokit/enterprise_admin_client/license.rb +1 -1
- data/lib/octokit/enterprise_admin_client/orgs.rb +2 -2
- data/lib/octokit/enterprise_admin_client/search_indexing.rb +1 -1
- data/lib/octokit/enterprise_admin_client/users.rb +12 -12
- data/lib/octokit/enterprise_management_console_client/management_console.rb +1 -1
- data/lib/octokit/enterprise_management_console_client.rb +1 -1
- data/lib/octokit/error.rb +74 -4
- data/lib/octokit/gist.rb +1 -1
- data/lib/octokit/middleware/follow_redirects.rb +2 -2
- data/lib/octokit/preview.rb +14 -3
- data/lib/octokit/rate_limit.rb +4 -4
- data/lib/octokit/repository.rb +10 -8
- data/lib/octokit/response/feed_parser.rb +0 -2
- data/lib/octokit/response/raise_error.rb +0 -2
- data/lib/octokit/version.rb +1 -1
- data/octokit.gemspec +2 -1
- metadata +39 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: be4c54d083639a915bef0eb235748b93351f17f2a98e204b7b9f2899c156f2f6
|
4
|
+
data.tar.gz: 21998779cea8f95e63b1814dc264102c1ac69c9d66fef6694ef6442554419bbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14221c5912859f6fa1a9f3dce7d7ee1cb6b5730bc1a95c997e84ff2972f23a3e8eaad723acbabd57982afadc1f4bb1538af510bd10583e21e0f208c7712ce1e6
|
7
|
+
data.tar.gz: 23300ee9b4e73fc660a391018efbc969742dbdc9740faa57ed7609853830689cc1edcca8d445df2d939f2d7353056f828b53ad44b33269573ed06a8e93b8dbd4
|
data/CONTRIBUTING.md
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
## Submitting a Pull Request
|
2
2
|
|
3
|
-
0.
|
4
|
-
|
5
|
-
|
6
|
-
2. [
|
7
|
-
3.
|
8
|
-
4.
|
9
|
-
5.
|
10
|
-
6.
|
11
|
-
7. Run `
|
3
|
+
0. Read our [Code of Conduct](CODE_OF_CONDUCT.md).
|
4
|
+
1. Check out [Hacking on Octokit](README.md#hacking-on-octokitrb) in the
|
5
|
+
README for bootstrapping the project for local development.
|
6
|
+
2. [Fork the repository.][fork]
|
7
|
+
3. [Create a topic branch.][branch]
|
8
|
+
4. Add specs for your unimplemented feature or bug fix.
|
9
|
+
5. Run `script/test`. If your specs pass, return to step 3.
|
10
|
+
6. Implement your feature or bug fix.
|
11
|
+
7. Run `script/test`. If your specs fail, return to step 5.
|
12
|
+
8. Run `open coverage/index.html`. If your changes are not completely covered
|
12
13
|
by your tests, return to step 4.
|
13
|
-
|
14
|
-
|
14
|
+
9. Add documentation for your feature or bug fix.
|
15
|
+
10. Run `bundle exec rake doc:yard`. If your changes are not 100% documented, go
|
15
16
|
back to step 8.
|
16
|
-
|
17
|
+
11. Add, commit, and push your changes. For documentation-only fixes, please
|
17
18
|
add "[ci skip]" to your commit message to avoid needless CI builds.
|
18
|
-
|
19
|
+
12. [Submit a pull request.][pr]
|
19
20
|
|
20
21
|
[fork]: https://help.github.com/articles/fork-a-repo
|
21
22
|
[branch]: https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
|
data/LICENSE.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2009-
|
1
|
+
Copyright (c) 2009-2017 Wynn Netherland, Adam Stacoviak, Erik Michaels-Ober
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
|
3
3
|
Ruby toolkit for the GitHub API.
|
4
4
|
|
5
|
-
![
|
6
|
-
[logo]: http://cl.ly/image/3Y013H0A2z3z/gundam-ruby.png
|
5
|
+
![logo](https://docs.github.com/assets/images/gundamcat.png)
|
7
6
|
|
8
7
|
Upgrading? Check the [Upgrade Guide](#upgrading-guide) before bumping to a new
|
9
8
|
[major version][semver].
|
@@ -31,6 +30,7 @@ Upgrading? Check the [Upgrade Guide](#upgrading-guide) before bumping to a new
|
|
31
30
|
10. [Configuration and defaults](#configuration-and-defaults)
|
32
31
|
1. [Configuring module defaults](#configuring-module-defaults)
|
33
32
|
2. [Using ENV variables](#using-env-variables)
|
33
|
+
3. [Timeouts](#timeouts)
|
34
34
|
11. [Hypermedia agent](#hypermedia-agent)
|
35
35
|
1. [Hypermedia in Octokit](#hypermedia-in-octokit)
|
36
36
|
2. [URI templates](#uri-templates)
|
@@ -41,10 +41,12 @@ Upgrading? Check the [Upgrade Guide](#upgrading-guide) before bumping to a new
|
|
41
41
|
1. [Debugging](#debugging)
|
42
42
|
2. [Caching](#caching)
|
43
43
|
14. [Hacking on Octokit.rb](#hacking-on-octokitrb)
|
44
|
-
1. [
|
44
|
+
1. [Code of Conduct](#code-of-conduct)
|
45
|
+
2. [Running and writing new tests](#running-and-writing-new-tests)
|
45
46
|
15. [Supported Ruby Versions](#supported-ruby-versions)
|
46
47
|
16. [Versioning](#versioning)
|
47
|
-
17. [
|
48
|
+
17. [Making Repeating Requests](#making-repeating-requests)
|
49
|
+
18. [License](#license)
|
48
50
|
|
49
51
|
## Philosophy
|
50
52
|
|
@@ -55,13 +57,14 @@ Most methods have positional arguments for required input and an options hash
|
|
55
57
|
for optional parameters, headers, or other options:
|
56
58
|
|
57
59
|
```ruby
|
60
|
+
client = Octokit::Client.new
|
61
|
+
|
58
62
|
# Fetch a README with Accept header for HTML format
|
59
|
-
|
63
|
+
client.readme 'al3x/sovereign', :accept => 'application/vnd.github.html'
|
60
64
|
```
|
61
65
|
|
62
|
-
|
63
66
|
[wrappers]: http://wynnnetherland.com/journal/what-makes-a-good-api-wrapper
|
64
|
-
[github-api]:
|
67
|
+
[github-api]: https://developer.github.com/v3/
|
65
68
|
|
66
69
|
## Quick start
|
67
70
|
|
@@ -73,28 +76,37 @@ Install via Rubygems
|
|
73
76
|
|
74
77
|
gem "octokit", "~> 4.0"
|
75
78
|
|
79
|
+
Access the library in Ruby:
|
80
|
+
|
81
|
+
require 'octokit'
|
82
|
+
|
76
83
|
### Making requests
|
77
84
|
|
78
|
-
[API methods][] are available as
|
79
|
-
configuration) or as client instance methods.
|
85
|
+
[API methods][] are available as client instance methods.
|
80
86
|
|
81
87
|
```ruby
|
82
88
|
# Provide authentication credentials
|
83
|
-
Octokit.
|
84
|
-
|
85
|
-
|
86
|
-
|
89
|
+
client = Octokit::Client.new(:access_token => 'personal_access_token')
|
90
|
+
|
91
|
+
# You can still use the username/password syntax by replacing the password value with your PAT.
|
92
|
+
# client = Octokit::Client.new(:login => 'defunkt', :password => 'personal_access_token')
|
87
93
|
|
88
94
|
# Fetch the current user
|
89
|
-
|
95
|
+
client.user
|
90
96
|
```
|
91
|
-
|
97
|
+
|
98
|
+
### Additional Query Parameters
|
99
|
+
|
100
|
+
When passing additional parameters to GET based request use the following syntax:
|
92
101
|
|
93
102
|
```ruby
|
94
|
-
#
|
95
|
-
|
96
|
-
|
97
|
-
|
103
|
+
# query: { parameter_name: 'value' }
|
104
|
+
# Example: Get repository listing by owner in ascending order
|
105
|
+
client.repos({}, query: {type: 'owner', sort: 'asc'})
|
106
|
+
|
107
|
+
# Example: Get contents of a repository by ref
|
108
|
+
# https://api.github.com/repos/octokit/octokit.rb/contents/path/to/file.rb?ref=some-other-branch
|
109
|
+
client.contents('octokit/octokit.rb', path: 'path/to/file.rb', query: {ref: 'some-other-branch'})
|
98
110
|
```
|
99
111
|
|
100
112
|
[API methods]: http://octokit.github.io/octokit.rb/method_list.html
|
@@ -105,8 +117,10 @@ Most methods return a `Resource` object which provides dot notation and `[]`
|
|
105
117
|
access for fields returned in the API response.
|
106
118
|
|
107
119
|
```ruby
|
120
|
+
client = Octokit::Client.new
|
121
|
+
|
108
122
|
# Fetch a user
|
109
|
-
user =
|
123
|
+
user = client.user 'jbarnette'
|
110
124
|
puts user.name
|
111
125
|
# => "John Barnette"
|
112
126
|
puts user.fields
|
@@ -127,8 +141,8 @@ need access to the raw HTTP response headers. You can access the last HTTP
|
|
127
141
|
response with `Client#last_response`:
|
128
142
|
|
129
143
|
```ruby
|
130
|
-
user =
|
131
|
-
response =
|
144
|
+
user = client.user 'andrewpthorp'
|
145
|
+
response = client.last_response
|
132
146
|
etag = response.headers[:etag]
|
133
147
|
```
|
134
148
|
|
@@ -143,9 +157,7 @@ Using your GitHub username and password is the easiest way to get started
|
|
143
157
|
making authenticated requests:
|
144
158
|
|
145
159
|
```ruby
|
146
|
-
client = Octokit::Client.new
|
147
|
-
:login => 'defunkt',
|
148
|
-
:password => 'c0d3b4ssssss!'
|
160
|
+
client = Octokit::Client.new(:login => 'defunkt', :password => 'c0d3b4ssssss!')
|
149
161
|
|
150
162
|
user = client.user
|
151
163
|
user.login
|
@@ -180,9 +192,7 @@ You can [create access tokens through your GitHub Account Settings](https://help
|
|
180
192
|
or with a basic authenticated Octokit client:
|
181
193
|
|
182
194
|
```ruby
|
183
|
-
client = Octokit::Client.new
|
184
|
-
:login => 'defunkt',
|
185
|
-
:password => 'c0d3b4ssssss!'
|
195
|
+
client = Octokit::Client.new(:login => 'defunkt', :password => 'c0d3b4ssssss!')
|
186
196
|
|
187
197
|
client.create_authorization(:scopes => ["user"], :note => "Name of token")
|
188
198
|
# => <your new oauth token>
|
@@ -263,6 +273,14 @@ user = client.user 'defunkt'
|
|
263
273
|
[access scopes]: http://developer.github.com/v3/oauth/#scopes
|
264
274
|
[app-creds]: http://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications
|
265
275
|
|
276
|
+
## Default results per_page
|
277
|
+
|
278
|
+
Default results from the GitHub API are 30, if you wish to add more you must do so during Octokit configuration.
|
279
|
+
|
280
|
+
```ruby
|
281
|
+
Octokit::Client.new(access_token: "<your 40 char token>", per_page: 100)
|
282
|
+
```
|
283
|
+
|
266
284
|
## Pagination
|
267
285
|
|
268
286
|
Many GitHub API resources are [paginated][]. While you may be tempted to start
|
@@ -271,8 +289,8 @@ previous, and last pages for you in the `Link` response header as [Hypermedia
|
|
271
289
|
link relations](#hypermedia-agent).
|
272
290
|
|
273
291
|
```ruby
|
274
|
-
issues =
|
275
|
-
issues.concat
|
292
|
+
issues = client.issues 'rails/rails'
|
293
|
+
issues.concat client.get(client.last_response.rels[:next].href)
|
276
294
|
```
|
277
295
|
|
278
296
|
### Auto pagination
|
@@ -282,13 +300,21 @@ enabled, calls for paginated resources will fetch and concatenate the results
|
|
282
300
|
from every page into a single array:
|
283
301
|
|
284
302
|
```ruby
|
285
|
-
|
286
|
-
issues =
|
303
|
+
client.auto_paginate = true
|
304
|
+
issues = client.issues 'rails/rails'
|
287
305
|
issues.length
|
288
306
|
|
289
307
|
# => 702
|
290
308
|
```
|
291
309
|
|
310
|
+
You can also enable auto pagination for all Octokit client instances:
|
311
|
+
|
312
|
+
```ruby
|
313
|
+
Octokit.configure do |c|
|
314
|
+
c.auto_paginate = true
|
315
|
+
end
|
316
|
+
```
|
317
|
+
|
292
318
|
**Note:** While Octokit auto pagination will set the page size to the maximum
|
293
319
|
`100`, and seek to not overstep your rate limit, you probably want to use a
|
294
320
|
custom pattern for traversing large lists.
|
@@ -297,7 +323,7 @@ custom pattern for traversing large lists.
|
|
297
323
|
|
298
324
|
## Working with GitHub Enterprise
|
299
325
|
|
300
|
-
With a bit of setup, you can also use Octokit with your
|
326
|
+
With a bit of setup, you can also use Octokit with your GitHub Enterprise instance.
|
301
327
|
|
302
328
|
### Interacting with the GitHub.com APIs in GitHub Enterprise
|
303
329
|
|
@@ -307,6 +333,7 @@ To interact with the "regular" GitHub.com APIs in GitHub Enterprise, simply conf
|
|
307
333
|
Octokit.configure do |c|
|
308
334
|
c.api_endpoint = "https://<hostname>/api/v3/"
|
309
335
|
end
|
336
|
+
|
310
337
|
client = Octokit::Client.new(:access_token => "<your 40 char token>")
|
311
338
|
```
|
312
339
|
|
@@ -315,16 +342,18 @@ client = Octokit::Client.new(:access_token => "<your 40 char token>")
|
|
315
342
|
The GitHub Enterprise Admin APIs are under a different client: `EnterpriseAdminClient`. You'll need to have an administrator account in order to use these APIs.
|
316
343
|
|
317
344
|
``` ruby
|
318
|
-
admin_client = Octokit::EnterpriseAdminClient.new
|
319
|
-
|
320
|
-
|
345
|
+
admin_client = Octokit::EnterpriseAdminClient.new(
|
346
|
+
:access_token => "<your 40 char token>",
|
347
|
+
:api_endpoint => "https://<hostname>/api/v3/"
|
348
|
+
)
|
321
349
|
|
322
350
|
# or
|
323
351
|
Octokit.configure do |c|
|
324
352
|
c.api_endpoint = "https://<hostname>/api/v3/"
|
325
353
|
c.access_token = "<your 40 char token>"
|
326
354
|
end
|
327
|
-
|
355
|
+
|
356
|
+
admin_client = Octokit.enterprise_admin_client.new
|
328
357
|
```
|
329
358
|
|
330
359
|
### Interacting with the GitHub Enterprise Management Console APIs
|
@@ -332,15 +361,18 @@ admin_client = Octokit.enterprise_admin_client
|
|
332
361
|
The GitHub Enterprise Management Console APIs are also under a separate client: `EnterpriseManagementConsoleClient`. In order to use it, you'll need to provide both your management console password as well as the endpoint to your management console. This is different than the API endpoint provided above.
|
333
362
|
|
334
363
|
``` ruby
|
335
|
-
management_console_client = Octokit::EnterpriseManagementConsoleClient.new
|
336
|
-
|
337
|
-
|
364
|
+
management_console_client = Octokit::EnterpriseManagementConsoleClient.new(
|
365
|
+
:management_console_password => "secret",
|
366
|
+
:management_console_endpoint = "https://hostname:8633"
|
367
|
+
)
|
368
|
+
|
338
369
|
# or
|
339
370
|
Octokit.configure do |c|
|
340
371
|
c.management_console_endpoint = "https://hostname:8633"
|
341
372
|
c.management_console_password = "secret"
|
342
373
|
end
|
343
|
-
|
374
|
+
|
375
|
+
management_console_client = Octokit.enterprise_management_console_client.new
|
344
376
|
```
|
345
377
|
|
346
378
|
### SSL Connection Errors
|
@@ -388,7 +420,7 @@ Octokit's default.
|
|
388
420
|
|
389
421
|
```ruby
|
390
422
|
# Given $OCTOKIT_API_ENDPOINT is "http://api.github.dev"
|
391
|
-
|
423
|
+
client.api_endpoint
|
392
424
|
|
393
425
|
# => "http://api.github.dev"
|
394
426
|
```
|
@@ -397,6 +429,27 @@ Deprecation warnings and API endpoints in development preview warnings are
|
|
397
429
|
printed to STDOUT by default, these can be disabled by setting the ENV
|
398
430
|
`OCTOKIT_SILENT=true`.
|
399
431
|
|
432
|
+
### Timeouts
|
433
|
+
|
434
|
+
By default, Octokit does not timeout network requests. To set a timeout, pass in Faraday timeout settings to Octokit's `connection_options` setting.
|
435
|
+
|
436
|
+
```ruby
|
437
|
+
Octokit.configure do |c|
|
438
|
+
c.api_endpoint = ENV.fetch('GITHUB_API_ENDPOINT', 'https://api.github.com/')
|
439
|
+
c.connection_options = {
|
440
|
+
request: {
|
441
|
+
open_timeout: 5,
|
442
|
+
timeout: 5
|
443
|
+
}
|
444
|
+
}
|
445
|
+
end
|
446
|
+
```
|
447
|
+
You should set a timeout in order to avoid Ruby’s Timeout module, which can hose your server. Here are some resources for more information on this:
|
448
|
+
|
449
|
+
- [The Oldest Bug In Ruby - Why Rack::Timeout Might Hose your Server](https://www.schneems.com/2017/02/21/the-oldest-bug-in-ruby-why-racktimeout-might-hose-your-server/)
|
450
|
+
- [Timeout: Ruby's Most Dangerous API](https://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/)
|
451
|
+
- [The Ultimate Guide to Ruby Timeouts](https://github.com/ankane/the-ultimate-guide-to-ruby-timeouts)
|
452
|
+
|
400
453
|
## Hypermedia agent
|
401
454
|
|
402
455
|
Starting in version 2.0, Octokit is [hypermedia][]-enabled. Under the hood,
|
@@ -408,7 +461,7 @@ Resources returned by Octokit methods contain not only data but hypermedia
|
|
408
461
|
link relations:
|
409
462
|
|
410
463
|
```ruby
|
411
|
-
user =
|
464
|
+
user = client.user 'technoweenie'
|
412
465
|
|
413
466
|
# Get the repos rel, returned from the API
|
414
467
|
# as repos_url in the resource
|
@@ -429,7 +482,7 @@ You might notice many link relations have variable placeholders. Octokit
|
|
429
482
|
supports [URI Templates][uri-templates] for parameterized URI expansion:
|
430
483
|
|
431
484
|
```ruby
|
432
|
-
repo =
|
485
|
+
repo = client.repo 'pengwynn/pingwynn'
|
433
486
|
rel = repo.rels[:issues]
|
434
487
|
# => #<Sawyer::Relation: issues: get https://api.github.com/repos/pengwynn/pingwynn/issues{/number}>
|
435
488
|
|
@@ -446,7 +499,7 @@ If you want to use Octokit as a pure hypermedia API client, you can start at
|
|
446
499
|
the API root and follow link relations from there:
|
447
500
|
|
448
501
|
```ruby
|
449
|
-
root =
|
502
|
+
root = client.root
|
450
503
|
root.rels[:repository].get :uri => {:owner => "octokit", :repo => "octokit.rb" }
|
451
504
|
root.rels[:user_repositories].get :uri => { :user => "octokit" },
|
452
505
|
:query => { :type => "owner" }
|
@@ -486,7 +539,7 @@ Octokit.default_media_type = "application/vnd.github.beta+json"
|
|
486
539
|
or per-request
|
487
540
|
|
488
541
|
```ruby
|
489
|
-
|
542
|
+
client.emails(:accept => "application/vnd.github.beta+json")
|
490
543
|
```
|
491
544
|
|
492
545
|
The long-deprecated `Octokit::Client#create_download` method has been removed.
|
@@ -527,12 +580,17 @@ traffic:
|
|
527
580
|
|
528
581
|
```ruby
|
529
582
|
stack = Faraday::RackBuilder.new do |builder|
|
530
|
-
builder.
|
583
|
+
builder.use Faraday::Request::Retry, exceptions: [Octokit::ServerError]
|
584
|
+
builder.use Octokit::Middleware::FollowRedirects
|
531
585
|
builder.use Octokit::Response::RaiseError
|
586
|
+
builder.use Octokit::Response::FeedParser
|
587
|
+
builder.response :logger
|
532
588
|
builder.adapter Faraday.default_adapter
|
533
589
|
end
|
534
590
|
Octokit.middleware = stack
|
535
|
-
|
591
|
+
|
592
|
+
client = Octokit::Client.new
|
593
|
+
client.user 'pengwynn'
|
536
594
|
```
|
537
595
|
```
|
538
596
|
I, [2013-08-22T15:54:38.583300 #88227] INFO -- : get https://api.github.com/users/pengwynn
|
@@ -593,9 +651,15 @@ to run a Ruby console to poke on Octokit, you can crank one up with:
|
|
593
651
|
|
594
652
|
script/console
|
595
653
|
|
596
|
-
Using the scripts in `./
|
654
|
+
Using the scripts in `./script` instead of `bundle exec rspec`, `bundle
|
597
655
|
console`, etc. ensures your dependencies are up-to-date.
|
598
656
|
|
657
|
+
### Code of Conduct
|
658
|
+
|
659
|
+
We want both the Octokit.rb and larger Octokit communities to be an open
|
660
|
+
and welcoming environments. Please read and follow both in spirit and
|
661
|
+
letter [Code of Conduct](CODE_OF_CONDUCT.md).
|
662
|
+
|
599
663
|
### Running and writing new tests
|
600
664
|
|
601
665
|
Octokit uses [VCR][] for recording and playing back API fixtures during test
|
@@ -622,11 +686,14 @@ ENV Variable | Description |
|
|
622
686
|
`OCTOKIT_TEST_GITHUB_CLIENT_SECRET` | Test OAuth application client secret.
|
623
687
|
`OCTOKIT_TEST_GITHUB_REPOSITORY` | Test repository to perform destructive actions against, this should not be set to any repository of importance. **Automatically created by the test suite if nonexistent** Default: `api-sandbox`
|
624
688
|
`OCTOKIT_TEST_GITHUB_ORGANIZATION` | Test organization.
|
625
|
-
`OCTOKIT_TEST_GITHUB_ENTERPRISE_LOGIN` | GitHub Enterprise login name
|
626
|
-
`OCTOKIT_TEST_GITHUB_ENTERPRISE_TOKEN` | GitHub Enterprise token
|
627
|
-
`OCTOKIT_TEST_GITHUB_ENTERPRISE_MANAGEMENT_CONSOLE_PASSWORD` | GitHub Enterprise management console password
|
628
|
-
`OCTOKIT_TEST_GITHUB_ENTERPRISE_ENDPOINT` | GitHub Enterprise hostname
|
629
|
-
`OCTOKIT_TEST_GITHUB_ENTERPRISE_MANAGEMENT_CONSOLE_ENDPOINT` | GitHub Enterprise Management Console endpoint
|
689
|
+
`OCTOKIT_TEST_GITHUB_ENTERPRISE_LOGIN` | GitHub Enterprise login name.
|
690
|
+
`OCTOKIT_TEST_GITHUB_ENTERPRISE_TOKEN` | GitHub Enterprise token.
|
691
|
+
`OCTOKIT_TEST_GITHUB_ENTERPRISE_MANAGEMENT_CONSOLE_PASSWORD` | GitHub Enterprise management console password.
|
692
|
+
`OCTOKIT_TEST_GITHUB_ENTERPRISE_ENDPOINT` | GitHub Enterprise hostname.
|
693
|
+
`OCTOKIT_TEST_GITHUB_ENTERPRISE_MANAGEMENT_CONSOLE_ENDPOINT` | GitHub Enterprise Management Console endpoint.
|
694
|
+
`OCTOKIT_TEST_GITHUB_INTEGRATION` | [GitHub Integration](https://developer.github.com/early-access/integrations/) owned by your test organization.
|
695
|
+
`OCTOKIT_TEST_GITHUB_INTEGRATION_INSTALLATION` | Installation of the GitHub Integration specified above.
|
696
|
+
`OCTOKIT_TEST_INTEGRATION_PEM_KEY` | File path to the private key generated from your integration.
|
630
697
|
|
631
698
|
Since we periodically refresh our cassettes, please keep some points in mind
|
632
699
|
when writing new specs.
|
@@ -646,13 +713,12 @@ when writing new specs.
|
|
646
713
|
|
647
714
|
## Supported Ruby Versions
|
648
715
|
|
649
|
-
This library aims to support and is [tested against][
|
716
|
+
This library aims to support and is [tested against][actions] the following Ruby
|
650
717
|
implementations:
|
651
718
|
|
652
|
-
* Ruby 2.
|
653
|
-
* Ruby 2.
|
654
|
-
* Ruby 2.
|
655
|
-
* Ruby 2.3
|
719
|
+
* Ruby 2.5
|
720
|
+
* Ruby 2.6
|
721
|
+
* Ruby 2.7
|
656
722
|
|
657
723
|
If something doesn't work on one of these Ruby versions, it's a bug.
|
658
724
|
|
@@ -667,7 +733,7 @@ implementation, you will be responsible for providing patches in a timely
|
|
667
733
|
fashion. If critical issues for a particular implementation exist at the time
|
668
734
|
of a major release, support for that Ruby version may be dropped.
|
669
735
|
|
670
|
-
[
|
736
|
+
[actions]: https://github.com/octokit/octokit.rb/actions
|
671
737
|
|
672
738
|
## Versioning
|
673
739
|
|
@@ -688,6 +754,21 @@ The changes made between versions can be seen on the [project releases page][rel
|
|
688
754
|
[pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
|
689
755
|
[releases]: https://github.com/octokit/octokit.rb/releases
|
690
756
|
|
757
|
+
## Making Repeating Requests
|
758
|
+
In most cases it would be best to use a [webhooks](https://developer.github.com/webhooks/), but sometimes webhooks don't provide all of the information needed. In those cases where one might need to poll for progress or retry a request on failure, we designed [Octopoller](https://github.com/octokit/octopoller.rb). Octopoller is a micro gem perfect for making repeating requests.
|
759
|
+
|
760
|
+
```ruby
|
761
|
+
Octopoller.poll(timeout: 15.seconds) do
|
762
|
+
begin
|
763
|
+
client.request_progress # ex. request a long running job's status
|
764
|
+
rescue Error
|
765
|
+
:re_poll
|
766
|
+
end
|
767
|
+
end
|
768
|
+
```
|
769
|
+
|
770
|
+
This is useful when making requests for a long running job's progress (ex. requesting a [Source Import's progress](https://developer.github.com/v3/migrations/source_imports/#get-import-progress)).
|
771
|
+
|
691
772
|
## License
|
692
773
|
|
693
774
|
Copyright (c) 2009-2014 Wynn Netherland, Adam Stacoviak, Erik Michaels-Ober
|
@@ -21,6 +21,14 @@ module Octokit
|
|
21
21
|
!!@access_token
|
22
22
|
end
|
23
23
|
|
24
|
+
# Indicates if the client was supplied a bearer token
|
25
|
+
#
|
26
|
+
# @see https://developer.github.com/early-access/integrations/authentication/#as-an-integration
|
27
|
+
# @return [Boolean]
|
28
|
+
def bearer_authenticated?
|
29
|
+
!!@bearer_token
|
30
|
+
end
|
31
|
+
|
24
32
|
# Indicates if the client was supplied an OAuth
|
25
33
|
# access token or Basic Auth username and password
|
26
34
|
#
|
@@ -35,22 +43,13 @@ module Octokit
|
|
35
43
|
# requests at a higher rate limit
|
36
44
|
#
|
37
45
|
# @see https://developer.github.com/v3/#unauthenticated-rate-limited-requests
|
38
|
-
# @return Boolean
|
46
|
+
# @return [Boolean]
|
39
47
|
def application_authenticated?
|
40
|
-
!!
|
48
|
+
!!(@client_id && @client_secret)
|
41
49
|
end
|
42
50
|
|
43
51
|
private
|
44
52
|
|
45
|
-
def application_authentication
|
46
|
-
if @client_id && @client_secret
|
47
|
-
{
|
48
|
-
:client_id => @client_id,
|
49
|
-
:client_secret => @client_secret
|
50
|
-
}
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
53
|
def login_from_netrc
|
55
54
|
return unless netrc?
|
56
55
|
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Octokit
|
2
|
+
class Client
|
3
|
+
|
4
|
+
# Methods for the Actions Secrets API
|
5
|
+
#
|
6
|
+
# @see https://developer.github.com/v3/actions/secrets/
|
7
|
+
module ActionsSecrets
|
8
|
+
|
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://developer.github.com/v3/actions/secrets/#get-your-public-key
|
14
|
+
def get_public_key(repo)
|
15
|
+
get "#{Repository.path repo}/actions/secrets/public-key"
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
# List secrets
|
20
|
+
#
|
21
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
22
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
23
|
+
# @see https://developer.github.com/v3/actions/secrets/#list-secrets-for-a-repository
|
24
|
+
def list_secrets(repo)
|
25
|
+
paginate "#{Repository.path repo}/actions/secrets"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get a secret
|
29
|
+
#
|
30
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
31
|
+
# @param name [String] Name of secret
|
32
|
+
# @return [Hash] name, created_at and updated_at
|
33
|
+
# @see https://developer.github.com/v3/actions/secrets/#get-a-secret
|
34
|
+
def get_secret(repo, name)
|
35
|
+
get "#{Repository.path repo}/actions/secrets/#{name}"
|
36
|
+
end
|
37
|
+
|
38
|
+
# Create or update secrets
|
39
|
+
#
|
40
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
41
|
+
# @param name [String] Name of secret
|
42
|
+
# @param options [Hash] encrypted_value and key_id
|
43
|
+
# @see https://developer.github.com/v3/actions/secrets/#create-or-update-a-secret-for-a-repository
|
44
|
+
def create_or_update_secret(repo, name, options)
|
45
|
+
put "#{Repository.path repo}/actions/secrets/#{name}", options
|
46
|
+
end
|
47
|
+
|
48
|
+
# Delete a secret
|
49
|
+
#
|
50
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
51
|
+
# @param name [String] Name of secret
|
52
|
+
# @see https://developer.github.com/v3/actions/secrets/#delete-a-secret-from-a-repository
|
53
|
+
def delete_secret(repo, name)
|
54
|
+
boolean_from_response :delete, "#{Repository.path repo}/actions/secrets/#{name}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|