pager_duty-connection 2.3.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pager_duty/connection/version.rb +1 -1
- data/lib/pager_duty/connection.rb +38 -4
- data/pager_duty-connection.gemspec +1 -2
- metadata +11 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b054f9ef807fb4106210b76a8a04db02b52599a4c617df4d43f06b3a5f63c67c
|
4
|
+
data.tar.gz: 76f316fd0c10badb260c3353926f9ceb540c5af3b0ae33b597641e0f482ea2a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99dc2a3a2ba5eedb69ac4ac1f758df7bb54a7a632adb9af8bc4a3093bcc8b4638d637f63dd49221838b81ccd7badb51ba68d9f6cdc12ad1a0c0ed5a9aedcc558
|
7
|
+
data.tar.gz: '08a739a697b4f429e42d584ece06a5d7176fcb2099be85c6d1cdc0c79763bbaca2ff6bfc04ce5a17fe9fcc1102545bec6fb54c7a93d39f948a7ed62359d48373'
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'faraday'
|
2
|
-
require '
|
2
|
+
require 'hashie'
|
3
3
|
require 'active_support'
|
4
4
|
require 'active_support/core_ext'
|
5
5
|
require 'active_support/time_with_zone'
|
@@ -106,7 +106,7 @@ module PagerDuty
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
class ParseTimeStrings < Faraday::
|
109
|
+
class ParseTimeStrings < Faraday::Middleware
|
110
110
|
TIME_KEYS = %w(
|
111
111
|
at
|
112
112
|
created_at
|
@@ -137,6 +137,10 @@ module PagerDuty
|
|
137
137
|
pending_actions
|
138
138
|
)
|
139
139
|
|
140
|
+
def on_complete(env)
|
141
|
+
parse(env[:body])
|
142
|
+
end
|
143
|
+
|
140
144
|
def parse(body)
|
141
145
|
case body
|
142
146
|
when Hash, ::Hashie::Mash
|
@@ -179,13 +183,34 @@ module PagerDuty
|
|
179
183
|
end
|
180
184
|
end
|
181
185
|
|
186
|
+
class Mashify < Faraday::Middleware
|
187
|
+
def on_complete(env)
|
188
|
+
env[:body] = parse(env[:body])
|
189
|
+
end
|
190
|
+
|
191
|
+
def parse(body)
|
192
|
+
case body
|
193
|
+
when Hash
|
194
|
+
::Hashie::Mash.new(body)
|
195
|
+
when Array
|
196
|
+
body.map { |item| parse(item) }
|
197
|
+
else
|
198
|
+
body
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
182
203
|
def initialize(token, token_type: :Token, url: API_PREFIX, debug: false)
|
183
204
|
@connection = Faraday.new do |conn|
|
184
205
|
conn.url_prefix = url
|
185
206
|
|
186
207
|
case token_type
|
187
208
|
when :Token
|
188
|
-
|
209
|
+
if faraday_v1?
|
210
|
+
conn.request :token_auth, token
|
211
|
+
else
|
212
|
+
conn.request :authorization, 'Token', token
|
213
|
+
end
|
189
214
|
when :Bearer
|
190
215
|
conn.request :authorization, 'Bearer', token
|
191
216
|
else raise ArgumentError, "invalid token_type: #{token_type.inspect}"
|
@@ -199,7 +224,7 @@ module PagerDuty
|
|
199
224
|
|
200
225
|
# json back, mashify it
|
201
226
|
conn.use ParseTimeStrings
|
202
|
-
conn.
|
227
|
+
conn.use Mashify
|
203
228
|
conn.response :json
|
204
229
|
conn.response :logger, ::Logger.new(STDOUT), bodies: true if debug
|
205
230
|
|
@@ -230,6 +255,7 @@ module PagerDuty
|
|
230
255
|
offset = (page - 1) * limit
|
231
256
|
|
232
257
|
query_params = request[:query_params].merge(offset: offset, limit: limit)
|
258
|
+
query_params.delete(:page)
|
233
259
|
|
234
260
|
run_request(:get, path, **request.merge(query_params: query_params))
|
235
261
|
end
|
@@ -248,6 +274,14 @@ module PagerDuty
|
|
248
274
|
|
249
275
|
private
|
250
276
|
|
277
|
+
def faraday_v1?
|
278
|
+
faraday_version < Gem::Version.new("2")
|
279
|
+
end
|
280
|
+
|
281
|
+
def faraday_version
|
282
|
+
@faraday_version ||= Gem.loaded_specs["faraday"].version
|
283
|
+
end
|
284
|
+
|
251
285
|
def run_request(method, path, body: {}, headers: {}, query_params: {})
|
252
286
|
path = path.gsub(/^\//, '') # strip leading slash, to make sure relative things happen on the connection
|
253
287
|
|
@@ -17,8 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
-
gem.add_dependency "faraday", "
|
21
|
-
gem.add_dependency "faraday_middleware", "~> 1.0"
|
20
|
+
gem.add_dependency "faraday", ">= 1.10", "< 3"
|
22
21
|
gem.add_dependency "activesupport", ">= 3.2", "< 8.0"
|
23
22
|
gem.add_dependency "hashie", ">= 1.2"
|
24
23
|
|
metadata
CHANGED
@@ -1,43 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pager_duty-connection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Nichols
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
17
|
+
- - ">="
|
25
18
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
27
|
-
-
|
28
|
-
name: faraday_middleware
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
19
|
+
version: '1.10'
|
20
|
+
- - "<"
|
32
21
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
22
|
+
version: '3'
|
34
23
|
type: :runtime
|
35
24
|
prerelease: false
|
36
25
|
version_requirements: !ruby/object:Gem::Requirement
|
37
26
|
requirements:
|
38
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.10'
|
30
|
+
- - "<"
|
39
31
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
32
|
+
version: '3'
|
41
33
|
- !ruby/object:Gem::Dependency
|
42
34
|
name: activesupport
|
43
35
|
requirement: !ruby/object:Gem::Requirement
|