pager_duty-connection 1.2.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/pager_duty/connection/version.rb +1 -1
- data/lib/pager_duty/connection.rb +20 -9
- data/pager_duty-connection.gemspec +3 -3
- metadata +9 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e78f2fad96d2bf01daf854fcc9e0bd8d971801caa7d5615e40c692201be07de5
|
4
|
+
data.tar.gz: 5beac4e604804d404580217c091644839a2aa2f468259b15eced7792cfeb1e52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '012509de4ebd913ec9ffd851ed3ddcb85eb4e9ddb16c6ae624b37bb0e54a31cd36db41014bc0e09b36318c1d6b19c699542aec83f489f5e6598c87029ce98070'
|
7
|
+
data.tar.gz: bf27bc5e64b1730ebbf693a6deb2ea378adb05ccad320a3fa974ebb0cc8b739c70c265f281baae08e5c186cf53873ca41cbc999ff8bd5217713e92409b6c7247
|
data/README.md
CHANGED
@@ -51,7 +51,7 @@ Working code is worth a thousand words. The basics:
|
|
51
51
|
pagerduty = PagerDuty::Connection.new(token)
|
52
52
|
|
53
53
|
# setup the connection with OAuth2 token
|
54
|
-
pagerduty = PagerDuty::Connection.new(token, :Bearer)
|
54
|
+
pagerduty = PagerDuty::Connection.new(token, token_type: :Bearer)
|
55
55
|
|
56
56
|
# 4 main methods: `get`, `post`, `put`, and `delete`:
|
57
57
|
|
@@ -119,6 +119,8 @@ module PagerDuty
|
|
119
119
|
end
|
120
120
|
|
121
121
|
body
|
122
|
+
when Array
|
123
|
+
body.map! { |element| parse(element) }
|
122
124
|
else
|
123
125
|
raise "Can't parse times of #{body.class}: #{body}"
|
124
126
|
end
|
@@ -150,11 +152,13 @@ module PagerDuty
|
|
150
152
|
@connection = Faraday.new do |conn|
|
151
153
|
conn.url_prefix = "https://api.pagerduty.com/"
|
152
154
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
155
|
+
token_arg =
|
156
|
+
case token_type
|
157
|
+
when :Token then { token: token }
|
158
|
+
when :Bearer then token
|
159
|
+
else raise ArgumentError, "invalid token_type: #{token_type.inspect}"
|
160
|
+
end
|
161
|
+
conn.authorization(token_type, token_arg)
|
158
162
|
|
159
163
|
conn.use ConvertTimesParametersToISO8601
|
160
164
|
|
@@ -168,6 +172,13 @@ module PagerDuty
|
|
168
172
|
conn.response :json
|
169
173
|
conn.response :logger, ::Logger.new(STDOUT), bodies: true if debug
|
170
174
|
|
175
|
+
# Because Faraday::Middleware executes in reverse order of
|
176
|
+
# calls to conn.use, status code error handling goes at the
|
177
|
+
# end of the block so that it runs first
|
178
|
+
conn.use RaiseApiErrorOnNon200
|
179
|
+
conn.use RaiseFileNotFoundOn404
|
180
|
+
conn.use RaiseRateLimitOn429
|
181
|
+
|
171
182
|
conn.adapter Faraday.default_adapter
|
172
183
|
end
|
173
184
|
end
|
@@ -180,19 +191,19 @@ module PagerDuty
|
|
180
191
|
offset = (page - 1) * limit
|
181
192
|
request[:query_params] = request[:query_params].merge(offset: offset, limit: limit)
|
182
193
|
|
183
|
-
run_request(:get, path, request)
|
194
|
+
run_request(:get, path, **request)
|
184
195
|
end
|
185
196
|
|
186
197
|
def put(path, request = {})
|
187
|
-
run_request(:put, path, request)
|
198
|
+
run_request(:put, path, **request)
|
188
199
|
end
|
189
200
|
|
190
201
|
def post(path, request = {})
|
191
|
-
run_request(:post, path, request)
|
202
|
+
run_request(:post, path, **request)
|
192
203
|
end
|
193
204
|
|
194
205
|
def delete(path, request = {})
|
195
|
-
run_request(:delete, path, request)
|
206
|
+
run_request(:delete, path, **request)
|
196
207
|
end
|
197
208
|
|
198
209
|
private
|
@@ -17,8 +17,8 @@ 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", "~>
|
22
|
-
gem.add_dependency "activesupport", ">= 3.2", "<
|
20
|
+
gem.add_dependency "faraday", "~> 1.0.0"
|
21
|
+
gem.add_dependency "faraday_middleware", "~> 1.0.0"
|
22
|
+
gem.add_dependency "activesupport", ">= 3.2", "< 7.0"
|
23
23
|
gem.add_dependency "hashie", ">= 1.2"
|
24
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pager_duty-connection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Nichols
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -16,40 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '1.0'
|
19
|
+
version: 1.0.0
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '1.0'
|
26
|
+
version: 1.0.0
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: faraday_middleware
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
31
|
- - "~>"
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
40
|
-
- - "<"
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '1.0'
|
33
|
+
version: 1.0.0
|
43
34
|
type: :runtime
|
44
35
|
prerelease: false
|
45
36
|
version_requirements: !ruby/object:Gem::Requirement
|
46
37
|
requirements:
|
47
38
|
- - "~>"
|
48
39
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
50
|
-
- - "<"
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: '1.0'
|
40
|
+
version: 1.0.0
|
53
41
|
- !ruby/object:Gem::Dependency
|
54
42
|
name: activesupport
|
55
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,7 +47,7 @@ dependencies:
|
|
59
47
|
version: '3.2'
|
60
48
|
- - "<"
|
61
49
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
50
|
+
version: '7.0'
|
63
51
|
type: :runtime
|
64
52
|
prerelease: false
|
65
53
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -69,7 +57,7 @@ dependencies:
|
|
69
57
|
version: '3.2'
|
70
58
|
- - "<"
|
71
59
|
- !ruby/object:Gem::Version
|
72
|
-
version: '
|
60
|
+
version: '7.0'
|
73
61
|
- !ruby/object:Gem::Dependency
|
74
62
|
name: hashie
|
75
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
109
|
- !ruby/object:Gem::Version
|
122
110
|
version: '0'
|
123
111
|
requirements: []
|
124
|
-
rubygems_version: 3.0.
|
112
|
+
rubygems_version: 3.0.3
|
125
113
|
signing_key:
|
126
114
|
specification_version: 4
|
127
115
|
summary: Written with the power of faraday, pager_duty-connection tries to be a simple
|