wavefront-sdk 5.2.1 → 5.4.2

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: 5e623522f872c4204c1e723ee5a399c513251933e64445f6f5b65ff66d2fbffc
4
- data.tar.gz: 6f55f44177169c24d4c0aa89490464097a6fe2278e24a1e3b83e5f7520757dfd
3
+ metadata.gz: 47c3ed865038dcefae2e115015cfd5cda6d2eec720278010ab16b285261ae7d3
4
+ data.tar.gz: 31816281995c53c3b6a12cdf103edbfbf0274a14f8353dc4085a1356bb770a0f
5
5
  SHA512:
6
- metadata.gz: 58bb998cc92b36c369497631f766af8844a692fbd10508962ee7bd30f4fbe65d222bc512d06b63feb19ca94cdcc4e8429b8c61f6227e4ff1041cd6ffff141758
7
- data.tar.gz: 198dfadd7561b5c3772211716d23f9653ace3bbf472e41d12fa8b64d744ed16567bb11796ef3aff252054bc0945200ea71e454b5989824656c178e74503b4675
6
+ metadata.gz: c9801eec9641016634808e2ad4e40139222fbf3e3c7ef3d0bde7ca85e5b9fe273d5d91700f290531775b4ef1ae463d3eb75e219b47936ca7ab69fa8211a27a5d
7
+ data.tar.gz: d07c63a3aa77ba33ae7c5b6c43bbc8a5af1f3c5b981f7a8543f3e2bd86a431ba6e1730a746a04b5cc5c0d149e4ec080657160c4876c51d09b1f9648f39ff3041
@@ -0,0 +1,32 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+ runs-on: ubuntu-latest
19
+ strategy:
20
+ matrix:
21
+ ruby-version: [2.4.10, 2.5.8, 2.6.6, 2.7.2]
22
+ steps:
23
+ - uses: actions/checkout@v2
24
+ - name: Set up Ruby
25
+ uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: ${{ matrix.ruby-version }}
28
+ bundler-cache: true
29
+ - name: Install dependencies
30
+ run: bundle install
31
+ - name: Run tests
32
+ run: bundle exec rake
@@ -2,9 +2,9 @@ language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
4
  - 2.4.9
5
- - 2.5.7
6
- - 2.6.5
7
- - 2.7.0
5
+ - 2.5.8
6
+ - 2.6.6
7
+ - 2.7.2
8
8
  before_install: gem install bundler --no-document
9
9
  deploy:
10
10
  provider: rubygems
@@ -14,7 +14,7 @@ deploy:
14
14
  on:
15
15
  tags: true
16
16
  repo: snltd/wavefront-sdk
17
- ruby: 2.6.5
17
+ ruby: 2.6.6
18
18
  notifications:
19
19
  email: false
20
20
  slack:
data/HISTORY.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.4.2 (2021-01-11)
4
+ * Fix bug which blocked event updates.
5
+
6
+ ## 5.4.1 (2020-12-17)
7
+ * Fix error on derived metric modification.
8
+
9
+ ## 5.4.0 (2020-12-16)
10
+ * Add `raw_response` option, which makes the SDK return the raw API response
11
+ as plain JSON text, rather than as a `Wavefront::Response` object.
12
+
13
+ ## 5.3.1 (2020-12-11)
14
+ * Fix error when renaming ingestion policies, and improve testing which should
15
+ have caught the problem in the first place.
16
+
17
+ ## 5.3.0 (2020-10-10)
18
+ * Add `Wavefront::Proxy#shutdown` which can shut down a proxy via the API.
19
+
3
20
  ## 5.2.1 (2020-09-18)
4
21
  * Remove necessity for user to `require 'pathname'`
5
22
 
@@ -128,5 +128,9 @@ module Wavefront
128
128
  wf_aws_external_id?(external_id)
129
129
  api.get(['awsExternalId', external_id].uri_concat)
130
130
  end
131
+
132
+ def update_keys
133
+ %i[name]
134
+ end
131
135
  end
132
136
  end
@@ -81,9 +81,9 @@ module Wavefront
81
81
  (time.to_f * 1000).round
82
82
  end
83
83
 
84
- # doing a PUT to update an object requires only a certain subset of
84
+ # Doing a PUT to update an object requires only a certain subset of
85
85
  # the keys returned by #describe(). This method takes the
86
- # existing description of an object and turns it into a new has
86
+ # existing description of an object and turns it into a new hash
87
87
  # which can be PUT.
88
88
  #
89
89
  # @param old [Hash] a hash of the existing object
@@ -15,8 +15,7 @@ module Wavefront
15
15
  class ApiCaller
16
16
  include Wavefront::Mixins
17
17
 
18
- attr_reader :opts, :noop, :debug, :verbose, :net, :logger,
19
- :calling_class
18
+ attr_reader :opts, :noop, :debug, :verbose, :net, :logger, :calling_class
20
19
 
21
20
  # @param calling_class [
22
21
  # @param creds [Hash] Wavefront credentials
@@ -178,7 +177,9 @@ module Wavefront
178
177
  resp.body
179
178
  end
180
179
 
181
- Wavefront::Response.new(body, resp.status, @opts)
180
+ return body if opts[:raw_response]
181
+
182
+ Wavefront::Response.new(body, resp.status, opts)
182
183
  end
183
184
 
184
185
  # Try to describe the actual HTTP calls we make. There's a bit
@@ -2,5 +2,5 @@
2
2
 
3
3
  require 'pathname'
4
4
 
5
- WF_SDK_VERSION = '5.2.1'
5
+ WF_SDK_VERSION = '5.4.2'
6
6
  WF_SDK_LOCATION = Pathname.new(__dir__).parent.parent.parent
@@ -112,11 +112,9 @@ module Wavefront
112
112
  wf_derivedmetric_id?(id)
113
113
  end
114
114
 
115
- private
116
-
117
115
  def update_keys
118
- %i[id name query tags additionalInformation
119
- includeObsoleteMetrics processRateMinutes minutes]
116
+ %i[id name query tags additionalInformation includeObsoleteMetrics
117
+ processRateMinutes minutes]
120
118
  end
121
119
  end
122
120
  end
@@ -12,7 +12,7 @@ module Wavefront
12
12
  include Wavefront::Mixin::Tag
13
13
 
14
14
  def update_keys
15
- %i[startTime endTime name annotations]
15
+ %i[id name]
16
16
  end
17
17
 
18
18
  # GET /api/v2/event
@@ -100,7 +100,9 @@ module Wavefront
100
100
 
101
101
  return api.put(id, body, 'application/json') unless modify
102
102
 
103
- api.put(id, hash_for_update(describe(id), body), 'application/json')
103
+ api.put(id,
104
+ hash_for_update(describe(id).response, body),
105
+ 'application/json')
104
106
  end
105
107
 
106
108
  # POST /api/v2/event/id/close
@@ -81,5 +81,9 @@ module Wavefront
81
81
  api.put(id, hash_for_update(describe(id).response, body),
82
82
  'application/json')
83
83
  end
84
+
85
+ def update_keys
86
+ %i[name]
87
+ end
84
88
  end
85
89
  end
@@ -83,8 +83,6 @@ module Wavefront
83
83
  api.post(['test', id].uri_concat, nil)
84
84
  end
85
85
 
86
- private
87
-
88
86
  def update_keys
89
87
  %i[id contentType method description title template triggers
90
88
  recipient customHttpHeaders emailSubject isHtmlContent]
@@ -50,7 +50,7 @@ module Wavefront
50
50
  def body_as(desired, args, index = 1)
51
51
  body = args[index]
52
52
 
53
- return args if body.class == desired
53
+ return args if body.instance_of?(desired)
54
54
 
55
55
  args[index] = body_as_json(body)
56
56
  args
@@ -86,5 +86,15 @@ module Wavefront
86
86
  wf_proxy_id?(id)
87
87
  api.put(id, payload)
88
88
  end
89
+
90
+ # Shutdown a proxy. Requires proxy >=5.x. Might not be effective if you
91
+ # have something like systemd or SMF restarting a failed proxy.
92
+ # @param id [String] ID of the proxy
93
+ # @return [Wavefront::Response]
94
+ #
95
+ def shutdown(id)
96
+ wf_proxy_id?(id)
97
+ api.put(id, { shutdown: true }, 'application/json')
98
+ end
89
99
  end
90
100
  end
@@ -80,5 +80,9 @@ module Wavefront
80
80
  api.get(['type', entitytype].uri_concat, offset: offset,
81
81
  limit: limit)
82
82
  end
83
+
84
+ def update_keys
85
+ %i[query entityType]
86
+ end
83
87
  end
84
88
  end
@@ -23,7 +23,7 @@ module Wavefront
23
23
  # @raise Wavefront::InvalidTimestamp
24
24
  #
25
25
  def parse_time(time, in_ms = false)
26
- return relative_time(time, in_ms) if time.to_s =~ /^[\-+]/
26
+ return relative_time(time, in_ms) if time.to_s.match?(/^[\-+]/)
27
27
 
28
28
  ParseTime.new(time, in_ms).parse!
29
29
  end
@@ -34,7 +34,7 @@ module Wavefront
34
34
  # @return [Fixnum] timestamp
35
35
  #
36
36
  def parse_time_string
37
- return t.to_i if t =~ /^\d+$/
37
+ return t.to_i if t.match?(/^\d+$/)
38
38
 
39
39
  @t = Time.parse("#{t} #{Time.now.getlocal.zone}")
40
40
  parse_time_time
@@ -297,6 +297,10 @@ module Wavefront
297
297
  raise NoMethodError
298
298
  end
299
299
 
300
+ def update_keys
301
+ %i[identifier groups userGroups]
302
+ end
303
+
300
304
  private
301
305
 
302
306
  def response_looks_right?(body_obj)
@@ -311,9 +315,5 @@ module Wavefront
311
315
 
312
316
  items.fetch(:message, 'no message from API')
313
317
  end
314
-
315
- def update_keys
316
- %i[identifier groups userGroups]
317
- end
318
318
  end
319
319
  end
@@ -65,6 +65,7 @@ module WavefrontTest
65
65
  module Update
66
66
  def test_update
67
67
  [payload].flatten.each do |p|
68
+ # passes payload through as-is
68
69
  assert_puts("/api/v2/#{api_class}/#{id}", p) do
69
70
  wf.update(id, p, false)
70
71
  end
@@ -73,6 +74,11 @@ module WavefrontTest
73
74
  assert_raises(ArgumentError) { wf.update }
74
75
  end
75
76
  end
77
+
78
+ def test_update_keys
79
+ assert_instance_of Array, wf.update_keys
80
+ assert(wf.update_keys.all? { |k| k.is_a?(Symbol) })
81
+ end
76
82
  end
77
83
 
78
84
  module Clone
@@ -4,7 +4,6 @@
4
4
  require_relative '../spec_helper'
5
5
  require_relative '../test_mixins/acl'
6
6
  require_relative '../test_mixins/tag'
7
- require_relative '../test_mixins/update_keys'
8
7
  require_relative '../test_mixins/general'
9
8
 
10
9
  # Unit tests for Alert class
@@ -20,7 +19,6 @@ class WavefrontAlertTest < WavefrontTestBase
20
19
  include WavefrontTest::List
21
20
  include WavefrontTest::Tag
22
21
  include WavefrontTest::Update
23
- include WavefrontTest::UpdateKeys
24
22
 
25
23
  def test_snooze
26
24
  assert_posts("/api/v2/alert/#{id}/snooze") { wf.snooze(id) }
@@ -23,7 +23,15 @@ class WavefrontCoreApiTest < MiniTest::Test
23
23
 
24
24
  def test_hash_for_update
25
25
  wf.instance_variable_set('@update_keys', %i[k1 k2])
26
- body = { k1: 'ov1', k2: 'ov2', k3: 'ov3' }
26
+ body = { k1: 'ov1',
27
+ k2: 'ov2',
28
+ k3: 'ov3',
29
+ customerId: 'test',
30
+ creatorId: 'someone@example.com',
31
+ createUserId: 'someone@example.com',
32
+ updateUserId: 'someone@example.com',
33
+ createdEpochMillis: 1_607_691_387_023,
34
+ updatedEpochMillis: 1_607_691_387_023 }
27
35
  upd = { k2: 'nv1' }
28
36
  assert_equal({ k1: 'ov1', k2: 'nv1' }, wf.hash_for_update(body, upd))
29
37
  end
@@ -4,7 +4,6 @@
4
4
  require_relative '../spec_helper'
5
5
  require_relative '../test_mixins/acl'
6
6
  require_relative '../test_mixins/tag'
7
- require_relative '../test_mixins/update_keys'
8
7
  require_relative '../test_mixins/general'
9
8
 
10
9
  # Unit tests for dashboard class
@@ -18,7 +17,6 @@ class WavefrontDashboardTest < WavefrontTestBase
18
17
  include WavefrontTest::List
19
18
  include WavefrontTest::Tag
20
19
  include WavefrontTest::Update
21
- include WavefrontTest::UpdateKeys
22
20
 
23
21
  def test_favorite
24
22
  assert_posts("/api/v2/dashboard/#{id}/favorite") { wf.favorite(id) }
@@ -29,6 +29,7 @@ class WavefrontDerivedMetricTest < WavefrontTestBase
29
29
  def payload
30
30
  { minutes: 5,
31
31
  name: 'test_1',
32
+ id: id,
32
33
  query: 'aliasMetric(ts("test.metric"), "derived.test_1")',
33
34
  tags: { customerTags: ['test'] },
34
35
  includeObsoleteMetrics: false,
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../spec_helper'
5
+ require_relative '../../lib/wavefront-sdk/defs/version'
6
+
7
+ # Tests for things that aren't in the SDK itself.
8
+ #
9
+ class WavefrontMiscTest < MiniTest::Test
10
+ # Check the latest version mentioned in the changelog is the version the SDK
11
+ # defines itself as.
12
+ #
13
+ def test_version_vs_history
14
+ history_file = WF_SDK_LOCATION + 'HISTORY.md'
15
+ history_vers = IO.read(history_file).match(/^## (\d+\.\d+\.\d+) \(/)
16
+ assert_equal(WF_SDK_VERSION, history_vers.captures.first)
17
+ end
18
+ end
@@ -10,6 +10,7 @@ class WavefrontNotificantTest < WavefrontTestBase
10
10
  include WavefrontTest::List
11
11
  include WavefrontTest::Delete
12
12
  include WavefrontTest::Describe
13
+ include WavefrontTest::Update
13
14
 
14
15
  def test_test
15
16
  assert_posts("/api/v2/notificant/test/#{id}") { wf.test(id) }
@@ -29,4 +30,30 @@ class WavefrontNotificantTest < WavefrontTestBase
29
30
  def invalid_id
30
31
  '---rubbish---'
31
32
  end
33
+
34
+ def payload
35
+ JSON.parse(%(
36
+ {
37
+ "method": "PAGERDUTY",
38
+ "id": "PE0BEkf4r123yooO",
39
+ "contentType": "",
40
+ "description": "Test target",
41
+ "customerId": "sysdef",
42
+ "title": "Terraform Test Target",
43
+ "recipient": "12345678910111213141516171819202",
44
+ "creatorId": "someone@example.com",
45
+ "updaterId": "someone@example.com",
46
+ "createdEpochMillis": 1604513812010,
47
+ "updatedEpochMillis": 1604513812010,
48
+ "template": "{}",
49
+ "triggers": [
50
+ "ALERT_OPENED",
51
+ "ALERT_RESOLVED"
52
+ ],
53
+ "customHttpHeaders": {},
54
+ "emailSubject": "",
55
+ "isHtmlContent": false
56
+ }
57
+ ), symbolize_names: true)
58
+ end
32
59
  end
@@ -21,6 +21,12 @@ class WavefrontProxyTest < WavefrontTestBase
21
21
  assert_raises(ArgumentError) { wf.rename }
22
22
  end
23
23
 
24
+ def test_shutdown
25
+ assert_puts("/api/v2/proxy/#{id}", { shutdown: true }.to_json, :json) do
26
+ wf.shutdown(id)
27
+ end
28
+ end
29
+
24
30
  private
25
31
 
26
32
  def api_class
@@ -23,16 +23,16 @@ Gem::Specification.new do |gem|
23
23
  gem.bindir = 'bin'
24
24
 
25
25
  gem.add_dependency 'addressable', '~> 2.7'
26
- gem.add_dependency 'faraday', '~> 1.0'
26
+ gem.add_dependency 'faraday', '~> 1.1'
27
27
  gem.add_dependency 'inifile', '~> 3.0'
28
28
  gem.add_dependency 'map', '~> 6.6'
29
29
 
30
30
  gem.add_development_dependency 'minitest', '~> 5.14'
31
31
  gem.add_development_dependency 'rake', '~> 13.0'
32
- gem.add_development_dependency 'rubocop', '0.91.0'
32
+ gem.add_development_dependency 'rubocop', '1.0'
33
33
  gem.add_development_dependency 'simplecov', '~> 0.18'
34
34
  gem.add_development_dependency 'spy', '1.0.0'
35
- gem.add_development_dependency 'webmock', '~> 3.8'
35
+ gem.add_development_dependency 'webmock', '~> 3.9'
36
36
  gem.add_development_dependency 'yard', '~> 0.9'
37
37
 
38
38
  gem.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wavefront-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.1
4
+ version: 5.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Fisher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-19 00:00:00.000000000 Z
11
+ date: 2021-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: '1.1'
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.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: inifile
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 0.91.0
103
+ version: '1.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 0.91.0
110
+ version: '1.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: simplecov
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '3.8'
145
+ version: '3.9'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '3.8'
152
+ version: '3.9'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: yard
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -171,6 +171,7 @@ extensions: []
171
171
  extra_rdoc_files: []
172
172
  files:
173
173
  - ".codeclimate.yml"
174
+ - ".github/workflows/ruby.yml"
174
175
  - ".gitignore"
175
176
  - ".rubocop.yml"
176
177
  - ".travis.yml"
@@ -254,7 +255,6 @@ files:
254
255
  - spec/test_mixins/acl.rb
255
256
  - spec/test_mixins/general.rb
256
257
  - spec/test_mixins/tag.rb
257
- - spec/test_mixins/update_keys.rb
258
258
  - spec/wavefront-sdk/account_spec.rb
259
259
  - spec/wavefront-sdk/alert_spec.rb
260
260
  - spec/wavefront-sdk/api_mixins/user_mixins_spec.rb
@@ -276,6 +276,7 @@ files:
276
276
  - spec/wavefront-sdk/message_spec.rb
277
277
  - spec/wavefront-sdk/metric_helper_spec.rb
278
278
  - spec/wavefront-sdk/metric_spec.rb
279
+ - spec/wavefront-sdk/misc_spec.rb
279
280
  - spec/wavefront-sdk/notificant_spec.rb
280
281
  - spec/wavefront-sdk/paginator/base_spec.rb
281
282
  - spec/wavefront-sdk/paginator/post_spec.rb
@@ -351,7 +352,6 @@ test_files:
351
352
  - spec/test_mixins/acl.rb
352
353
  - spec/test_mixins/general.rb
353
354
  - spec/test_mixins/tag.rb
354
- - spec/test_mixins/update_keys.rb
355
355
  - spec/wavefront-sdk/account_spec.rb
356
356
  - spec/wavefront-sdk/alert_spec.rb
357
357
  - spec/wavefront-sdk/api_mixins/user_mixins_spec.rb
@@ -373,6 +373,7 @@ test_files:
373
373
  - spec/wavefront-sdk/message_spec.rb
374
374
  - spec/wavefront-sdk/metric_helper_spec.rb
375
375
  - spec/wavefront-sdk/metric_spec.rb
376
+ - spec/wavefront-sdk/misc_spec.rb
376
377
  - spec/wavefront-sdk/notificant_spec.rb
377
378
  - spec/wavefront-sdk/paginator/base_spec.rb
378
379
  - spec/wavefront-sdk/paginator/post_spec.rb
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module WavefrontTest
4
- #
5
- # include this into any class which has update keys
6
- #
7
- module UpdateKeys
8
- def test_update_keys
9
- assert_instance_of Array, wf.update_keys
10
- assert(wf.update_keys.all? { |k| k.is_a?(Symbol) })
11
- end
12
- end
13
- end