octokit 4.2.0 → 9.2.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 +5 -5
- data/CONTRIBUTING.md +14 -13
- data/LICENSE.md +1 -1
- data/README.md +275 -127
- data/Rakefile +20 -14
- data/lib/ext/sawyer/relation.rb +12 -0
- data/lib/octokit/arguments.rb +3 -3
- data/lib/octokit/authentication.rb +20 -14
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +161 -0
- data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
- data/lib/octokit/client/actions_workflow_runs.rb +125 -0
- data/lib/octokit/client/actions_workflows.rb +68 -0
- data/lib/octokit/client/apps.rb +259 -0
- data/lib/octokit/client/checks.rb +200 -0
- data/lib/octokit/client/code_scanning.rb +190 -0
- data/lib/octokit/client/codespaces_secrets.rb +108 -0
- data/lib/octokit/client/commit_branches.rb +20 -0
- data/lib/octokit/client/commit_comments.rb +8 -8
- data/lib/octokit/client/commit_pulls.rb +20 -0
- data/lib/octokit/client/commits.rb +32 -35
- data/lib/octokit/client/community_profile.rb +21 -0
- data/lib/octokit/client/contents.rb +24 -21
- data/lib/octokit/client/dependabot_secrets.rb +108 -0
- data/lib/octokit/client/deployments.rb +29 -7
- data/lib/octokit/client/downloads.rb +5 -6
- data/lib/octokit/client/emojis.rb +3 -3
- data/lib/octokit/client/environments.rb +58 -0
- data/lib/octokit/client/events.rb +4 -4
- data/lib/octokit/client/feeds.rb +4 -5
- data/lib/octokit/client/gists.rb +36 -8
- data/lib/octokit/client/gitignore.rb +3 -3
- data/lib/octokit/client/hooks.rb +34 -30
- data/lib/octokit/client/issues.rb +97 -14
- data/lib/octokit/client/labels.rb +17 -17
- data/lib/octokit/client/legacy_search.rb +3 -3
- data/lib/octokit/client/licenses.rb +5 -8
- data/lib/octokit/client/markdown.rb +3 -3
- data/lib/octokit/client/marketplace.rb +56 -0
- data/lib/octokit/client/meta.rb +4 -5
- data/lib/octokit/client/milestones.rb +14 -14
- data/lib/octokit/client/notifications.rb +7 -11
- data/lib/octokit/client/oauth_applications.rb +116 -0
- data/lib/octokit/client/objects.rb +14 -14
- data/lib/octokit/client/organizations.rb +256 -73
- data/lib/octokit/client/pages.rb +26 -3
- data/lib/octokit/client/projects.rb +294 -0
- data/lib/octokit/client/pull_requests.rb +74 -51
- data/lib/octokit/client/rate_limit.rb +11 -13
- data/lib/octokit/client/reactions.rb +204 -0
- data/lib/octokit/client/refs.rb +34 -20
- data/lib/octokit/client/releases.rb +16 -13
- data/lib/octokit/client/repositories.rb +276 -60
- data/lib/octokit/client/repository_invitations.rb +96 -0
- data/lib/octokit/client/reviews.rb +227 -0
- data/lib/octokit/client/say.rb +4 -5
- data/lib/octokit/client/search.rb +46 -17
- data/lib/octokit/client/service_status.rb +19 -9
- data/lib/octokit/client/source_import.rb +156 -0
- data/lib/octokit/client/stats.rb +39 -17
- data/lib/octokit/client/statuses.rb +6 -6
- data/lib/octokit/client/tokens.rb +31 -0
- data/lib/octokit/client/traffic.rb +64 -0
- data/lib/octokit/client/users.rb +133 -25
- data/lib/octokit/client.rb +85 -19
- data/lib/octokit/configurable.rb +60 -32
- data/lib/octokit/connection.rb +45 -21
- data/lib/octokit/default.rb +82 -35
- data/lib/octokit/enterprise_admin_client/admin_stats.rb +14 -15
- data/lib/octokit/enterprise_admin_client/license.rb +4 -5
- data/lib/octokit/enterprise_admin_client/orgs.rb +7 -6
- data/lib/octokit/enterprise_admin_client/search_indexing.rb +8 -9
- data/lib/octokit/enterprise_admin_client/users.rb +19 -18
- data/lib/octokit/enterprise_admin_client.rb +11 -3
- data/lib/octokit/enterprise_management_console_client/management_console.rb +52 -34
- data/lib/octokit/enterprise_management_console_client.rb +9 -3
- data/lib/octokit/error.rb +144 -26
- data/lib/octokit/gist.rb +4 -5
- data/lib/octokit/manage_ghes_client/manage_ghes.rb +178 -0
- data/lib/octokit/manage_ghes_client.rb +64 -0
- data/lib/octokit/middleware/follow_redirects.rb +18 -14
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +11 -9
- data/lib/octokit/repo_arguments.rb +3 -4
- data/lib/octokit/repository.rb +35 -23
- data/lib/octokit/response/base_middleware.rb +10 -0
- data/lib/octokit/response/feed_parser.rb +5 -9
- data/lib/octokit/response/raise_error.rb +4 -6
- data/lib/octokit/user.rb +4 -2
- data/lib/octokit/version.rb +3 -1
- data/lib/octokit/warnable.rb +4 -5
- data/lib/octokit.rb +30 -8
- data/octokit.gemspec +12 -10
- metadata +47 -24
- data/lib/octokit/client/authorizations.rb +0 -256
- data/lib/octokit/client/pub_sub_hubbub.rb +0 -111
- data/lib/octokit/preview.rb +0 -28
@@ -1,256 +0,0 @@
|
|
1
|
-
module Octokit
|
2
|
-
class Client
|
3
|
-
|
4
|
-
# Methods for the Authorizations API
|
5
|
-
#
|
6
|
-
# @see https://developer.github.com/v3/oauth_authorizations/#oauth-authorizations-api
|
7
|
-
module Authorizations
|
8
|
-
|
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
|
-
# Techincally 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
|
-
|
65
|
-
if options.delete :idempotent
|
66
|
-
client_id, client_secret = fetch_client_id_and_secret(options)
|
67
|
-
raise ArgumentError.new("Client ID and Secret required for idempotent authorizations") unless client_id && client_secret
|
68
|
-
|
69
|
-
if fingerprint = options.delete(:fingerprint)
|
70
|
-
put "authorizations/clients/#{client_id}/#{fingerprint}", options.merge(:client_secret => client_secret)
|
71
|
-
else
|
72
|
-
put "authorizations/clients/#{client_id}", options.merge(:client_secret => client_secret)
|
73
|
-
end
|
74
|
-
|
75
|
-
else
|
76
|
-
post 'authorizations', options
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
# Update an authorization for the authenticated user.
|
81
|
-
#
|
82
|
-
# You can update your own tokens, but only through
|
83
|
-
# Basic Authentication.
|
84
|
-
#
|
85
|
-
# @param options [Hash] A customizable set of options.
|
86
|
-
# @option options [Array] :scopes Replace the authorization scopes with these.
|
87
|
-
# @option options [Array] :add_scopes A list of scopes to add to this authorization.
|
88
|
-
# @option options [Array] :remove_scopes A list of scopes to remove from this authorization.
|
89
|
-
# @option options [String] :note A note to remind you what the OAuth token is for.
|
90
|
-
# @option options [String] :note_url A URL to remind you what app the OAuth token is for.
|
91
|
-
#
|
92
|
-
# @return [Sawyer::Resource] A single (updated) authorization for the authenticated user
|
93
|
-
# @see https://developer.github.com/v3/oauth_authorizations/#update-an-existing-authorization
|
94
|
-
# @see https://developer.github.com/v3/oauth/#scopes for available scopes
|
95
|
-
# @example Update the authorization for user ctshryock's project Zoidberg
|
96
|
-
# client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
|
97
|
-
# client.update_authorization(999999, {:add_scopes => ["gist", "repo"], :note => "Why not Zoidberg possibly?"})
|
98
|
-
def update_authorization(number, options = {})
|
99
|
-
patch "authorizations/#{number}", options
|
100
|
-
end
|
101
|
-
|
102
|
-
# Delete an authorization for the authenticated user.
|
103
|
-
#
|
104
|
-
# You can delete your own tokens, and only through
|
105
|
-
# Basic Authentication.
|
106
|
-
#
|
107
|
-
# @param number [Number] An existing Authorization ID
|
108
|
-
#
|
109
|
-
# @return [Boolean] Success
|
110
|
-
# @see https://developer.github.com/v3/oauth_authorizations/#delete-an-authorization
|
111
|
-
# @example Delete an authorization
|
112
|
-
# client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
|
113
|
-
# client.delete_authorization(999999)
|
114
|
-
def delete_authorization(number, options = {})
|
115
|
-
boolean_from_response :delete, "authorizations/#{number}", options
|
116
|
-
end
|
117
|
-
|
118
|
-
# Check scopes for a token
|
119
|
-
#
|
120
|
-
# @param token [String] GitHub OAuth token
|
121
|
-
# @param options [Hash] Header params for request
|
122
|
-
# @return [Array<String>] OAuth scopes
|
123
|
-
# @see https://developer.github.com/v3/oauth/#scopes
|
124
|
-
def scopes(token = @access_token, options = {})
|
125
|
-
raise ArgumentError.new("Access token required") if token.nil?
|
126
|
-
|
127
|
-
auth = { "Authorization" => "token #{token}" }
|
128
|
-
headers = (options.delete(:headers) || {}).merge(auth)
|
129
|
-
|
130
|
-
agent.call(:get, "user", :headers => headers).
|
131
|
-
headers['X-OAuth-Scopes'].
|
132
|
-
to_s.
|
133
|
-
split(',').
|
134
|
-
map(&:strip).
|
135
|
-
sort
|
136
|
-
end
|
137
|
-
|
138
|
-
# Check if a token is valid.
|
139
|
-
#
|
140
|
-
# Applications can check if a token is valid without rate limits.
|
141
|
-
#
|
142
|
-
# @param token [String] 40 character GitHub OAuth access token
|
143
|
-
#
|
144
|
-
# @return [Sawyer::Resource] A single authorization for the authenticated user
|
145
|
-
# @see https://developer.github.com/v3/oauth_authorizations/#check-an-authorization
|
146
|
-
# @example
|
147
|
-
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
148
|
-
# client.check_application_authorization('deadbeef1234567890deadbeef987654321')
|
149
|
-
def check_application_authorization(token, options = {})
|
150
|
-
opts = options.dup
|
151
|
-
key = opts.delete(:client_id) || client_id
|
152
|
-
secret = opts.delete(:client_secret) || client_secret
|
153
|
-
|
154
|
-
as_app(key, secret) do |app_client|
|
155
|
-
app_client.get "/applications/#{client_id}/tokens/#{token}", opts
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
# Reset a token
|
160
|
-
#
|
161
|
-
# Applications can reset a token without requiring a user to re-authorize.
|
162
|
-
#
|
163
|
-
# @param token [String] 40 character GitHub OAuth access token
|
164
|
-
#
|
165
|
-
# @return [Sawyer::Resource] A single authorization for the authenticated user
|
166
|
-
# @see https://developer.github.com/v3/oauth_authorizations/#reset-an-authorization
|
167
|
-
# @example
|
168
|
-
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
169
|
-
# client.reset_application_authorization('deadbeef1234567890deadbeef987654321')
|
170
|
-
def reset_application_authorization(token, options = {})
|
171
|
-
opts = options.dup
|
172
|
-
key = opts.delete(:client_id) || client_id
|
173
|
-
secret = opts.delete(:client_secret) || client_secret
|
174
|
-
|
175
|
-
as_app(key, secret) do |app_client|
|
176
|
-
app_client.post "/applications/#{client_id}/tokens/#{token}", opts
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
# Revoke a token
|
181
|
-
#
|
182
|
-
# Applications can revoke (delete) a token
|
183
|
-
#
|
184
|
-
# @param token [String] 40 character GitHub OAuth access token
|
185
|
-
#
|
186
|
-
# @return [Boolean] Result
|
187
|
-
# @see https://developer.github.com/v3/oauth_authorizations/#revoke-an-authorization-for-an-application
|
188
|
-
# @example
|
189
|
-
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
190
|
-
# client.revoke_application_authorization('deadbeef1234567890deadbeef987654321')
|
191
|
-
def revoke_application_authorization(token, options = {})
|
192
|
-
opts = options.dup
|
193
|
-
key = opts.delete(:client_id) || client_id
|
194
|
-
secret = opts.delete(:client_secret) || client_secret
|
195
|
-
|
196
|
-
as_app(key, secret) do |app_client|
|
197
|
-
app_client.delete "/applications/#{client_id}/tokens/#{token}", opts
|
198
|
-
|
199
|
-
app_client.last_response.status == 204
|
200
|
-
end
|
201
|
-
rescue Octokit::NotFound
|
202
|
-
false
|
203
|
-
end
|
204
|
-
alias :delete_application_authorization :revoke_application_authorization
|
205
|
-
|
206
|
-
# Revoke all tokens for an app
|
207
|
-
#
|
208
|
-
# Applications can revoke all of their tokens in a single request
|
209
|
-
#
|
210
|
-
# @return [Boolean] Result
|
211
|
-
# @see https://developer.github.com/v3/oauth_authorizations/#revoke-all-authorizations-for-an-application
|
212
|
-
# @example
|
213
|
-
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
214
|
-
# client.revoke_all_application_authorizations
|
215
|
-
def revoke_all_application_authorizations(options = {})
|
216
|
-
opts = options.dup
|
217
|
-
key = opts.delete(:client_id) || client_id
|
218
|
-
secret = opts.delete(:client_secret) || client_secret
|
219
|
-
|
220
|
-
as_app(key, secret) do |app_client|
|
221
|
-
app_client.delete "/applications/#{client_id}/tokens", opts
|
222
|
-
|
223
|
-
app_client.last_response.status == 204
|
224
|
-
end
|
225
|
-
rescue Octokit::NotFound
|
226
|
-
false
|
227
|
-
end
|
228
|
-
alias :delete_application_authorization :revoke_application_authorization
|
229
|
-
|
230
|
-
# Get the URL to authorize a user for an application via the web flow
|
231
|
-
#
|
232
|
-
# @param app_id [String] Client Id we received when our application was registered with GitHub.
|
233
|
-
# @option options [String] :redirect_uri The url to redirect to after authorizing.
|
234
|
-
# @option options [String] :scope The scopes to request from the user.
|
235
|
-
# @option options [String] :state A random string to protect against CSRF.
|
236
|
-
# @return [String] The url to redirect the user to authorize.
|
237
|
-
# @see Octokit::Client
|
238
|
-
# @see https://developer.github.com/v3/oauth/#web-application-flow
|
239
|
-
# @example
|
240
|
-
# @client.authorize_url('xxxx')
|
241
|
-
def authorize_url(app_id = client_id, options = {})
|
242
|
-
if app_id.to_s.empty?
|
243
|
-
raise Octokit::ApplicationCredentialsRequired.new "client_id required"
|
244
|
-
end
|
245
|
-
authorize_url = options.delete(:endpoint) || Octokit.web_endpoint
|
246
|
-
authorize_url += "login/oauth/authorize?client_id=" + app_id
|
247
|
-
|
248
|
-
options.each do |key, value|
|
249
|
-
authorize_url += "&" + key.to_s + "=" + value
|
250
|
-
end
|
251
|
-
|
252
|
-
authorize_url
|
253
|
-
end
|
254
|
-
end
|
255
|
-
end
|
256
|
-
end
|
@@ -1,111 +0,0 @@
|
|
1
|
-
module Octokit
|
2
|
-
class Client
|
3
|
-
|
4
|
-
# Methods for the PubSubHubbub API
|
5
|
-
#
|
6
|
-
# @see https://developer.github.com/v3/repos/hooks/#pubsubhubbub
|
7
|
-
module PubSubHubbub
|
8
|
-
|
9
|
-
# Subscribe to a pubsub topic
|
10
|
-
#
|
11
|
-
# @param topic [String] A recoginized and supported pubsub topic
|
12
|
-
# @param callback [String] A callback url to be posted to when the topic event is fired
|
13
|
-
# @param secret [String] An optional shared secret used to generate a SHA1 HMAC of the outgoing body content
|
14
|
-
# @return [Boolean] true if the subscribe was successful, otherwise an error is raised
|
15
|
-
# @see https://developer.github.com/v3/repos/hooks/#subscribing
|
16
|
-
# @example Subscribe to push events from one of your repositories, having an email sent when fired
|
17
|
-
# client = Octokit::Client.new(:oauth_token = "token")
|
18
|
-
# client.subscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")
|
19
|
-
def subscribe(topic, callback, secret = nil)
|
20
|
-
options = {
|
21
|
-
:"hub.callback" => callback,
|
22
|
-
:"hub.mode" => "subscribe",
|
23
|
-
:"hub.topic" => topic
|
24
|
-
}
|
25
|
-
options.merge!(:"hub.secret" => secret) unless secret.nil?
|
26
|
-
|
27
|
-
response = pub_sub_hubbub_request(options)
|
28
|
-
|
29
|
-
response.status == 204
|
30
|
-
end
|
31
|
-
|
32
|
-
# Unsubscribe from a pubsub topic
|
33
|
-
#
|
34
|
-
# @param topic [String] A recoginized pubsub topic
|
35
|
-
# @param callback [String] A callback url to be unsubscribed from
|
36
|
-
# @return [Boolean] true if the unsubscribe was successful, otherwise an error is raised
|
37
|
-
# @see https://developer.github.com/v3/repos/hooks/#subscribing
|
38
|
-
# @example Unsubscribe to push events from one of your repositories, no longer having an email sent when fired
|
39
|
-
# client = Octokit::Client.new(:oauth_token = "token")
|
40
|
-
# client.unsubscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")
|
41
|
-
def unsubscribe(topic, callback)
|
42
|
-
options = {
|
43
|
-
:"hub.callback" => callback,
|
44
|
-
:"hub.mode" => "unsubscribe",
|
45
|
-
:"hub.topic" => topic
|
46
|
-
}
|
47
|
-
response = pub_sub_hubbub_request(options)
|
48
|
-
|
49
|
-
response.status == 204
|
50
|
-
end
|
51
|
-
|
52
|
-
# Subscribe to a repository through pubsub
|
53
|
-
#
|
54
|
-
# @param repo [String, Repository, Hash] A GitHub repository
|
55
|
-
# @param service_name [String] service name owner
|
56
|
-
# @param service_arguments [Hash] params that will be passed by subscribed hook.
|
57
|
-
# List of services is available @ https://github.com/github/github-services/tree/master/docs.
|
58
|
-
# Please refer Data node for complete list of arguments.
|
59
|
-
# @param secret [String] An optional shared secret used to generate a SHA1 HMAC of the outgoing body content
|
60
|
-
# @return [Boolean] True if subscription successful, false otherwise
|
61
|
-
# @see https://developer.github.com/v3/repos/hooks/#subscribing
|
62
|
-
# @example Subscribe to push events to one of your repositories to Travis-CI
|
63
|
-
# client = Octokit::Client.new(:oauth_token = "token")
|
64
|
-
# client.subscribe_service_hook('joshk/device_imapable', 'Travis', { :token => "test", :domain => "domain", :user => "user" })
|
65
|
-
def subscribe_service_hook(repo, service_name, service_arguments = {}, secret = nil)
|
66
|
-
topic = "#{Octokit.web_endpoint}#{Repository.new(repo)}/events/push"
|
67
|
-
callback = "github://#{service_name}?#{service_arguments.collect{ |k,v| [ k,v ].map{ |p| URI.encode_www_form_component(p) }.join("=") }.join("&") }"
|
68
|
-
subscribe(topic, callback, secret)
|
69
|
-
end
|
70
|
-
|
71
|
-
# Unsubscribe repository through pubsub
|
72
|
-
#
|
73
|
-
# @param repo [String, Repository, Hash] A GitHub repository
|
74
|
-
# @param service_name [String] service name owner
|
75
|
-
# List of services is available @ https://github.com/github/github-services/tree/master/docs.
|
76
|
-
# @see https://developer.github.com/v3/repos/hooks/#subscribing
|
77
|
-
# @example Subscribe to push events to one of your repositories to Travis-CI
|
78
|
-
# client = Octokit::Client.new(:oauth_token = "token")
|
79
|
-
# client.unsubscribe_service_hook('joshk/device_imapable', 'Travis')
|
80
|
-
def unsubscribe_service_hook(repo, service_name)
|
81
|
-
topic = "#{Octokit.web_endpoint}#{Repository.new(repo)}/events/push"
|
82
|
-
callback = "github://#{service_name}"
|
83
|
-
unsubscribe(topic, callback)
|
84
|
-
end
|
85
|
-
|
86
|
-
private
|
87
|
-
|
88
|
-
def pub_sub_hubbub_request(options = {})
|
89
|
-
# This method is janky, bypass normal stack so we don't
|
90
|
-
# serialize request as JSON
|
91
|
-
conn = Faraday.new(:url => @api_endpoint) do |http|
|
92
|
-
http.headers[:user_agent] = user_agent
|
93
|
-
if basic_authenticated?
|
94
|
-
http.basic_auth(@login, @password)
|
95
|
-
elsif token_authenticated?
|
96
|
-
http.authorization 'token', @access_token
|
97
|
-
end
|
98
|
-
http.request :url_encoded
|
99
|
-
http.use Octokit::Response::RaiseError
|
100
|
-
http.adapter Faraday.default_adapter
|
101
|
-
end
|
102
|
-
|
103
|
-
conn.post do |req|
|
104
|
-
req.url "hub"
|
105
|
-
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
106
|
-
req.body = options
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
data/lib/octokit/preview.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
module Octokit
|
2
|
-
|
3
|
-
# Default setup options for preview features
|
4
|
-
module Preview
|
5
|
-
|
6
|
-
PREVIEW_TYPES = {
|
7
|
-
:branch_protection => 'application/vnd.github.loki-preview+json'.freeze,
|
8
|
-
:migrations => 'application/vnd.github.wyandotte-preview+json'.freeze,
|
9
|
-
:licenses => 'application/vnd.github.drax-preview+json'.freeze
|
10
|
-
}
|
11
|
-
|
12
|
-
def ensure_api_media_type(type, options)
|
13
|
-
if options[:accept].nil?
|
14
|
-
options[:accept] = PREVIEW_TYPES[type]
|
15
|
-
warn_preview(type)
|
16
|
-
end
|
17
|
-
options
|
18
|
-
end
|
19
|
-
|
20
|
-
def warn_preview(type)
|
21
|
-
warn <<-EOS
|
22
|
-
WARNING: The preview version of the #{type.to_s.capitalize} API is not yet suitable for production use.
|
23
|
-
You can avoid this message by supplying an appropriate media type in the 'Accept' request
|
24
|
-
header.
|
25
|
-
EOS
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|