octokit 4.25.1 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +3 -1
- data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
- data/lib/octokit/client/actions_workflow_runs.rb +21 -3
- data/lib/octokit/client/actions_workflows.rb +25 -1
- data/lib/octokit/client/apps.rb +15 -15
- data/lib/octokit/client/community_profile.rb +0 -1
- data/lib/octokit/client/events.rb +0 -1
- data/lib/octokit/client/hooks.rb +0 -10
- data/lib/octokit/client/issues.rb +0 -1
- data/lib/octokit/client/licenses.rb +0 -3
- data/lib/octokit/client/oauth_applications.rb +0 -4
- data/lib/octokit/client/organizations.rb +41 -13
- data/lib/octokit/client/pages.rb +2 -4
- data/lib/octokit/client/projects.rb +26 -45
- data/lib/octokit/client/pub_sub_hubbub.rb +7 -7
- data/lib/octokit/client/pull_requests.rb +11 -0
- data/lib/octokit/client/reactions.rb +4 -9
- data/lib/octokit/client/refs.rb +1 -3
- data/lib/octokit/client/repositories.rb +13 -33
- data/lib/octokit/client/reviews.rb +2 -2
- data/lib/octokit/client/search.rb +14 -1
- data/lib/octokit/client/source_import.rb +3 -8
- data/lib/octokit/client/tokens.rb +31 -0
- data/lib/octokit/client/traffic.rb +4 -8
- data/lib/octokit/client/users.rb +0 -7
- data/lib/octokit/client.rb +6 -4
- data/lib/octokit/configurable.rb +2 -4
- data/lib/octokit/connection.rb +1 -1
- data/lib/octokit/default.rb +18 -18
- data/lib/octokit/error.rb +21 -14
- data/lib/octokit/middleware/follow_redirects.rb +1 -1
- data/lib/octokit/rate_limit.rb +1 -1
- data/lib/octokit/repository.rb +1 -0
- data/lib/octokit/version.rb +3 -3
- data/octokit.gemspec +1 -1
- metadata +10 -9
- data/lib/octokit/client/authorizations.rb +0 -185
- data/lib/octokit/preview.rb +0 -46
@@ -1,185 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Octokit
|
4
|
-
class Client
|
5
|
-
# Methods for the Authorizations API
|
6
|
-
#
|
7
|
-
# @see https://developer.github.com/v3/oauth_authorizations/#oauth-authorizations-api
|
8
|
-
module Authorizations
|
9
|
-
# List the authenticated user's authorizations
|
10
|
-
#
|
11
|
-
# API for users to manage their own tokens.
|
12
|
-
# You can only access your own tokens, and only through
|
13
|
-
# Basic Authentication.
|
14
|
-
#
|
15
|
-
# @return [Array<Sawyer::Resource>] A list of authorizations for the authenticated user
|
16
|
-
# @see https://developer.github.com/v3/oauth_authorizations/#list-your-authorizations
|
17
|
-
# @example List authorizations for user ctshryock
|
18
|
-
# client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
|
19
|
-
# client.authorizations
|
20
|
-
def authorizations(options = {})
|
21
|
-
paginate 'authorizations', options
|
22
|
-
end
|
23
|
-
|
24
|
-
# Get a single authorization for the authenticated user.
|
25
|
-
#
|
26
|
-
# You can only access your own tokens, and only through
|
27
|
-
# Basic Authentication.
|
28
|
-
#
|
29
|
-
# @return [Sawyer::Resource] A single authorization for the authenticated user
|
30
|
-
# @see https://developer.github.com/v3/oauth_authorizations/#get-a-single-authorization
|
31
|
-
# @example Show authorization for user ctshryock's Travis auth
|
32
|
-
# client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
|
33
|
-
# client.authorization(999999)
|
34
|
-
def authorization(number, options = {})
|
35
|
-
get "authorizations/#{number}", options
|
36
|
-
end
|
37
|
-
|
38
|
-
# Create an authorization for the authenticated user.
|
39
|
-
#
|
40
|
-
# You can create your own tokens, and only through
|
41
|
-
# Basic Authentication.
|
42
|
-
#
|
43
|
-
# @param options [Hash] A customizable set of options.
|
44
|
-
# @option options [Array] :scopes A list of scopes that this authorization is in.
|
45
|
-
# @option options [String] :note A note to remind you what the OAuth token is for.
|
46
|
-
# @option options [String] :note_url A URL to remind you what app the OAuth token is for.
|
47
|
-
# @option options [Boolean] :idempotent If true, will return an existing authorization if one has already been created.
|
48
|
-
# @option options [String] :client_id Client Id we received when our application was registered with GitHub.
|
49
|
-
# @option options [String] :client_secret Client Secret we received when our application was registered with GitHub.
|
50
|
-
#
|
51
|
-
# @return [Sawyer::Resource] A single authorization for the authenticated user
|
52
|
-
# @see https://developer.github.com/v3/oauth/#scopes Available scopes
|
53
|
-
# @see https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization
|
54
|
-
# @see https://developer.github.com/v3/oauth_authorizations/#get-or-create-an-authorization-for-a-specific-app
|
55
|
-
# @example Create a new authorization for user ctshryock's project Zoidberg
|
56
|
-
# client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
|
57
|
-
# client.create_authorization({:scopes => ["public_repo", "gist"], :note => "Why not Zoidberg?", :note_url=> "https://en.wikipedia.org/wiki/Zoidberg"})
|
58
|
-
# @example Create a new OR return an existing authorization to be used by a specific client for user ctshryock's project Zoidberg
|
59
|
-
# client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
|
60
|
-
# client.create_authorization({:idempotent => true, :client_id => 'xxxx', :client_secret => 'yyyy', :scopes => ["user"]})
|
61
|
-
def create_authorization(options = {})
|
62
|
-
# Technically we can omit scopes as GitHub has a default, however the
|
63
|
-
# API will reject us if we send a POST request with an empty body.
|
64
|
-
options = options.dup
|
65
|
-
if options.delete :idempotent
|
66
|
-
client_id, client_secret = fetch_client_id_and_secret(options)
|
67
|
-
unless client_id && client_secret
|
68
|
-
raise ArgumentError, 'Client ID and Secret required for idempotent authorizations'
|
69
|
-
end
|
70
|
-
|
71
|
-
# Remove the client_id from the body otherwise
|
72
|
-
# this will result in a 422.
|
73
|
-
options.delete(:client_id)
|
74
|
-
|
75
|
-
if (fingerprint = options.delete(:fingerprint))
|
76
|
-
put "authorizations/clients/#{client_id}/#{fingerprint}", options.merge(client_secret: client_secret)
|
77
|
-
else
|
78
|
-
put "authorizations/clients/#{client_id}", options.merge(client_secret: client_secret)
|
79
|
-
end
|
80
|
-
|
81
|
-
else
|
82
|
-
post 'authorizations', options
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
# Update an authorization for the authenticated user.
|
87
|
-
#
|
88
|
-
# You can update your own tokens, but only through
|
89
|
-
# Basic Authentication.
|
90
|
-
#
|
91
|
-
# @param options [Hash] A customizable set of options.
|
92
|
-
# @option options [Array] :scopes Replace the authorization scopes with these.
|
93
|
-
# @option options [Array] :add_scopes A list of scopes to add to this authorization.
|
94
|
-
# @option options [Array] :remove_scopes A list of scopes to remove from this authorization.
|
95
|
-
# @option options [String] :note A note to remind you what the OAuth token is for.
|
96
|
-
# @option options [String] :note_url A URL to remind you what app the OAuth token is for.
|
97
|
-
#
|
98
|
-
# @return [Sawyer::Resource] A single (updated) authorization for the authenticated user
|
99
|
-
# @see https://developer.github.com/v3/oauth_authorizations/#update-an-existing-authorization
|
100
|
-
# @see https://developer.github.com/v3/oauth/#scopes for available scopes
|
101
|
-
# @example Update the authorization for user ctshryock's project Zoidberg
|
102
|
-
# client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
|
103
|
-
# client.update_authorization(999999, {:add_scopes => ["gist", "repo"], :note => "Why not Zoidberg possibly?"})
|
104
|
-
def update_authorization(number, options = {})
|
105
|
-
patch "authorizations/#{number}", options
|
106
|
-
end
|
107
|
-
|
108
|
-
# Delete an authorization for the authenticated user.
|
109
|
-
#
|
110
|
-
# You can delete your own tokens, and only through
|
111
|
-
# Basic Authentication.
|
112
|
-
#
|
113
|
-
# @param number [Number] An existing Authorization ID
|
114
|
-
#
|
115
|
-
# @return [Boolean] Success
|
116
|
-
# @see https://developer.github.com/v3/oauth_authorizations/#delete-an-authorization
|
117
|
-
# @example Delete an authorization
|
118
|
-
# client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
|
119
|
-
# client.delete_authorization(999999)
|
120
|
-
def delete_authorization(number, options = {})
|
121
|
-
boolean_from_response :delete, "authorizations/#{number}", options
|
122
|
-
end
|
123
|
-
|
124
|
-
# Check scopes for a token
|
125
|
-
#
|
126
|
-
# @param token [String] GitHub OAuth token
|
127
|
-
# @param options [Hash] Header params for request
|
128
|
-
# @return [Array<String>] OAuth scopes
|
129
|
-
# @see https://developer.github.com/v3/oauth/#scopes
|
130
|
-
def scopes(token = @access_token, options = {})
|
131
|
-
options = options.dup
|
132
|
-
raise ArgumentError, 'Access token required' if token.nil?
|
133
|
-
|
134
|
-
auth = { 'Authorization' => "token #{token}" }
|
135
|
-
headers = (options.delete(:headers) || {}).merge(auth)
|
136
|
-
|
137
|
-
agent.call(:get, 'user', headers: headers)
|
138
|
-
.headers['X-OAuth-Scopes']
|
139
|
-
.to_s
|
140
|
-
.split(',')
|
141
|
-
.map(&:strip)
|
142
|
-
.sort
|
143
|
-
end
|
144
|
-
|
145
|
-
# Revoke all tokens for an app
|
146
|
-
#
|
147
|
-
# Applications can revoke all of their tokens in a single request
|
148
|
-
#
|
149
|
-
# @deprecated As of January 25th, 2016: https://developer.github.com/changes/2014-04-08-reset-api-tokens/
|
150
|
-
# @return [Boolean] false
|
151
|
-
def revoke_all_application_authorizations(_options = {})
|
152
|
-
octokit_warn('Deprecated: If you need to revoke all tokens for your application, you can do so via the settings page for your application.')
|
153
|
-
false
|
154
|
-
end
|
155
|
-
|
156
|
-
# Get the URL to authorize a user for an application via the web flow
|
157
|
-
#
|
158
|
-
# @param app_id [String] Client Id we received when our application was registered with GitHub.
|
159
|
-
# @option options [String] :redirect_uri The url to redirect to after authorizing.
|
160
|
-
# @option options [String] :scope The scopes to request from the user.
|
161
|
-
# @option options [String] :state A random string to protect against CSRF.
|
162
|
-
# @return [String] The url to redirect the user to authorize.
|
163
|
-
# @see Octokit::Client
|
164
|
-
# @see https://developer.github.com/v3/oauth/#web-application-flow
|
165
|
-
# @example
|
166
|
-
# @client.authorize_url('xxxx')
|
167
|
-
def authorize_url(app_id = client_id, options = {})
|
168
|
-
opts = options.dup
|
169
|
-
if app_id.to_s.empty?
|
170
|
-
raise Octokit::ApplicationCredentialsRequired, 'client_id required'
|
171
|
-
end
|
172
|
-
|
173
|
-
authorize_url = opts.delete(:endpoint) || Octokit.web_endpoint
|
174
|
-
authorize_url << "login/oauth/authorize?client_id=#{app_id}"
|
175
|
-
|
176
|
-
require 'cgi'
|
177
|
-
opts.each do |key, value|
|
178
|
-
authorize_url << "&#{key}=#{CGI.escape value}"
|
179
|
-
end
|
180
|
-
|
181
|
-
authorize_url
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
data/lib/octokit/preview.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Octokit
|
4
|
-
# Default setup options for preview features
|
5
|
-
module Preview
|
6
|
-
PREVIEW_TYPES = {
|
7
|
-
applications_api: 'application/vnd.github.doctor-strange-preview+json',
|
8
|
-
branch_protection: 'application/vnd.github.luke-cage-preview+json',
|
9
|
-
commit_search: 'application/vnd.github.cloak-preview+json',
|
10
|
-
commit_pulls: 'application/vnd.github.groot-preview+json',
|
11
|
-
commit_branches: 'application/vnd.github.groot-preview+json',
|
12
|
-
migrations: 'application/vnd.github.wyandotte-preview+json',
|
13
|
-
licenses: 'application/vnd.github.drax-preview+json',
|
14
|
-
source_imports: 'application/vnd.github.barred-rock-preview',
|
15
|
-
reactions: 'application/vnd.github.squirrel-girl-preview',
|
16
|
-
transfer_repository: 'application/vnd.github.nightshade-preview+json',
|
17
|
-
issue_timelines: 'application/vnd.github.mockingbird-preview+json',
|
18
|
-
nested_teams: 'application/vnd.github.hellcat-preview+json',
|
19
|
-
pages: 'application/vnd.github.mister-fantastic-preview+json',
|
20
|
-
projects: 'application/vnd.github.inertia-preview+json',
|
21
|
-
traffic: 'application/vnd.github.spiderman-preview',
|
22
|
-
topics: 'application/vnd.github.mercy-preview+json',
|
23
|
-
community_profile: 'application/vnd.github.black-panther-preview+json',
|
24
|
-
strict_validation: 'application/vnd.github.speedy-preview+json',
|
25
|
-
template_repositories: 'application/vnd.github.baptiste-preview+json',
|
26
|
-
project_card_events: 'application/vnd.github.starfox-preview+json',
|
27
|
-
vulnerability_alerts: 'application/vnd.github.dorian-preview+json'
|
28
|
-
}.freeze
|
29
|
-
|
30
|
-
def ensure_api_media_type(type, options)
|
31
|
-
if options[:accept].nil?
|
32
|
-
options[:accept] = PREVIEW_TYPES[type]
|
33
|
-
warn_preview(type)
|
34
|
-
end
|
35
|
-
options
|
36
|
-
end
|
37
|
-
|
38
|
-
def warn_preview(type)
|
39
|
-
octokit_warn <<~EOS
|
40
|
-
WARNING: The preview version of the #{type.to_s.capitalize} API is not yet suitable for production use.
|
41
|
-
You can avoid this message by supplying an appropriate media type in the 'Accept' request
|
42
|
-
header.
|
43
|
-
EOS
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|