octokit 4.6.2 → 6.1.1
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 +239 -118
- data/Rakefile +12 -12
- data/lib/ext/sawyer/relation.rb +4 -2
- data/lib/octokit/arguments.rb +2 -2
- data/lib/octokit/authentication.rb +20 -14
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +59 -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 +222 -0
- data/lib/octokit/client/checks.rb +200 -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 +31 -34
- data/lib/octokit/client/community_profile.rb +21 -0
- data/lib/octokit/client/contents.rb +25 -20
- data/lib/octokit/client/deployments.rb +25 -5
- data/lib/octokit/client/downloads.rb +5 -6
- data/lib/octokit/client/emojis.rb +3 -3
- data/lib/octokit/client/environments.rb +55 -0
- data/lib/octokit/client/events.rb +4 -4
- data/lib/octokit/client/feeds.rb +4 -5
- data/lib/octokit/client/gists.rb +7 -6
- data/lib/octokit/client/gitignore.rb +3 -3
- data/lib/octokit/client/hooks.rb +9 -19
- data/lib/octokit/client/issues.rb +60 -14
- data/lib/octokit/client/labels.rb +17 -17
- data/lib/octokit/client/legacy_search.rb +3 -3
- data/lib/octokit/client/licenses.rb +4 -7
- 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 +5 -5
- data/lib/octokit/client/notifications.rb +6 -10
- data/lib/octokit/client/oauth_applications.rb +116 -0
- data/lib/octokit/client/objects.rb +14 -14
- data/lib/octokit/client/organizations.rb +238 -61
- data/lib/octokit/client/pages.rb +5 -7
- data/lib/octokit/client/projects.rb +50 -70
- data/lib/octokit/client/pub_sub_hubbub.rb +16 -16
- data/lib/octokit/client/pull_requests.rb +58 -46
- data/lib/octokit/client/rate_limit.rb +11 -13
- data/lib/octokit/client/reactions.rb +6 -11
- data/lib/octokit/client/refs.rb +32 -19
- data/lib/octokit/client/releases.rb +14 -13
- data/lib/octokit/client/repositories.rb +195 -54
- data/lib/octokit/client/repository_invitations.rb +4 -11
- 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 +8 -13
- data/lib/octokit/client/stats.rb +12 -9
- data/lib/octokit/client/statuses.rb +6 -6
- data/lib/octokit/client/tokens.rb +31 -0
- data/lib/octokit/client/traffic.rb +6 -11
- data/lib/octokit/client/users.rb +106 -25
- data/lib/octokit/client.rb +66 -17
- data/lib/octokit/configurable.rb +42 -30
- data/lib/octokit/connection.rb +43 -21
- data/lib/octokit/default.rb +63 -34
- 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 +5 -6
- data/lib/octokit/enterprise_admin_client/search_indexing.rb +8 -9
- data/lib/octokit/enterprise_admin_client/users.rb +17 -16
- data/lib/octokit/enterprise_admin_client.rb +9 -3
- data/lib/octokit/enterprise_management_console_client/management_console.rb +33 -33
- data/lib/octokit/enterprise_management_console_client.rb +9 -3
- data/lib/octokit/error.rb +107 -26
- data/lib/octokit/gist.rb +4 -5
- data/lib/octokit/middleware/follow_redirects.rb +17 -13
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +11 -9
- data/lib/octokit/repo_arguments.rb +2 -3
- data/lib/octokit/repository.rb +27 -25
- 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 +5 -3
- data/lib/octokit/warnable.rb +4 -5
- data/lib/octokit.rb +15 -8
- data/octokit.gemspec +13 -10
- metadata +55 -22
- data/lib/octokit/client/authorizations.rb +0 -244
- data/lib/octokit/preview.rb +0 -35
data/lib/octokit/connection.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'sawyer'
|
2
4
|
require 'octokit/authentication'
|
3
5
|
module Octokit
|
4
|
-
|
5
6
|
# Network layer for API clients.
|
6
7
|
module Connection
|
7
|
-
|
8
8
|
include Octokit::Authentication
|
9
9
|
|
10
10
|
# Header keys that can be passed in options hash to {#get},{#head}
|
11
|
-
CONVENIENCE_HEADERS = Set.new([
|
11
|
+
CONVENIENCE_HEADERS = Set.new(%i[accept content_type])
|
12
12
|
|
13
13
|
# Make a HTTP GET request
|
14
14
|
#
|
@@ -75,17 +75,17 @@ module Octokit
|
|
75
75
|
# contains the contents of the requests so far and the second parameter
|
76
76
|
# contains the latest response.
|
77
77
|
# @return [Sawyer::Resource]
|
78
|
-
def paginate(url, options = {}
|
79
|
-
opts = parse_query_and_convenience_headers(options
|
78
|
+
def paginate(url, options = {})
|
79
|
+
opts = parse_query_and_convenience_headers(options)
|
80
80
|
if @auto_paginate || @per_page
|
81
|
-
opts[:query][:per_page] ||=
|
81
|
+
opts[:query][:per_page] ||= @per_page || (@auto_paginate ? 100 : nil)
|
82
82
|
end
|
83
83
|
|
84
84
|
data = request(:get, url, opts.dup)
|
85
85
|
|
86
86
|
if @auto_paginate
|
87
87
|
while @last_response.rels[:next] && rate_limit.remaining > 0
|
88
|
-
@last_response = @last_response.rels[:next].get(:
|
88
|
+
@last_response = @last_response.rels[:next].get(headers: opts[:headers])
|
89
89
|
if block_given?
|
90
90
|
yield(data, @last_response)
|
91
91
|
else
|
@@ -104,14 +104,16 @@ module Octokit
|
|
104
104
|
def agent
|
105
105
|
@agent ||= Sawyer::Agent.new(endpoint, sawyer_options) do |http|
|
106
106
|
http.headers[:accept] = default_media_type
|
107
|
-
http.headers[:content_type] =
|
107
|
+
http.headers[:content_type] = 'application/json'
|
108
108
|
http.headers[:user_agent] = user_agent
|
109
109
|
if basic_authenticated?
|
110
|
-
http.
|
110
|
+
http.request(*FARADAY_BASIC_AUTH_KEYS, @login, @password)
|
111
111
|
elsif token_authenticated?
|
112
|
-
http.authorization 'token', @access_token
|
112
|
+
http.request :authorization, 'token', @access_token
|
113
|
+
elsif bearer_authenticated?
|
114
|
+
http.request :authorization, 'Bearer', @bearer_token
|
113
115
|
elsif application_authenticated?
|
114
|
-
http.
|
116
|
+
http.request(*FARADAY_BASIC_AUTH_KEYS, @client_id, @client_secret)
|
115
117
|
end
|
116
118
|
end
|
117
119
|
end
|
@@ -120,7 +122,7 @@ module Octokit
|
|
120
122
|
#
|
121
123
|
# @return [Sawyer::Resource]
|
122
124
|
def root
|
123
|
-
get
|
125
|
+
get '/'
|
124
126
|
end
|
125
127
|
|
126
128
|
# Response for last HTTP request
|
@@ -151,8 +153,11 @@ module Octokit
|
|
151
153
|
end
|
152
154
|
end
|
153
155
|
|
154
|
-
@last_response = response = agent.call(method, URI
|
155
|
-
response
|
156
|
+
@last_response = response = agent.call(method, Addressable::URI.parse(path.to_s).normalize.to_s, data, options)
|
157
|
+
response_data_correctly_encoded(response)
|
158
|
+
rescue Octokit::Error => e
|
159
|
+
@last_response = nil
|
160
|
+
raise e
|
156
161
|
end
|
157
162
|
|
158
163
|
# Executes the request, checking if it was successful
|
@@ -160,37 +165,54 @@ module Octokit
|
|
160
165
|
# @return [Boolean] True on success, false otherwise
|
161
166
|
def boolean_from_response(method, path, options = {})
|
162
167
|
request(method, path, options)
|
163
|
-
@last_response.status
|
168
|
+
[201, 202, 204].include? @last_response.status
|
164
169
|
rescue Octokit::NotFound
|
165
170
|
false
|
166
171
|
end
|
167
172
|
|
168
|
-
|
169
173
|
def sawyer_options
|
170
174
|
opts = {
|
171
|
-
:
|
175
|
+
links_parser: Sawyer::LinkParsers::Simple.new
|
172
176
|
}
|
173
177
|
conn_opts = @connection_options
|
174
|
-
conn_opts[:builder] = @middleware if @middleware
|
178
|
+
conn_opts[:builder] = @middleware.dup if @middleware
|
175
179
|
conn_opts[:proxy] = @proxy if @proxy
|
180
|
+
if conn_opts[:ssl].nil?
|
181
|
+
conn_opts[:ssl] = { verify_mode: @ssl_verify_mode } if @ssl_verify_mode
|
182
|
+
else
|
183
|
+
verify = @connection_options[:ssl][:verify]
|
184
|
+
conn_opts[:ssl] = {
|
185
|
+
verify: verify,
|
186
|
+
verify_mode: verify == false ? 0 : @ssl_verify_mode
|
187
|
+
}
|
188
|
+
end
|
176
189
|
opts[:faraday] = Faraday.new(conn_opts)
|
177
190
|
|
178
191
|
opts
|
179
192
|
end
|
180
193
|
|
181
194
|
def parse_query_and_convenience_headers(options)
|
182
|
-
|
195
|
+
options = options.dup
|
196
|
+
headers = options.delete(:headers) { {} }
|
183
197
|
CONVENIENCE_HEADERS.each do |h|
|
184
198
|
if header = options.delete(h)
|
185
199
|
headers[h] = header
|
186
200
|
end
|
187
201
|
end
|
188
202
|
query = options.delete(:query)
|
189
|
-
opts = {:
|
190
|
-
opts[:query].merge!(query) if query
|
203
|
+
opts = { query: options }
|
204
|
+
opts[:query].merge!(query) if query.is_a?(Hash)
|
191
205
|
opts[:headers] = headers unless headers.empty?
|
192
206
|
|
193
207
|
opts
|
194
208
|
end
|
209
|
+
|
210
|
+
def response_data_correctly_encoded(response)
|
211
|
+
content_type = response.headers.fetch('content-type', '')
|
212
|
+
return response.data unless content_type.include?('charset') && response.data.is_a?(String)
|
213
|
+
|
214
|
+
reported_encoding = content_type.match(/charset=([^ ]+)/)[1]
|
215
|
+
response.data.force_encoding(reported_encoding)
|
216
|
+
end
|
195
217
|
end
|
196
218
|
end
|
data/lib/octokit/default.rb
CHANGED
@@ -1,30 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'octokit/middleware/follow_redirects'
|
2
4
|
require 'octokit/response/raise_error'
|
3
5
|
require 'octokit/response/feed_parser'
|
4
6
|
require 'octokit/version'
|
7
|
+
require 'octokit/warnable'
|
5
8
|
|
6
|
-
|
9
|
+
if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
|
10
|
+
begin
|
11
|
+
require 'faraday/retry'
|
12
|
+
rescue LoadError
|
13
|
+
Octokit::Warnable.octokit_warn 'To use retry middleware with Faraday v2.0+, install `faraday-retry` gem'
|
14
|
+
end
|
15
|
+
end
|
7
16
|
|
17
|
+
module Octokit
|
8
18
|
# Default configuration options for {Client}
|
9
19
|
module Default
|
10
|
-
|
11
20
|
# Default API endpoint
|
12
|
-
API_ENDPOINT =
|
21
|
+
API_ENDPOINT = 'https://api.github.com'
|
13
22
|
|
14
23
|
# Default User Agent header string
|
15
|
-
USER_AGENT = "Octokit Ruby Gem #{Octokit::VERSION}"
|
24
|
+
USER_AGENT = "Octokit Ruby Gem #{Octokit::VERSION}"
|
16
25
|
|
17
26
|
# Default media type
|
18
|
-
MEDIA_TYPE =
|
27
|
+
MEDIA_TYPE = 'application/vnd.github.v3+json'
|
19
28
|
|
20
29
|
# Default WEB endpoint
|
21
|
-
WEB_ENDPOINT =
|
22
|
-
|
23
|
-
# In Faraday 0.9, Faraday::Builder was renamed to Faraday::RackBuilder
|
24
|
-
RACK_BUILDER_CLASS = defined?(Faraday::RackBuilder) ? Faraday::RackBuilder : Faraday::Builder
|
30
|
+
WEB_ENDPOINT = 'https://github.com'
|
25
31
|
|
26
32
|
# Default Faraday middleware stack
|
27
|
-
MIDDLEWARE =
|
33
|
+
MIDDLEWARE = Faraday::RackBuilder.new do |builder|
|
34
|
+
# In Faraday 2.x, Faraday::Request::Retry was moved to a separate gem
|
35
|
+
# so we use it only when it's available.
|
36
|
+
if defined?(Faraday::Request::Retry)
|
37
|
+
retry_exceptions = Faraday::Request::Retry::DEFAULT_EXCEPTIONS + [Octokit::ServerError]
|
38
|
+
builder.use Faraday::Request::Retry, exceptions: retry_exceptions
|
39
|
+
elsif defined?(Faraday::Retry::Middleware)
|
40
|
+
retry_exceptions = Faraday::Retry::Middleware::DEFAULT_EXCEPTIONS + [Octokit::ServerError]
|
41
|
+
builder.use Faraday::Retry::Middleware, exceptions: retry_exceptions
|
42
|
+
end
|
43
|
+
|
28
44
|
builder.use Octokit::Middleware::FollowRedirects
|
29
45
|
builder.use Octokit::Response::RaiseError
|
30
46
|
builder.use Octokit::Response::FeedParser
|
@@ -32,62 +48,67 @@ module Octokit
|
|
32
48
|
end
|
33
49
|
|
34
50
|
class << self
|
35
|
-
|
36
51
|
# Configuration options
|
37
52
|
# @return [Hash]
|
38
53
|
def options
|
39
|
-
|
54
|
+
Octokit::Configurable.keys.to_h { |key| [key, send(key)] }
|
40
55
|
end
|
41
56
|
|
42
57
|
# Default access token from ENV
|
43
58
|
# @return [String]
|
44
59
|
def access_token
|
45
|
-
ENV
|
60
|
+
ENV.fetch('OCTOKIT_ACCESS_TOKEN', nil)
|
46
61
|
end
|
47
62
|
|
48
63
|
# Default API endpoint from ENV or {API_ENDPOINT}
|
49
64
|
# @return [String]
|
50
65
|
def api_endpoint
|
51
|
-
ENV
|
66
|
+
ENV.fetch('OCTOKIT_API_ENDPOINT') { API_ENDPOINT }
|
52
67
|
end
|
53
68
|
|
54
69
|
# Default pagination preference from ENV
|
55
70
|
# @return [String]
|
56
71
|
def auto_paginate
|
57
|
-
ENV
|
72
|
+
ENV.fetch('OCTOKIT_AUTO_PAGINATE', nil)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Default bearer token from ENV
|
76
|
+
# @return [String]
|
77
|
+
def bearer_token
|
78
|
+
ENV.fetch('OCTOKIT_BEARER_TOKEN', nil)
|
58
79
|
end
|
59
80
|
|
60
81
|
# Default OAuth app key from ENV
|
61
82
|
# @return [String]
|
62
83
|
def client_id
|
63
|
-
ENV
|
84
|
+
ENV.fetch('OCTOKIT_CLIENT_ID', nil)
|
64
85
|
end
|
65
86
|
|
66
87
|
# Default OAuth app secret from ENV
|
67
88
|
# @return [String]
|
68
89
|
def client_secret
|
69
|
-
ENV
|
90
|
+
ENV.fetch('OCTOKIT_SECRET', nil)
|
70
91
|
end
|
71
92
|
|
72
93
|
# Default management console password from ENV
|
73
94
|
# @return [String]
|
74
95
|
def management_console_password
|
75
|
-
ENV
|
96
|
+
ENV.fetch('OCTOKIT_ENTERPRISE_MANAGEMENT_CONSOLE_PASSWORD', nil)
|
76
97
|
end
|
77
98
|
|
78
99
|
# Default management console endpoint from ENV
|
79
100
|
# @return [String]
|
80
101
|
def management_console_endpoint
|
81
|
-
ENV
|
102
|
+
ENV.fetch('OCTOKIT_ENTERPRISE_MANAGEMENT_CONSOLE_ENDPOINT', nil)
|
82
103
|
end
|
83
104
|
|
84
105
|
# Default options for Faraday::Connection
|
85
106
|
# @return [Hash]
|
86
107
|
def connection_options
|
87
108
|
{
|
88
|
-
:
|
89
|
-
:
|
90
|
-
:
|
109
|
+
headers: {
|
110
|
+
accept: default_media_type,
|
111
|
+
user_agent: user_agent
|
91
112
|
}
|
92
113
|
}
|
93
114
|
end
|
@@ -95,13 +116,13 @@ module Octokit
|
|
95
116
|
# Default media type from ENV or {MEDIA_TYPE}
|
96
117
|
# @return [String]
|
97
118
|
def default_media_type
|
98
|
-
ENV
|
119
|
+
ENV.fetch('OCTOKIT_DEFAULT_MEDIA_TYPE') { MEDIA_TYPE }
|
99
120
|
end
|
100
121
|
|
101
122
|
# Default GitHub username for Basic Auth from ENV
|
102
123
|
# @return [String]
|
103
124
|
def login
|
104
|
-
ENV
|
125
|
+
ENV.fetch('OCTOKIT_LOGIN', nil)
|
105
126
|
end
|
106
127
|
|
107
128
|
# Default middleware stack for Faraday::Connection
|
@@ -114,47 +135,55 @@ module Octokit
|
|
114
135
|
# Default GitHub password for Basic Auth from ENV
|
115
136
|
# @return [String]
|
116
137
|
def password
|
117
|
-
ENV
|
138
|
+
ENV.fetch('OCTOKIT_PASSWORD', nil)
|
118
139
|
end
|
119
140
|
|
120
141
|
# Default pagination page size from ENV
|
121
|
-
# @return [
|
142
|
+
# @return [Integer] Page size
|
122
143
|
def per_page
|
123
|
-
page_size = ENV
|
144
|
+
page_size = ENV.fetch('OCTOKIT_PER_PAGE', nil)
|
124
145
|
|
125
|
-
page_size
|
146
|
+
page_size&.to_i
|
126
147
|
end
|
127
148
|
|
128
149
|
# Default proxy server URI for Faraday connection from ENV
|
129
150
|
# @return [String]
|
130
151
|
def proxy
|
131
|
-
ENV
|
152
|
+
ENV.fetch('OCTOKIT_PROXY', nil)
|
153
|
+
end
|
154
|
+
|
155
|
+
# Default SSL verify mode from ENV
|
156
|
+
# @return [Integer]
|
157
|
+
def ssl_verify_mode
|
158
|
+
# 0 is OpenSSL::SSL::VERIFY_NONE
|
159
|
+
# 1 is OpenSSL::SSL::SSL_VERIFY_PEER
|
160
|
+
# the standard default for SSL is SSL_VERIFY_PEER which requires a server certificate check on the client
|
161
|
+
ENV.fetch('OCTOKIT_SSL_VERIFY_MODE', 1).to_i
|
132
162
|
end
|
133
163
|
|
134
164
|
# Default User-Agent header string from ENV or {USER_AGENT}
|
135
165
|
# @return [String]
|
136
166
|
def user_agent
|
137
|
-
ENV
|
167
|
+
ENV.fetch('OCTOKIT_USER_AGENT') { USER_AGENT }
|
138
168
|
end
|
139
169
|
|
140
170
|
# Default web endpoint from ENV or {WEB_ENDPOINT}
|
141
171
|
# @return [String]
|
142
172
|
def web_endpoint
|
143
|
-
ENV
|
173
|
+
ENV.fetch('OCTOKIT_WEB_ENDPOINT') { WEB_ENDPOINT }
|
144
174
|
end
|
145
175
|
|
146
176
|
# Default behavior for reading .netrc file
|
147
177
|
# @return [Boolean]
|
148
178
|
def netrc
|
149
|
-
ENV
|
179
|
+
ENV.fetch('OCTOKIT_NETRC', false)
|
150
180
|
end
|
151
181
|
|
152
182
|
# Default path for .netrc file
|
153
183
|
# @return [String]
|
154
184
|
def netrc_file
|
155
|
-
ENV
|
185
|
+
ENV.fetch('OCTOKIT_NETRC_FILE') { File.join(Dir.home.to_s, '.netrc') }
|
156
186
|
end
|
157
|
-
|
158
187
|
end
|
159
188
|
end
|
160
189
|
end
|
@@ -1,18 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class EnterpriseAdminClient
|
3
|
-
|
4
5
|
# Methods for the Enterprise Admin Stats API
|
5
6
|
#
|
6
|
-
# @see https://developer.github.com/v3/enterprise/admin_stats/
|
7
|
+
# @see https://developer.github.com/v3/enterprise-admin/admin_stats/
|
7
8
|
module AdminStats
|
8
|
-
|
9
9
|
# Get all available stats
|
10
10
|
#
|
11
11
|
# @return [Sawyer::Resource] All available stats
|
12
12
|
# @example Get all available stats
|
13
13
|
# @client.admin_stats
|
14
14
|
def admin_stats
|
15
|
-
get_admin_stats
|
15
|
+
get_admin_stats 'all'
|
16
16
|
end
|
17
17
|
|
18
18
|
# Get only repository-related stats
|
@@ -21,7 +21,7 @@ module Octokit
|
|
21
21
|
# @example Get only repository-related stats
|
22
22
|
# @client.admin_repository_stats
|
23
23
|
def admin_repository_stats
|
24
|
-
get_admin_stats
|
24
|
+
get_admin_stats 'repos'
|
25
25
|
end
|
26
26
|
|
27
27
|
# Get only hooks-related stats
|
@@ -30,7 +30,7 @@ module Octokit
|
|
30
30
|
# @example Get only hooks-related stats
|
31
31
|
# @client.admin_hooks_stats
|
32
32
|
def admin_hooks_stats
|
33
|
-
get_admin_stats
|
33
|
+
get_admin_stats 'hooks'
|
34
34
|
end
|
35
35
|
|
36
36
|
# Get only pages-related stats
|
@@ -39,7 +39,7 @@ module Octokit
|
|
39
39
|
# @example Get only pages-related stats
|
40
40
|
# @client.admin_pages_stats
|
41
41
|
def admin_pages_stats
|
42
|
-
get_admin_stats
|
42
|
+
get_admin_stats 'pages'
|
43
43
|
end
|
44
44
|
|
45
45
|
# Get only organization-related stats
|
@@ -48,7 +48,7 @@ module Octokit
|
|
48
48
|
# @example Get only organization-related stats
|
49
49
|
# @client.admin_organization_stats
|
50
50
|
def admin_organization_stats
|
51
|
-
get_admin_stats
|
51
|
+
get_admin_stats 'orgs'
|
52
52
|
end
|
53
53
|
|
54
54
|
# Get only user-related stats
|
@@ -57,7 +57,7 @@ module Octokit
|
|
57
57
|
# @example Get only user-related stats
|
58
58
|
# @client.admin_users_stats
|
59
59
|
def admin_users_stats
|
60
|
-
get_admin_stats
|
60
|
+
get_admin_stats 'users'
|
61
61
|
end
|
62
62
|
|
63
63
|
# Get only pull request-related stats
|
@@ -66,7 +66,7 @@ module Octokit
|
|
66
66
|
# @example Get only pull request-related stats
|
67
67
|
# @client.admin_pull_requests_stats
|
68
68
|
def admin_pull_requests_stats
|
69
|
-
get_admin_stats
|
69
|
+
get_admin_stats 'pulls'
|
70
70
|
end
|
71
71
|
|
72
72
|
# Get only issue-related stats
|
@@ -75,7 +75,7 @@ module Octokit
|
|
75
75
|
# @example Get only issue-related stats
|
76
76
|
# @client.admin_issues_stats
|
77
77
|
def admin_issues_stats
|
78
|
-
get_admin_stats
|
78
|
+
get_admin_stats 'issues'
|
79
79
|
end
|
80
80
|
|
81
81
|
# Get only milestone-related stats
|
@@ -84,7 +84,7 @@ module Octokit
|
|
84
84
|
# @example Get only milestone-related stats
|
85
85
|
# @client.admin_milestones_stats
|
86
86
|
def admin_milestones_stats
|
87
|
-
get_admin_stats
|
87
|
+
get_admin_stats 'milestones'
|
88
88
|
end
|
89
89
|
|
90
90
|
# Get only gist-related stats
|
@@ -93,7 +93,7 @@ module Octokit
|
|
93
93
|
# @example Get only gist-related stats
|
94
94
|
# @client.admin_gits_stats
|
95
95
|
def admin_gists_stats
|
96
|
-
get_admin_stats
|
96
|
+
get_admin_stats 'gists'
|
97
97
|
end
|
98
98
|
|
99
99
|
# Get only comment-related stats
|
@@ -102,7 +102,7 @@ module Octokit
|
|
102
102
|
# @example Get only comment-related stats
|
103
103
|
# @client.admin_comments_stats
|
104
104
|
def admin_comments_stats
|
105
|
-
get_admin_stats
|
105
|
+
get_admin_stats 'comments'
|
106
106
|
end
|
107
107
|
|
108
108
|
private
|
@@ -115,6 +115,5 @@ module Octokit
|
|
115
115
|
get "enterprise/stats/#{metric}"
|
116
116
|
end
|
117
117
|
end
|
118
|
-
|
119
118
|
end
|
120
119
|
end
|
@@ -1,18 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class EnterpriseAdminClient
|
3
|
-
|
4
5
|
# Methods for the Enterprise License API
|
5
6
|
#
|
6
|
-
# @see https://developer.github.com/v3/enterprise/license/
|
7
|
+
# @see https://developer.github.com/v3/enterprise-admin/license/
|
7
8
|
module License
|
8
|
-
|
9
9
|
# Get information about the Enterprise license
|
10
10
|
#
|
11
11
|
# @return [Sawyer::Resource] The license information
|
12
12
|
def license_info
|
13
|
-
get
|
13
|
+
get 'enterprise/settings/license'
|
14
14
|
end
|
15
|
-
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class EnterpriseAdminClient
|
3
|
-
|
4
5
|
# Methods for the Enterprise Orgs API
|
5
6
|
#
|
6
|
-
# @see https://developer.github.com/v3/enterprise/orgs/
|
7
|
+
# @see https://developer.github.com/v3/enterprise-admin/orgs/
|
7
8
|
module Orgs
|
8
|
-
|
9
9
|
# Create a new organization on the instance.
|
10
10
|
#
|
11
11
|
# @param login [String] The organization's username.
|
@@ -13,15 +13,14 @@ module Octokit
|
|
13
13
|
# @param options [Hash] A set of options.
|
14
14
|
# @option options [String] :profile_name The organization's display name.
|
15
15
|
# @return [nil]
|
16
|
-
# @see https://developer.github.com/v3/enterprise/orgs/#create-an-organization
|
16
|
+
# @see https://developer.github.com/v3/enterprise-admin/orgs/#create-an-organization
|
17
17
|
# @example
|
18
18
|
# @admin_client.create_organization('SuchAGreatOrg', 'gjtorikian')
|
19
19
|
def create_organization(login, admin, options = {})
|
20
20
|
options[:login] = login
|
21
21
|
options[:admin] = admin
|
22
|
-
post
|
22
|
+
post 'admin/organizations', options
|
23
23
|
end
|
24
|
-
|
25
24
|
end
|
26
25
|
end
|
27
26
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class EnterpriseAdminClient
|
3
|
-
|
4
5
|
# Methods for the Enterprise Search Indexing API
|
5
6
|
#
|
6
|
-
# @see https://developer.github.com/v3/enterprise/search_indexing/
|
7
|
+
# @see https://developer.github.com/v3/enterprise-admin/search_indexing/
|
7
8
|
module SearchIndexing
|
8
|
-
|
9
9
|
# Queue a User or Organization to be indexed
|
10
10
|
#
|
11
11
|
# @param user [String] A GitHub Enterprise user or organization
|
@@ -13,7 +13,7 @@ module Octokit
|
|
13
13
|
def index_user(user)
|
14
14
|
queue_index user
|
15
15
|
end
|
16
|
-
alias
|
16
|
+
alias index_organization index_user
|
17
17
|
|
18
18
|
# Queue a Repository to be indexed
|
19
19
|
#
|
@@ -46,7 +46,7 @@ module Octokit
|
|
46
46
|
def index_users_repositories(user)
|
47
47
|
queue_index "#{user}/*"
|
48
48
|
end
|
49
|
-
alias
|
49
|
+
alias index_organizations_repositories index_users_repositories
|
50
50
|
|
51
51
|
# Queue an index of all the issues across all of a user's or
|
52
52
|
# organization's repositories
|
@@ -56,7 +56,7 @@ module Octokit
|
|
56
56
|
def index_users_repositories_issues(user)
|
57
57
|
queue_index "#{user}/*/issues"
|
58
58
|
end
|
59
|
-
alias
|
59
|
+
alias index_organizations_repositories_issues index_users_repositories_issues
|
60
60
|
|
61
61
|
# Queue an index of all the code contained in all of a user's or
|
62
62
|
# organization's repositories
|
@@ -66,7 +66,7 @@ module Octokit
|
|
66
66
|
def index_users_repositories_code(user)
|
67
67
|
queue_index "#{user}/*/code"
|
68
68
|
end
|
69
|
-
alias
|
69
|
+
alias index_organizations_repositories_code index_users_repositories_code
|
70
70
|
|
71
71
|
private
|
72
72
|
|
@@ -75,9 +75,8 @@ module Octokit
|
|
75
75
|
# @param target [String] Target to index
|
76
76
|
# @return [Sawyer:Resource] Result of the queuing containing `:message`
|
77
77
|
def queue_index(target)
|
78
|
-
post
|
78
|
+
post 'staff/indexing_jobs', target: target
|
79
79
|
end
|
80
80
|
end
|
81
|
-
|
82
81
|
end
|
83
82
|
end
|