octokit 4.16.0 → 4.18.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/lib/octokit/client.rb +2 -0
- data/lib/octokit/client/authorizations.rb +1 -69
- data/lib/octokit/client/events.rb +1 -0
- data/lib/octokit/client/oauth_applications.rb +122 -0
- data/lib/octokit/client/search.rb +1 -1
- data/lib/octokit/preview.rb +2 -0
- data/lib/octokit/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6769ee0502378ac696ca5c6fe2cf854eb67ad86affebf92342a6f30997d3f181
|
|
4
|
+
data.tar.gz: 9a189f3ee1bdd7164ce1a189d62f014e0440a648ac40dfdc8e7bf8c57af4d5fa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 61f2200517ff1f3f805926d3ce20b3155429e77d6e35ef89ebc0b1e2a826064e658bcc9f32c368cd89618677fa9c1b14d65668b6083ebba56ab36375e605a035
|
|
7
|
+
data.tar.gz: 8bf0ef345c8f3850196d8a2695b5ae9a3f2d90a7c63e9e02944c2876bf381613bb2fd0ecd5c3b11a4aaba75e22d5345269d1ad324c777224b4c65ec4f27eaf4a
|
data/lib/octokit/client.rb
CHANGED
|
@@ -36,6 +36,7 @@ require 'octokit/client/markdown'
|
|
|
36
36
|
require 'octokit/client/marketplace'
|
|
37
37
|
require 'octokit/client/milestones'
|
|
38
38
|
require 'octokit/client/notifications'
|
|
39
|
+
require 'octokit/client/oauth_applications'
|
|
39
40
|
require 'octokit/client/objects'
|
|
40
41
|
require 'octokit/client/organizations'
|
|
41
42
|
require 'octokit/client/pages'
|
|
@@ -97,6 +98,7 @@ module Octokit
|
|
|
97
98
|
include Octokit::Client::Marketplace
|
|
98
99
|
include Octokit::Client::Milestones
|
|
99
100
|
include Octokit::Client::Notifications
|
|
101
|
+
include Octokit::Client::OauthApplications
|
|
100
102
|
include Octokit::Client::Objects
|
|
101
103
|
include Octokit::Client::Organizations
|
|
102
104
|
include Octokit::Client::Pages
|
|
@@ -140,74 +140,6 @@ module Octokit
|
|
|
140
140
|
sort
|
|
141
141
|
end
|
|
142
142
|
|
|
143
|
-
# Check if a token is valid.
|
|
144
|
-
#
|
|
145
|
-
# Applications can check if a token is valid without rate limits.
|
|
146
|
-
#
|
|
147
|
-
# @param token [String] 40 character GitHub OAuth access token
|
|
148
|
-
#
|
|
149
|
-
# @return [Sawyer::Resource] A single authorization for the authenticated user
|
|
150
|
-
# @see https://developer.github.com/v3/oauth_authorizations/#check-an-authorization
|
|
151
|
-
# @example
|
|
152
|
-
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
|
153
|
-
# client.check_application_authorization('deadbeef1234567890deadbeef987654321')
|
|
154
|
-
def check_application_authorization(token, options = {})
|
|
155
|
-
opts = options.dup
|
|
156
|
-
key = opts.delete(:client_id) || client_id
|
|
157
|
-
secret = opts.delete(:client_secret) || client_secret
|
|
158
|
-
|
|
159
|
-
as_app(key, secret) do |app_client|
|
|
160
|
-
app_client.get "applications/#{client_id}/tokens/#{token}", opts
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
# Reset a token
|
|
165
|
-
#
|
|
166
|
-
# Applications can reset a token without requiring a user to re-authorize.
|
|
167
|
-
#
|
|
168
|
-
# @param token [String] 40 character GitHub OAuth access token
|
|
169
|
-
#
|
|
170
|
-
# @return [Sawyer::Resource] A single authorization for the authenticated user
|
|
171
|
-
# @see https://developer.github.com/v3/oauth_authorizations/#reset-an-authorization
|
|
172
|
-
# @example
|
|
173
|
-
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
|
174
|
-
# client.reset_application_authorization('deadbeef1234567890deadbeef987654321')
|
|
175
|
-
def reset_application_authorization(token, options = {})
|
|
176
|
-
opts = options.dup
|
|
177
|
-
key = opts.delete(:client_id) || client_id
|
|
178
|
-
secret = opts.delete(:client_secret) || client_secret
|
|
179
|
-
|
|
180
|
-
as_app(key, secret) do |app_client|
|
|
181
|
-
app_client.post "applications/#{client_id}/tokens/#{token}", opts
|
|
182
|
-
end
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
# Revoke a token
|
|
186
|
-
#
|
|
187
|
-
# Applications can revoke (delete) a token
|
|
188
|
-
#
|
|
189
|
-
# @param token [String] 40 character GitHub OAuth access token
|
|
190
|
-
#
|
|
191
|
-
# @return [Boolean] Result
|
|
192
|
-
# @see https://developer.github.com/v3/oauth_authorizations/#revoke-an-authorization-for-an-application
|
|
193
|
-
# @example
|
|
194
|
-
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
|
195
|
-
# client.revoke_application_authorization('deadbeef1234567890deadbeef987654321')
|
|
196
|
-
def revoke_application_authorization(token, options = {})
|
|
197
|
-
opts = options.dup
|
|
198
|
-
key = opts.delete(:client_id) || client_id
|
|
199
|
-
secret = opts.delete(:client_secret) || client_secret
|
|
200
|
-
|
|
201
|
-
as_app(key, secret) do |app_client|
|
|
202
|
-
app_client.delete "applications/#{client_id}/tokens/#{token}", opts
|
|
203
|
-
|
|
204
|
-
app_client.last_response.status == 204
|
|
205
|
-
end
|
|
206
|
-
rescue Octokit::NotFound
|
|
207
|
-
false
|
|
208
|
-
end
|
|
209
|
-
alias :delete_application_authorization :revoke_application_authorization
|
|
210
|
-
|
|
211
143
|
# Revoke all tokens for an app
|
|
212
144
|
#
|
|
213
145
|
# Applications can revoke all of their tokens in a single request
|
|
@@ -233,7 +165,7 @@ module Octokit
|
|
|
233
165
|
def authorize_url(app_id = client_id, options = {})
|
|
234
166
|
opts = options.dup
|
|
235
167
|
if app_id.to_s.empty?
|
|
236
|
-
raise Octokit::ApplicationCredentialsRequired
|
|
168
|
+
raise Octokit::ApplicationCredentialsRequired, "client_id required"
|
|
237
169
|
end
|
|
238
170
|
authorize_url = opts.delete(:endpoint) || Octokit.web_endpoint
|
|
239
171
|
authorize_url << "login/oauth/authorize?client_id=#{app_id}"
|
|
@@ -131,6 +131,7 @@ module Octokit
|
|
|
131
131
|
# @example List all issues events for issue #38 on octokit/octokit.rb
|
|
132
132
|
# Octokit.issue_events("octokit/octokit.rb", 38)
|
|
133
133
|
def issue_events(repo, number, options = {})
|
|
134
|
+
options = ensure_api_media_type(:project_card_events, options)
|
|
134
135
|
paginate "#{Repository.path repo}/issues/#{number}/events", options
|
|
135
136
|
end
|
|
136
137
|
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Octokit
|
|
4
|
+
class Client
|
|
5
|
+
|
|
6
|
+
# Methods for the OauthApplications API
|
|
7
|
+
#
|
|
8
|
+
# @see https://developer.github.com/v3/apps/oauth_applications
|
|
9
|
+
module OauthApplications
|
|
10
|
+
|
|
11
|
+
# Check if a token is valid.
|
|
12
|
+
#
|
|
13
|
+
# Applications can check if a token is valid without rate limits.
|
|
14
|
+
#
|
|
15
|
+
# @param access_token [String] 40 character GitHub OAuth access token
|
|
16
|
+
#
|
|
17
|
+
# @return [Sawyer::Resource] A single authorization for the authenticated user
|
|
18
|
+
# @see https://developer.github.com/v3/apps/oauth_applications/#check-a-token
|
|
19
|
+
#
|
|
20
|
+
# @example
|
|
21
|
+
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
|
22
|
+
# client.check_token('deadbeef1234567890deadbeef987654321')
|
|
23
|
+
def check_token(access_token, options = {})
|
|
24
|
+
options = ensure_api_media_type(:applications_api, options.dup)
|
|
25
|
+
options[:access_token] = access_token
|
|
26
|
+
|
|
27
|
+
key = options.delete(:client_id) || client_id
|
|
28
|
+
secret = options.delete(:client_secret) || client_secret
|
|
29
|
+
|
|
30
|
+
as_app(key, secret) do |app_client|
|
|
31
|
+
app_client.post "applications/#{client_id}/token", options
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
alias check_application_authorization check_token
|
|
35
|
+
|
|
36
|
+
# Reset a token
|
|
37
|
+
#
|
|
38
|
+
# Applications can reset a token without requiring a user to re-authorize.
|
|
39
|
+
#
|
|
40
|
+
# @param access_token [String] 40 character GitHub OAuth access token
|
|
41
|
+
#
|
|
42
|
+
# @return [Sawyer::Resource] A single authorization for the authenticated user
|
|
43
|
+
# @see https://developer.github.com/v3/apps/oauth_applications/#reset-a-token
|
|
44
|
+
#
|
|
45
|
+
# @example
|
|
46
|
+
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
|
47
|
+
# client.reset_token('deadbeef1234567890deadbeef987654321')
|
|
48
|
+
def reset_token(access_token, options = {})
|
|
49
|
+
options = ensure_api_media_type(:applications_api, options.dup)
|
|
50
|
+
options[:access_token] = access_token
|
|
51
|
+
|
|
52
|
+
key = options.delete(:client_id) || client_id
|
|
53
|
+
secret = options.delete(:client_secret) || client_secret
|
|
54
|
+
|
|
55
|
+
as_app(key, secret) do |app_client|
|
|
56
|
+
app_client.patch "applications/#{client_id}/token", options
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
alias reset_application_authorization reset_token
|
|
60
|
+
|
|
61
|
+
# Delete an app token
|
|
62
|
+
#
|
|
63
|
+
# Applications can revoke (delete) a token
|
|
64
|
+
#
|
|
65
|
+
# @param token [String] 40 character GitHub OAuth access token
|
|
66
|
+
#
|
|
67
|
+
# @return [Boolean] Result
|
|
68
|
+
# @see https://developer.github.com/v3/apps/oauth_applications/#delete-an-app-token
|
|
69
|
+
#
|
|
70
|
+
# @example
|
|
71
|
+
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
|
72
|
+
# client.delete_token('deadbeef1234567890deadbeef987654321')
|
|
73
|
+
def delete_app_token(access_token, options = {})
|
|
74
|
+
options = ensure_api_media_type(:applications_api, options.dup)
|
|
75
|
+
options[:access_token] = access_token
|
|
76
|
+
|
|
77
|
+
key = options.delete(:client_id) || client_id
|
|
78
|
+
secret = options.delete(:client_secret) || client_secret
|
|
79
|
+
|
|
80
|
+
begin
|
|
81
|
+
as_app(key, secret) do |app_client|
|
|
82
|
+
app_client.delete "applications/#{client_id}/token", options
|
|
83
|
+
app_client.last_response.status == 204
|
|
84
|
+
end
|
|
85
|
+
rescue Octokit::NotFound
|
|
86
|
+
false
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
alias delete_application_authorization delete_app_token
|
|
90
|
+
alias revoke_application_authorization delete_app_token
|
|
91
|
+
|
|
92
|
+
# Delete an app authorization
|
|
93
|
+
#
|
|
94
|
+
# OAuth application owners can revoke a grant for their OAuth application and a specific user.
|
|
95
|
+
#
|
|
96
|
+
# @param accces_token [String] 40 character GitHub OAuth access token
|
|
97
|
+
#
|
|
98
|
+
# @return [Boolean] Result
|
|
99
|
+
# @see https://developer.github.com/v3/apps/oauth_applications/#delete-an-app-token
|
|
100
|
+
#
|
|
101
|
+
# @example
|
|
102
|
+
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
|
103
|
+
# client.delete_app_authorization('deadbeef1234567890deadbeef987654321')
|
|
104
|
+
def delete_app_authorization(access_token, options = {})
|
|
105
|
+
options = ensure_api_media_type(:applications_api, options.dup)
|
|
106
|
+
options[:access_token] = access_token
|
|
107
|
+
|
|
108
|
+
key = options.delete(:client_id) || client_id
|
|
109
|
+
secret = options.delete(:client_secret) || client_secret
|
|
110
|
+
|
|
111
|
+
begin
|
|
112
|
+
as_app(key, secret) do |app_client|
|
|
113
|
+
app_client.delete "applications/#{client_id}/grant", options
|
|
114
|
+
app_client.last_response.status == 204
|
|
115
|
+
end
|
|
116
|
+
rescue Octokit::NotFound
|
|
117
|
+
false
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
@@ -44,7 +44,7 @@ module Octokit
|
|
|
44
44
|
# @option options [Integer] :page Page of paginated results
|
|
45
45
|
# @option options [Integer] :per_page Number of items per page
|
|
46
46
|
# @return [Sawyer::Resource] Search results object
|
|
47
|
-
# @see https://developer.github.com/v3/search/#search-issues
|
|
47
|
+
# @see https://developer.github.com/v3/search/#search-issues-and-pull-requests
|
|
48
48
|
def search_issues(query, options = {})
|
|
49
49
|
search "search/issues", query, options
|
|
50
50
|
end
|
data/lib/octokit/preview.rb
CHANGED
|
@@ -4,6 +4,7 @@ module Octokit
|
|
|
4
4
|
module Preview
|
|
5
5
|
|
|
6
6
|
PREVIEW_TYPES = {
|
|
7
|
+
:applications_api => 'application/vnd.github.doctor-strange-preview+json'.freeze,
|
|
7
8
|
:branch_protection => 'application/vnd.github.luke-cage-preview+json'.freeze,
|
|
8
9
|
:checks => 'application/vnd.github.antiope-preview+json'.freeze,
|
|
9
10
|
:commit_search => 'application/vnd.github.cloak-preview+json'.freeze,
|
|
@@ -26,6 +27,7 @@ module Octokit
|
|
|
26
27
|
:drafts => 'application/vnd.github.shadow-cat-preview'.freeze,
|
|
27
28
|
:template_repositories => 'application/vnd.github.baptiste-preview+json'.freeze,
|
|
28
29
|
:uninstall_github_app => 'application/vnd.github.gambit-preview+json'.freeze,
|
|
30
|
+
:project_card_events => 'application/vnd.github.starfox-preview+json'.freeze,
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
def ensure_api_media_type(type, options)
|
data/lib/octokit/version.rb
CHANGED
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.
|
|
4
|
+
version: 4.18.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Wynn Netherland
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2020-
|
|
13
|
+
date: 2020-03-25 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: bundler
|
|
@@ -111,6 +111,7 @@ files:
|
|
|
111
111
|
- lib/octokit/client/meta.rb
|
|
112
112
|
- lib/octokit/client/milestones.rb
|
|
113
113
|
- lib/octokit/client/notifications.rb
|
|
114
|
+
- lib/octokit/client/oauth_applications.rb
|
|
114
115
|
- lib/octokit/client/objects.rb
|
|
115
116
|
- lib/octokit/client/organizations.rb
|
|
116
117
|
- lib/octokit/client/pages.rb
|
|
@@ -176,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
176
177
|
- !ruby/object:Gem::Version
|
|
177
178
|
version: 1.3.5
|
|
178
179
|
requirements: []
|
|
179
|
-
rubygems_version: 3.
|
|
180
|
+
rubygems_version: 3.0.3
|
|
180
181
|
signing_key:
|
|
181
182
|
specification_version: 4
|
|
182
183
|
summary: Ruby toolkit for working with the GitHub API
|