wavefront-sdk 5.2.0 → 5.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +32 -0
  3. data/.rubocop.yml +7 -37
  4. data/.travis.yml +4 -4
  5. data/HISTORY.md +17 -0
  6. data/lib/wavefront-sdk/cloudintegration.rb +4 -0
  7. data/lib/wavefront-sdk/core/api.rb +2 -2
  8. data/lib/wavefront-sdk/core/api_caller.rb +4 -3
  9. data/lib/wavefront-sdk/defs/version.rb +3 -1
  10. data/lib/wavefront-sdk/derivedmetric.rb +2 -4
  11. data/lib/wavefront-sdk/distribution.rb +2 -0
  12. data/lib/wavefront-sdk/ingestionpolicy.rb +4 -0
  13. data/lib/wavefront-sdk/notificant.rb +0 -2
  14. data/lib/wavefront-sdk/paginator/post.rb +1 -1
  15. data/lib/wavefront-sdk/proxy.rb +10 -0
  16. data/lib/wavefront-sdk/savedsearch.rb +4 -0
  17. data/lib/wavefront-sdk/support/mixins.rb +1 -1
  18. data/lib/wavefront-sdk/support/parse_time.rb +1 -1
  19. data/lib/wavefront-sdk/user.rb +4 -4
  20. data/lib/wavefront-sdk/writers/core.rb +2 -2
  21. data/spec/.rubocop.yml +9 -40
  22. data/spec/support/minitest_assertions.rb +5 -11
  23. data/spec/test_mixins/general.rb +6 -0
  24. data/spec/wavefront-sdk/alert_spec.rb +0 -2
  25. data/spec/wavefront-sdk/core/api_spec.rb +9 -1
  26. data/spec/wavefront-sdk/core/logger_spec.rb +3 -3
  27. data/spec/wavefront-sdk/credentials_spec.rb +2 -0
  28. data/spec/wavefront-sdk/dashboard_spec.rb +0 -2
  29. data/spec/wavefront-sdk/derivedmetric_spec.rb +1 -0
  30. data/spec/wavefront-sdk/misc_spec.rb +18 -0
  31. data/spec/wavefront-sdk/notificant_spec.rb +27 -0
  32. data/spec/wavefront-sdk/proxy_spec.rb +6 -0
  33. data/spec/wavefront-sdk/writers/core_spec.rb +1 -1
  34. data/wavefront-sdk.gemspec +3 -3
  35. metadata +11 -10
  36. data/spec/test_mixins/update_keys.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc04400fbf51a67e94d228b3145a9fdd5fdb484c24035f1c83ff583e755d705e
4
- data.tar.gz: 3acd358086967628300c65bff916b541e28004a1a5ca55b44b764a7ddb277d1e
3
+ metadata.gz: c655c861444978220b162bc7144eacd8ae34a01016acc37aa6dd8837f7c13946
4
+ data.tar.gz: e83e2a0bf6faa89f429e8100154c4fa0d2d394e0eaff3aa948deacf9ebad0217
5
5
  SHA512:
6
- metadata.gz: 665e0f09c85149b0879b868ec51336b88ac9c9c1af542df52ce0e00b932249a06236268e6398e6b828b7a7deb4421669611cdcaaf838965dd2eb560a720f0181
7
- data.tar.gz: 519dc5ca20b01d81454bf8255815bd85ba3e016a4639eda688f1e2544b6d6c6e26ce6ff097e125fdf1eb40ab3ac10530307e0df3a31e590fac24279c89965b64
6
+ metadata.gz: 98d0ddf6e9c5fd9e221919a502f1f9d417bfeced192958c14dda83bf126d883eea26af2aceadd2c713c9b1ee152494542f373c737ce4e833c87c8f2677210f0e
7
+ data.tar.gz: 8c7a347579b7375cac6c7c481ba13cc7ff2d393d9f6eff867b080d8f93b2d545bbddd8b67193706ec3cefda03ff46c3bb26033b0e14b824fad596d13a72a5201
@@ -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,47 +2,17 @@
2
2
 
3
3
  AllCops:
4
4
  TargetRubyVersion: 2.4
5
+ NewCops: enable
5
6
 
6
7
  Metrics/ClassLength:
7
8
  Max: 150
8
9
 
9
- # New cops
10
- #
11
- Lint/RaiseException:
12
- Enabled: true
13
- Lint/StructNewOverride:
14
- Enabled: true
15
- Style/ExponentialNotation:
16
- Enabled: true
17
- Style/HashEachMethods:
18
- Enabled: true
19
- Style/HashTransformKeys:
20
- Enabled: true
21
- Style/HashTransformValues:
22
- Enabled: true
23
- Layout/EmptyLinesAroundAttributeAccessor:
24
- Enabled: true
25
- Layout/SpaceAroundMethodCallOperator:
26
- Enabled: true
27
- Style/SlicingWithRange:
28
- Enabled: true
29
- Lint/DeprecatedOpenSSLConstant:
30
- Enabled: true
31
- Lint/MixedRegexpCaptureTypes:
32
- Enabled: true
33
- Style/RedundantRegexpCharacterClass:
34
- Enabled: true
35
- Style/RedundantRegexpEscape:
36
- Enabled: true
37
- Style/AccessorGrouping:
38
- Enabled: true
39
- Style/BisectedAttrAccessor:
40
- Enabled: true
41
- Style/RedundantAssignment:
42
- Enabled: true
43
- Style/RedundantFetchBlock:
44
- Enabled: true
45
-
46
10
  # Is nothing sacred?
47
11
  Layout/LineLength:
48
12
  Max: 80
13
+
14
+ Style/StringConcatenation:
15
+ Enabled: false
16
+
17
+ Style/OptionalBooleanParameter:
18
+ Enabled: false
@@ -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.1 (2020-12-17)
4
+ * Fix error on derived metric modification.
5
+
6
+ ## 5.4.0 (2020-12-16)
7
+ * Add `raw_response` option, which makes the SDK return the raw API response
8
+ as plain JSON text, rather than as a `Wavefront::Response` object.
9
+
10
+ ## 5.3.1 (2020-12-11)
11
+ * Fix error when renaming ingestion policies, and improve testing which should
12
+ have caught the problem in the first place.
13
+
14
+ ## 5.3.0 (2020-10-10)
15
+ * Add `Wavefront::Proxy#shutdown` which can shut down a proxy via the API.
16
+
17
+ ## 5.2.1 (2020-09-18)
18
+ * Remove necessity for user to `require 'pathname'`
19
+
3
20
  ## 5.2.0 (2020-09-03)
4
21
  * Add `:raise_on_no_profile` option to `Wavefront::Credentials` constructor
5
22
  options. If this is true and a specific config stanza is requested but not
@@ -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
@@ -1,4 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- WF_SDK_VERSION = '5.2.0'
3
+ require 'pathname'
4
+
5
+ WF_SDK_VERSION = '5.4.1'
4
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
@@ -65,6 +65,7 @@ module Wavefront
65
65
  raise Wavefront::Exception::InvalidDistribution
66
66
  end
67
67
 
68
+ # rubocop:disable Metrics/AbcSize
68
69
  def dist_hash(dist)
69
70
  dist.dup.tap do |d|
70
71
  d[:interval] = distribution_interval(dist)
@@ -75,6 +76,7 @@ module Wavefront
75
76
  d[:opttags] = tags_or_nothing(opts[:tags])
76
77
  end
77
78
  end
79
+ # rubocop:enable Metrics/AbcSize
78
80
 
79
81
  def distribution_timestamp(dist)
80
82
  parse_time(dist.fetch(:ts, Time.now))
@@ -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
@@ -138,8 +138,8 @@ module Wavefront
138
138
  end
139
139
 
140
140
  def log_invalid_point(rawpoint, exception)
141
- logger.log('Invalid point, skipping.', :info)
142
- logger.log(exception.class, :info)
141
+ logger.log('Invalid point, skipping.', :warn)
142
+ logger.log(exception.class, :warn)
143
143
  logger.log(format('Invalid point: %<rawpoint>s (%<message>s)',
144
144
  rawpoint: rawpoint,
145
145
  message: exception.to_s), :debug)
@@ -1,54 +1,23 @@
1
- # Offense count: 64
1
+ AllCops:
2
+ NewCops: enable
3
+
2
4
  Metrics/AbcSize:
3
5
  Max: 64
4
6
 
5
- # Offense count: 5
6
7
  # Configuration parameters: CountComments.
7
8
  Metrics/ClassLength:
8
9
  Max: 400
9
10
 
10
- # Offense count: 46
11
11
  # Configuration parameters: CountComments, ExcludedMethods.
12
12
  Metrics/MethodLength:
13
13
  Max: 39
14
14
 
15
- # New cops
16
- #
17
- Lint/RaiseException:
18
- Enabled: true
19
- Lint/StructNewOverride:
20
- Enabled: true
21
- Style/ExponentialNotation:
22
- Enabled: true
23
- Style/HashEachMethods:
24
- Enabled: true
25
- Style/HashTransformKeys:
26
- Enabled: true
27
- Style/HashTransformValues:
28
- Enabled: true
29
- Layout/EmptyLinesAroundAttributeAccessor:
30
- Enabled: true
31
- Layout/SpaceAroundMethodCallOperator:
32
- Enabled: true
33
- Style/SlicingWithRange:
34
- Enabled: true
35
- Lint/DeprecatedOpenSSLConstant:
36
- Enabled: true
37
- Lint/MixedRegexpCaptureTypes:
38
- Enabled: true
39
- Style/RedundantRegexpCharacterClass:
40
- Enabled: true
41
- Style/RedundantRegexpEscape:
42
- Enabled: true
43
- Style/AccessorGrouping:
44
- Enabled: true
45
- Style/BisectedAttrAccessor:
46
- Enabled: true
47
- Style/RedundantAssignment:
48
- Enabled: true
49
- Style/RedundantFetchBlock:
50
- Enabled: true
51
-
52
15
  # Is nothing sacred?
53
16
  Layout/LineLength:
54
17
  Max: 80
18
+
19
+ Style/StringConcatenation:
20
+ Enabled: false
21
+
22
+ Style/OptionalBooleanParameter:
23
+ Enabled: false
@@ -95,18 +95,12 @@ module Minitest
95
95
  end
96
96
 
97
97
  def header_lookup(type)
98
- ctype = case type
99
- when :plain
100
- 'text/plain'
101
- when :json
102
- 'application/json'
103
- when :octet
104
- 'application/octet-stream'
105
- when :form
106
- 'application/x-www-form-urlencoded'
107
- end
98
+ ctypes = { plain: 'text/plain',
99
+ json: 'application/json',
100
+ octet: 'application/octet-stream',
101
+ form: 'application/x-www-form-urlencoded' }
108
102
 
109
- { 'Content-Type': ctype, Accept: 'application/json' }
103
+ { 'Content-Type': ctypes[type], Accept: 'application/json' }
110
104
  end
111
105
  end
112
106
  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
@@ -41,21 +41,21 @@ class WavefrontLoggerTest < MiniTest::Test
41
41
  end
42
42
 
43
43
  def test_log_logger_debug
44
- l = Wavefront::Logger.new(logger: Logger.new(STDOUT))
44
+ l = Wavefront::Logger.new(logger: Logger.new($stdout))
45
45
  out, err = capture_subprocess_io { l.log('my message', :debug) }
46
46
  assert_match(/DEBUG -- : my message$/, out)
47
47
  assert_empty(err)
48
48
  end
49
49
 
50
50
  def test_log_logger_info
51
- l = Wavefront::Logger.new(logger: Logger.new(STDOUT))
51
+ l = Wavefront::Logger.new(logger: Logger.new($stdout))
52
52
  out, err = capture_subprocess_io { l.log('my message', :info) }
53
53
  assert_match(/INFO -- : my message$/, out)
54
54
  assert_empty(err)
55
55
  end
56
56
 
57
57
  def test_log_logger_error
58
- l = Wavefront::Logger.new(logger: Logger.new(STDOUT))
58
+ l = Wavefront::Logger.new(logger: Logger.new($stdout))
59
59
  out, err = capture_subprocess_io { l.log('my message', :error) }
60
60
  assert_match(/ERROR -- : my message$/, out)
61
61
  assert_empty(err)
@@ -60,9 +60,11 @@ end
60
60
  # Test individual methods. We must override the constructor to do
61
61
  # this.
62
62
  #
63
+ # rubocop:disable Lint/MissingSuper
63
64
  class Giblets < Wavefront::Credentials
64
65
  def initialize; end
65
66
  end
67
+ # rubocop:enable Lint/MissingSuper
66
68
 
67
69
  # And here are the tests
68
70
  #
@@ -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
@@ -22,7 +22,7 @@ class TestClassNoTags
22
22
  end
23
23
 
24
24
  def logger
25
- Logger.new(STDOUT)
25
+ Logger.new($stdout)
26
26
  end
27
27
 
28
28
  def manage_conn
@@ -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.87.1'
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.0
4
+ version: 5.4.1
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-03 00:00:00.000000000 Z
11
+ date: 2020-12-18 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.87.1
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.87.1
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