pager_duty-connection 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/README.md +3 -0
- data/lib/pager_duty/connection/version.rb +1 -1
- data/lib/pager_duty/connection.rb +12 -9
- data/pager_duty-connection.gemspec +5 -3
- metadata +24 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ec4e78b2def787e07a82a8dfb19838dcace837e98647e386209af24003f26e9
|
4
|
+
data.tar.gz: 7d0885571bbf8e088de58ec22a12bff3354935b5c036017c0548babf8422e933
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e30277c8080331cd8ae89dcf520d7d9df945a5ed5456f4b0acba12a40d43fa9ca038a5860650091762d47a08cd46c1149bbc5f93000d13b68f2fd793490e43c2
|
7
|
+
data.tar.gz: d47249fc1dab34ed3100177c81d13fc15b83f60201cbad4c9b1516f295da6cb156a723a54afbd753448e1cdfb1e7e2d6ba33c72eeffc53fb72ee9e87ae1e87db
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.5
|
data/README.md
CHANGED
@@ -53,6 +53,9 @@ pagerduty = PagerDuty::Connection.new(token)
|
|
53
53
|
# setup the connection with OAuth2 token
|
54
54
|
pagerduty = PagerDuty::Connection.new(token, token_type: :Bearer)
|
55
55
|
|
56
|
+
# setup to use a custom domain
|
57
|
+
pagerduty = PagerDuty::Connection.new(token, token_type: :Bearer, url: 'https://custom.domain.com')
|
58
|
+
|
56
59
|
# 4 main methods: `get`, `post`, `put`, and `delete`:
|
57
60
|
|
58
61
|
response = pagerduty.get('some/relative/path', params)
|
@@ -10,6 +10,7 @@ module PagerDuty
|
|
10
10
|
attr_accessor :connection
|
11
11
|
|
12
12
|
API_VERSION = 2
|
13
|
+
API_PREFIX = "https://api.pagerduty.com/"
|
13
14
|
|
14
15
|
class FileNotFoundError < RuntimeError
|
15
16
|
end
|
@@ -36,10 +37,11 @@ module PagerDuty
|
|
36
37
|
response = @app.call env
|
37
38
|
unless [200, 201, 204].include?(response.status)
|
38
39
|
url = response.env[:url].to_s
|
39
|
-
message = "Got HTTP #{response
|
40
|
-
|
40
|
+
message = "Got HTTP #{response.status}: #{response.reason_phrase}\nFrom #{url}"
|
41
|
+
|
42
|
+
if error = response.body
|
41
43
|
# TODO May Need to check error.errors too
|
42
|
-
message += "\n#{error
|
44
|
+
message += "\n#{JSON.parse(error)}"
|
43
45
|
end
|
44
46
|
|
45
47
|
raise ApiError, message
|
@@ -148,9 +150,9 @@ module PagerDuty
|
|
148
150
|
end
|
149
151
|
end
|
150
152
|
|
151
|
-
def initialize(token, token_type: :Token, debug: false)
|
153
|
+
def initialize(token, token_type: :Token, url: API_PREFIX, debug: false)
|
152
154
|
@connection = Faraday.new do |conn|
|
153
|
-
conn.url_prefix =
|
155
|
+
conn.url_prefix = url
|
154
156
|
|
155
157
|
token_arg =
|
156
158
|
case token_type
|
@@ -186,12 +188,13 @@ module PagerDuty
|
|
186
188
|
def get(path, request = {})
|
187
189
|
# paginate anything being 'get'ed, because the offset/limit isn't intuitive
|
188
190
|
request[:query_params] = {} if !request[:query_params]
|
189
|
-
page =
|
190
|
-
limit =
|
191
|
+
page = request[:query_params].fetch(:page, 1).to_i
|
192
|
+
limit = request[:query_params].fetch(:limit, 100).to_i
|
191
193
|
offset = (page - 1) * limit
|
192
|
-
request[:query_params] = request[:query_params].merge(offset: offset, limit: limit)
|
193
194
|
|
194
|
-
|
195
|
+
query_params = request[:query_params].merge(offset: offset, limit: limit)
|
196
|
+
|
197
|
+
run_request(:get, path, **request.merge(query_params: query_params))
|
195
198
|
end
|
196
199
|
|
197
200
|
def put(path, request = {})
|
@@ -17,8 +17,10 @@ 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", "~> 1.0
|
21
|
-
gem.add_dependency "faraday_middleware", "~> 1.0
|
22
|
-
gem.add_dependency "activesupport", ">= 3.2", "<
|
20
|
+
gem.add_dependency "faraday", "~> 1.0"
|
21
|
+
gem.add_dependency "faraday_middleware", "~> 1.0"
|
22
|
+
gem.add_dependency "activesupport", ">= 3.2", "< 8.0"
|
23
23
|
gem.add_dependency "hashie", ">= 1.2"
|
24
|
+
|
25
|
+
gem.add_development_dependency "rake"
|
24
26
|
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: 2.0
|
4
|
+
version: 2.1.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:
|
11
|
+
date: 2022-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0
|
19
|
+
version: '1.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.0
|
26
|
+
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: faraday_middleware
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0
|
33
|
+
version: '1.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.0
|
40
|
+
version: '1.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -47,7 +47,7 @@ dependencies:
|
|
47
47
|
version: '3.2'
|
48
48
|
- - "<"
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version: '
|
50
|
+
version: '8.0'
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -57,7 +57,7 @@ dependencies:
|
|
57
57
|
version: '3.2'
|
58
58
|
- - "<"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '8.0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: hashie
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,6 +72,20 @@ dependencies:
|
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '1.2'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rake
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
75
89
|
description: Ruby API wrapper for the PagerDuty REST API
|
76
90
|
email:
|
77
91
|
- josh@technicalpickles.com
|
@@ -80,6 +94,7 @@ extensions: []
|
|
80
94
|
extra_rdoc_files: []
|
81
95
|
files:
|
82
96
|
- ".gitignore"
|
97
|
+
- ".ruby-version"
|
83
98
|
- Gemfile
|
84
99
|
- LICENSE.txt
|
85
100
|
- README.md
|
@@ -109,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
124
|
- !ruby/object:Gem::Version
|
110
125
|
version: '0'
|
111
126
|
requirements: []
|
112
|
-
rubygems_version: 3.
|
127
|
+
rubygems_version: 3.3.10
|
113
128
|
signing_key:
|
114
129
|
specification_version: 4
|
115
130
|
summary: Written with the power of faraday, pager_duty-connection tries to be a simple
|