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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e78f2fad96d2bf01daf854fcc9e0bd8d971801caa7d5615e40c692201be07de5
4
- data.tar.gz: 5beac4e604804d404580217c091644839a2aa2f468259b15eced7792cfeb1e52
3
+ metadata.gz: 6ec4e78b2def787e07a82a8dfb19838dcace837e98647e386209af24003f26e9
4
+ data.tar.gz: 7d0885571bbf8e088de58ec22a12bff3354935b5c036017c0548babf8422e933
5
5
  SHA512:
6
- metadata.gz: '012509de4ebd913ec9ffd851ed3ddcb85eb4e9ddb16c6ae624b37bb0e54a31cd36db41014bc0e09b36318c1d6b19c699542aec83f489f5e6598c87029ce98070'
7
- data.tar.gz: bf27bc5e64b1730ebbf693a6deb2ea378adb05ccad320a3fa974ebb0cc8b739c70c265f281baae08e5c186cf53873ca41cbc999ff8bd5217713e92409b6c7247
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)
@@ -1,5 +1,5 @@
1
1
  module PagerDuty
2
2
  class Connection
3
- VERSION = "2.0.1"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
@@ -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['status']} back for #{url}"
40
- if error = response.body['error']
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.to_hash}"
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 = "https://api.pagerduty.com/"
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 = (request[:query_params].delete(:page) || 1).to_i
190
- limit = (request[:query_params].delete(:limit) || 100).to_i
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
- run_request(:get, path, **request)
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.0"
21
- gem.add_dependency "faraday_middleware", "~> 1.0.0"
22
- gem.add_dependency "activesupport", ">= 3.2", "< 7.0"
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.1
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: 2021-09-16 00:00:00.000000000 Z
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.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.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.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.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: '7.0'
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: '7.0'
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.0.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