wavefront-sdk 7.0.0 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +3 -3
  3. data/.github/workflows/test.yml +1 -1
  4. data/.rubocop.yml +1 -1
  5. data/Gemfile +11 -0
  6. data/HISTORY.md +27 -4
  7. data/README.md +3 -3
  8. data/lib/wavefront-sdk/accesspolicy.rb +37 -0
  9. data/lib/wavefront-sdk/account.rb +28 -0
  10. data/lib/wavefront-sdk/alert.rb +29 -10
  11. data/lib/wavefront-sdk/api_mixins/tag.rb +12 -12
  12. data/lib/wavefront-sdk/apitoken.rb +29 -2
  13. data/lib/wavefront-sdk/cloudintegration.rb +10 -8
  14. data/lib/wavefront-sdk/cluster.rb +18 -0
  15. data/lib/wavefront-sdk/core/api_caller.rb +2 -2
  16. data/lib/wavefront-sdk/core/exception.rb +4 -0
  17. data/lib/wavefront-sdk/dashboard.rb +7 -6
  18. data/lib/wavefront-sdk/defs/version.rb +1 -1
  19. data/lib/wavefront-sdk/derivedmetric.rb +7 -6
  20. data/lib/wavefront-sdk/event.rb +5 -5
  21. data/lib/wavefront-sdk/externallink.rb +3 -3
  22. data/lib/wavefront-sdk/ingestionpolicy.rb +32 -5
  23. data/lib/wavefront-sdk/integration.rb +14 -4
  24. data/lib/wavefront-sdk/internals.rb +93 -0
  25. data/lib/wavefront-sdk/maintenancewindow.rb +3 -3
  26. data/lib/wavefront-sdk/message.rb +1 -1
  27. data/lib/wavefront-sdk/metricspolicy.rb +1 -1
  28. data/lib/wavefront-sdk/monitoredapplication.rb +55 -0
  29. data/lib/wavefront-sdk/notificant.rb +4 -4
  30. data/lib/wavefront-sdk/proxy.rb +26 -4
  31. data/lib/wavefront-sdk/role.rb +2 -2
  32. data/lib/wavefront-sdk/savedsearch.rb +4 -4
  33. data/lib/wavefront-sdk/search.rb +6 -4
  34. data/lib/wavefront-sdk/source.rb +6 -6
  35. data/lib/wavefront-sdk/spansamplingpolicy.rb +126 -0
  36. data/lib/wavefront-sdk/stdlib/string.rb +1 -1
  37. data/lib/wavefront-sdk/user.rb +5 -5
  38. data/lib/wavefront-sdk/usergroup.rb +2 -2
  39. data/lib/wavefront-sdk/validators.rb +28 -5
  40. data/lib/wavefront-sdk/webhook.rb +3 -3
  41. data/lib/wavefront-sdk/write.rb +1 -0
  42. data/lib/wavefront-sdk/writers/api.rb +31 -8
  43. data/spec/spec_helper.rb +1 -1
  44. data/spec/wavefront-sdk/accesspolicy_spec.rb +53 -0
  45. data/spec/wavefront-sdk/account_spec.rb +32 -1
  46. data/spec/wavefront-sdk/alert_spec.rb +17 -0
  47. data/spec/wavefront-sdk/api_mixins/user_mixins_spec.rb +1 -1
  48. data/spec/wavefront-sdk/apitoken_spec.rb +12 -0
  49. data/spec/wavefront-sdk/cluster_spec.rb +13 -0
  50. data/spec/wavefront-sdk/core/api_caller_spec.rb +1 -1
  51. data/spec/wavefront-sdk/core/api_spec.rb +1 -1
  52. data/spec/wavefront-sdk/core/logger_spec.rb +1 -1
  53. data/spec/wavefront-sdk/core/response_spec.rb +1 -1
  54. data/spec/wavefront-sdk/credentials_spec.rb +2 -2
  55. data/spec/wavefront-sdk/distribution_spec.rb +1 -1
  56. data/spec/wavefront-sdk/ingestionpolicy_spec.rb +11 -0
  57. data/spec/wavefront-sdk/integration_spec.rb +4 -0
  58. data/spec/wavefront-sdk/internals_spec.rb +62 -0
  59. data/spec/wavefront-sdk/metric_helper_spec.rb +1 -1
  60. data/spec/wavefront-sdk/misc_spec.rb +1 -1
  61. data/spec/wavefront-sdk/monitoredapplication_spec.rb +35 -0
  62. data/spec/wavefront-sdk/paginator/base_spec.rb +1 -1
  63. data/spec/wavefront-sdk/paginator/post_spec.rb +1 -1
  64. data/spec/wavefront-sdk/proxy_spec.rb +14 -0
  65. data/spec/wavefront-sdk/resources/swagger.spec.gz +0 -0
  66. data/spec/wavefront-sdk/spansamplingpolicy_spec.rb +47 -0
  67. data/spec/wavefront-sdk/spy_spec.rb +1 -1
  68. data/spec/wavefront-sdk/stdlib/array_spec.rb +1 -1
  69. data/spec/wavefront-sdk/stdlib/hash_spec.rb +1 -1
  70. data/spec/wavefront-sdk/stdlib/string_spec.rb +1 -1
  71. data/spec/wavefront-sdk/support/mixins_spec.rb +1 -1
  72. data/spec/wavefront-sdk/support/parse_time_spec.rb +1 -1
  73. data/spec/wavefront-sdk/unstable/chart_spec.rb +1 -1
  74. data/spec/wavefront-sdk/usage_spec.rb +0 -1
  75. data/spec/wavefront-sdk/validators_spec.rb +17 -1
  76. data/spec/wavefront-sdk/write_spec.rb +1 -1
  77. data/spec/wavefront-sdk/writers/api_spec.rb +1 -1
  78. data/spec/wavefront-sdk/writers/core_spec.rb +1 -1
  79. data/spec/wavefront-sdk/writers/http_spec.rb +1 -1
  80. data/spec/wavefront-sdk/writers/proxy_spec.rb +1 -1
  81. data/spec/wavefront-sdk/writers/socket_spec.rb +1 -1
  82. data/spec/wavefront-sdk/writers/summary_spec.rb +1 -1
  83. data/wavefront-sdk.gemspec +2 -13
  84. metadata +17 -146
@@ -0,0 +1,126 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'defs/constants'
4
+ require_relative 'core/api'
5
+
6
+ module Wavefront
7
+ #
8
+ # View and manage the Wavefront span sampling policy.
9
+ #
10
+ class SpanSamplingPolicy < CoreApi
11
+ def update_keys
12
+ %i[name active expression description samplingPercent]
13
+ end
14
+
15
+ # GET /api/v2/spansamplingpolicy
16
+ # Get all sampling policies for a customer
17
+ #
18
+ # @param offset [Int] policy at which the list begins
19
+ # @param limit [Int] the number of policies to return
20
+ # @return [Wavefront::Response]
21
+ #
22
+ def list(offset = 0, limit = 100)
23
+ api.get('', offset: offset, limit: limit)
24
+ end
25
+
26
+ # POST /api/v2/spansamplingpolicy
27
+ # Create a span sampling policy
28
+ #
29
+ # @param body [Hash] description of policy
30
+ # @return [Wavefront::Response]
31
+ #
32
+ def create(body)
33
+ raise ArgumentError unless body.is_a?(Hash)
34
+
35
+ api.post('', body, 'application/json')
36
+ end
37
+
38
+ # DELETE /api/v2/spansamplingpolicy/{id}
39
+ # Delete a specific span sampling policy
40
+ #
41
+ # Deleting an active policy moves it to 'trash', from where it can
42
+ # be restored with an #undelete operation. Deleting an policy in
43
+ # 'trash' removes it for ever.
44
+ #
45
+ # @param id [String] ID of the policy
46
+ # @return [Wavefront::Response]
47
+ #
48
+ def delete(id)
49
+ wf_spansamplingpolicy_id?(id)
50
+ api.delete(id)
51
+ end
52
+
53
+ # GET /api/v2/spansamplingpolicy/deleted
54
+ # Get all deleted sampling policies for a customer
55
+ # @return [Wavefront::Response]
56
+ #
57
+ def deleted
58
+ api.get('deleted')
59
+ end
60
+
61
+ # GET /api/v2/spansamplingpolicy/{id}
62
+ # GET /api/v2/spansamplingpolicy/{id}/history/{version}
63
+ # Get a specific span sampling policy
64
+ # Get a specific policy / Get a specific historical version of a specific
65
+ # sampling policy
66
+ #
67
+ # @param id [String] ID of the policy
68
+ # @param version [Integer] version of policy
69
+ # @return [Wavefront::Response]
70
+ #
71
+ def describe(id, version = nil)
72
+ wf_spansamplingpolicy_id?(id)
73
+ wf_version?(version) if version
74
+ fragments = [id]
75
+ fragments += ['history', version] if version
76
+ api.get(fragments.uri_concat)
77
+ end
78
+
79
+ # PUT /api/v2/spansamplingpolicy/{id}
80
+ # Update a specific span sampling policy
81
+ #
82
+ # @param id [String] a Wavefront span-sampling policy ID
83
+ # @param body [Hash] key-value hash of the parameters you wish
84
+ # to change
85
+ # @param modify [true, false] if true, use {#describe()} to get
86
+ # a hash describing the existing object, and modify that with
87
+ # the new body. If false, pass the new body straight through.
88
+ # @return [Wavefront::Response]
89
+
90
+ def update(id, body, modify = true)
91
+ wf_spansamplingpolicy_id?(id)
92
+ raise ArgumentError unless body.is_a?(Hash)
93
+
94
+ return api.put(id, body, 'application/json') unless modify
95
+
96
+ api.put(id, hash_for_update(describe(id).response, body),
97
+ 'application/json')
98
+ end
99
+
100
+ # GET /api/v2/spansamplingpolicy/{id}/history
101
+ # Get the version history of a specific sampling policy
102
+ #
103
+ # @param id [String] ID of the policy
104
+ # @return [Wavefront::Response]
105
+ #
106
+ def history(id, offset = nil, limit = nil)
107
+ wf_spansamplingpolicy_id?(id)
108
+ qs = {}
109
+ qs[:offset] = offset if offset
110
+ qs[:limit] = limit if limit
111
+
112
+ api.get([id, 'history'].uri_concat, qs)
113
+ end
114
+
115
+ # POST /api/v2/spansamplingpolicy/{id}/undelete
116
+ # Restore a deleted span sampling policy
117
+ #
118
+ # @param id [String] ID of the policy
119
+ # @return [Wavefront::Response]
120
+ #
121
+ def undelete(id)
122
+ wf_spansamplingpolicy_id?(id)
123
+ api.post([id, 'undelete'].uri_concat)
124
+ end
125
+ end
126
+ end
@@ -11,6 +11,6 @@ class String
11
11
  # @return [String] a URI path
12
12
  #
13
13
  def tagescape
14
- gsub(/"/, '\"')
14
+ gsub('"', '\"')
15
15
  end
16
16
  end
@@ -49,7 +49,7 @@ module Wavefront
49
49
  api.post("?sendEmail=#{send_email}", body, 'application/json')
50
50
  end
51
51
 
52
- # DELETE /api/v2/user/id
52
+ # DELETE /api/v2/user/{id}
53
53
  # Delete a specific user. See also #delete_users.
54
54
  #
55
55
  # @param id [String] ID of the user
@@ -61,7 +61,7 @@ module Wavefront
61
61
  api.delete(id)
62
62
  end
63
63
 
64
- # GET /api/v2/user/id
64
+ # GET /api/v2/user/{id}
65
65
  # Retrieves a user by identifier (email addr).
66
66
  #
67
67
  # @param id [String] ID of the user
@@ -73,7 +73,7 @@ module Wavefront
73
73
  api.get(id)
74
74
  end
75
75
 
76
- # PUT /api/v2/user/id
76
+ # PUT /api/v2/user/{id}
77
77
  # Update a specific user definition.
78
78
  #
79
79
  # @param id [String] a Wavefront user ID
@@ -124,7 +124,7 @@ module Wavefront
124
124
  'application/json')
125
125
  end
126
126
 
127
- # PUT /api/v2/user/id/grant
127
+ # POST /api/v2/user/{id}/grant
128
128
  # Grants a specific user permission.
129
129
  #
130
130
  # @param id [String] ID of the user
@@ -147,7 +147,7 @@ module Wavefront
147
147
  'application/x-www-form-urlencoded')
148
148
  end
149
149
 
150
- # PUT /api/v2/user/id/revoke
150
+ # POST /api/v2/user/{id}/revoke
151
151
  # Revokes a specific user permission.
152
152
  #
153
153
  # @param id [String] ID of the user
@@ -16,8 +16,8 @@ module Wavefront
16
16
 
17
17
  # GET /api/v2/usergroup
18
18
  # Get all user groups for a customer
19
- # @param offset [Int] alert at which the list begins
20
- # @param limit [Int] the number of alerts to return
19
+ # @param offset [Int] usergroup at which the list begins
20
+ # @param limit [Int] the number of usergroups to return
21
21
  # @return [Wavefront::Response]
22
22
  #
23
23
  def list(offset = 0, limit = 100)
@@ -164,8 +164,7 @@ module Wavefront
164
164
  #
165
165
  # @param version [Integer] the version number to validate
166
166
  # @return True if the version is valid
167
- # @raise Wavefront::Exception::InvalidVersion if the alert ID is
168
- # not valid
167
+ # @raise Wavefront::Exception::InvalidVersion if the ID is not valid
169
168
  #
170
169
  def wf_version?(version)
171
170
  version = version.to_i if version.is_a?(String) && version =~ /^\d+$/
@@ -197,7 +196,7 @@ module Wavefront
197
196
  def wf_point_tag?(key, val)
198
197
  if key && val && (key.size + val.size < 254) &&
199
198
  key =~ /^[\w\-.:]+$/ && val !~ /\\$/
200
- return
199
+ return false
201
200
  end
202
201
 
203
202
  raise Wavefront::Exception::InvalidTag, "#{key}=#{val}"
@@ -589,10 +588,10 @@ module Wavefront
589
588
  # ID is not valid
590
589
  #
591
590
  def wf_account_id?(id)
592
- return true if wf_user_id?(id)
591
+ true if wf_user_id?(id)
593
592
  rescue Wavefront::Exception::InvalidUserId
594
593
  begin
595
- return true if wf_serviceaccount_id?(id)
594
+ true if wf_serviceaccount_id?(id)
596
595
  rescue Wavefront::Exception::InvalidServiceAccountId
597
596
  raise Wavefront::Exception::InvalidAccountId, id
598
597
  end
@@ -609,6 +608,17 @@ module Wavefront
609
608
  raise Wavefront::Exception::InvalidMonitoredClusterId, id
610
609
  end
611
610
 
611
+ # Ensure the given argument is a valid monitored application ID
612
+ # @param id [String]
613
+ # @raise Wavefront::Exception::InvalidMonitoredApplicationId if the ID is
614
+ # not valid
615
+ #
616
+ def wf_monitoredapplication_id?(id)
617
+ return true if id.is_a?(String) && id.size < 256 && id =~ /^[a-z0-9\-_]+$/
618
+
619
+ raise Wavefront::Exception::InvalidMonitoredApplicationId, id
620
+ end
621
+
612
622
  # Ensure the given value is a valid sampling rate.
613
623
  # @param rate [Float]
614
624
  # @raise Wavefront::Exception::InvalidSamplingValue
@@ -654,6 +664,19 @@ module Wavefront
654
664
 
655
665
  raise Wavefront::Exception::InvalidMetricsPolicyId, id
656
666
  end
667
+
668
+ # Ensure the given argument is a valid Wavefront Span Sampling Policy ID.
669
+ # So far as I can tell they're just strings.
670
+ #
671
+ # @param id [String] the span sampling policy ID to validate
672
+ # @return true if the ID is valid
673
+ # @raise Wavefront::Exception::InvalidSpanSamplingPolicyId if the ID is
674
+ # not valid
675
+ def wf_spansamplingpolicy_id?(id)
676
+ return true if id.is_a?(String)
677
+
678
+ raise Wavefront::Exception::InvalidSpanSamplingPolicyId, id
679
+ end
657
680
  end
658
681
  # rubocop:enable Metrics/ModuleLength
659
682
  end
@@ -35,7 +35,7 @@ module Wavefront
35
35
  api.post('', body, 'application/json')
36
36
  end
37
37
 
38
- # DELETE /api/v2/webhook/id
38
+ # DELETE /api/v2/webhook/{id}
39
39
  # Delete a specific webhook.
40
40
  #
41
41
  # @param id [String, Integer] ID of the webhook
@@ -46,7 +46,7 @@ module Wavefront
46
46
  api.delete(id)
47
47
  end
48
48
 
49
- # GET /api/v2/webhook/id
49
+ # GET /api/v2/webhook/{id}
50
50
  # Get a specific webhook.
51
51
  #
52
52
  # @param id [String, Integer] ID of the webhook
@@ -57,7 +57,7 @@ module Wavefront
57
57
  api.get(id)
58
58
  end
59
59
 
60
- # PUT /api/v2/webhook/id
60
+ # PUT /api/v2/webhook/{id}
61
61
  # Update a specific webhook.
62
62
  #
63
63
  # @param id [String] a Wavefront webhook ID
@@ -88,6 +88,7 @@ module Wavefront
88
88
  writer.close
89
89
  end
90
90
 
91
+ # POST /report
91
92
  # A wrapper to the writer class's #write method.
92
93
  # Writers implement this method differently, Check the
93
94
  # appropriate class documentation for @return information etc.
@@ -6,10 +6,23 @@ require_relative '../core/api_caller'
6
6
  module Wavefront
7
7
  module Writer
8
8
  #
9
- # Send points direct to Wavefront's API. This requires an
10
- # endpoint, a token, and HTTPS egress.
9
+ # Send points direct to Wavefront's API. This requires an endpoint, a
10
+ # token, and HTTPS egress.
11
+ #
12
+ # Points are sent in batches of BATCH_SIZE. We attempt to make a summary
13
+ # of how many points are sent or rejected, but it's quantized by the batch
14
+ # size.
15
+ #
16
+ # TODO I think this needs a composite response. It makes one or more API
17
+ # calls depending on the amount of metrics to be sent, and the CLI needs
18
+ # to know if there was anything other than a 200. Options are to return
19
+ # the first failure when it happens, or to try all the chunks and return
20
+ # the last non-200, or the highest numbered return code, or some other
21
+ # indication of failure.
11
22
  #
12
23
  class Api < Core
24
+ BATCH_SIZE = 100
25
+
13
26
  def open
14
27
  @conn = Wavefront::ApiCaller.new(self, creds, opts)
15
28
  end
@@ -32,7 +45,6 @@ module Wavefront
32
45
 
33
46
  def send_point(body)
34
47
  _send_point(body)
35
- summary.sent += body.size
36
48
  true
37
49
  rescue StandardError => e
38
50
  summary.unsent += body.size
@@ -52,15 +64,26 @@ module Wavefront
52
64
  send_point(body)
53
65
  end
54
66
 
55
- # Send points in batches of a hundred. I'm not sure exactly
56
- # how much the API can cope with in a single call, so this
57
- # might change.
67
+ # Send points in batches of BATCH_SIZE. I'm not sure exactly how much the
68
+ # API can cope with in a single call, so this might change.
69
+ # @return [Nil]
58
70
  #
71
+ # rubocop:disable Metrics/MethodLength
59
72
  def _send_point(body)
60
- body.each_slice(100) do |p|
61
- conn.post('/?f=wavefront', p.join("\n"), 'application/octet-stream')
73
+ body.each_slice(BATCH_SIZE) do |p|
74
+ ret = conn.post('/?f=wavefront', p.join("\n"),
75
+ 'application/octet-stream')
76
+
77
+ if ret.ok?
78
+ logger.log("sent #{BATCH_SIZE} points", :debug)
79
+ summary.sent += p.count
80
+ else
81
+ logger.log("failed to send #{BATCH_SIZE} points", :debug)
82
+ summary.unsent += p.count
83
+ end
62
84
  end
63
85
  end
86
+ # rubocop:enable Metrics/MethodLength
64
87
  end
65
88
  end
66
89
  end
data/spec/spec_helper.rb CHANGED
@@ -10,7 +10,7 @@ require_relative 'constants'
10
10
 
11
11
  # Abstract class which sets up everything needed by the API tests
12
12
  #
13
- class WavefrontTestBase < MiniTest::Test
13
+ class WavefrontTestBase < Minitest::Test
14
14
  attr_reader :wf, :wf_noop, :headers, :invalid_id, :valid_id
15
15
 
16
16
  def initialize(args)
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../spec_helper'
5
+ require_relative '../test_mixins/general'
6
+
7
+ # Unit tests for AccessPolicy class
8
+ #
9
+ class WavefrontAccessPolicyTest < WavefrontTestBase
10
+ def test_describe
11
+ assert_gets('/api/v2/accesspolicy') { wf.describe }
12
+ end
13
+
14
+ def test_update
15
+ assert_puts('/api/v2/accesspolicy', payload.to_json) do
16
+ wf.update(payload)
17
+ end
18
+ end
19
+
20
+ def test_validate
21
+ assert_gets('/api/v2/accesspolicy/validate?ip=1.2.3.4') do
22
+ wf.validate('1.2.3.4')
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def api_class
29
+ 'accesspolicy'
30
+ end
31
+
32
+ def payload
33
+ {
34
+ status: {
35
+ result: 'OK',
36
+ message: 'string',
37
+ code: 0
38
+ },
39
+ response: {
40
+ customer: 'string',
41
+ lastUpdatedMs: 0,
42
+ policyRules: [
43
+ {
44
+ name: 'string',
45
+ description: 'string',
46
+ subnet: 'string',
47
+ action: 'ALLOW'
48
+ }
49
+ ]
50
+ }
51
+ }
52
+ end
53
+ end
@@ -179,6 +179,18 @@ class WavefrontAccountTest < WavefrontTestBase
179
179
  assert_raises(ArgumentError) { wf.validate_accounts }
180
180
  end
181
181
 
182
+ def test_admins
183
+ assert_gets('/api/v2/account/user/admin') { wf.admins }
184
+ end
185
+
186
+ def test_update_perms
187
+ assert_invalid_id { wf.update_perms(invalid_id, perms_payload) }
188
+
189
+ assert_puts("/api/v2/account/user/#{user_id}", perms_payload.to_json) do
190
+ wf.update_perms(user_id, perms_payload, false)
191
+ end
192
+ end
193
+
182
194
  private
183
195
 
184
196
  def api_class
@@ -203,6 +215,10 @@ class WavefrontAccountTest < WavefrontTestBase
203
215
  2659191e-aad4-4302-a94e-9667e1515678]
204
216
  end
205
217
 
218
+ def user_id
219
+ 'user@example.com'
220
+ end
221
+
206
222
  def invalid_role
207
223
  %w[bad_role]
208
224
  end
@@ -212,7 +228,7 @@ class WavefrontAccountTest < WavefrontTestBase
212
228
  end
213
229
 
214
230
  def id_list
215
- %w[sa:test user@example.com]
231
+ ['sa:test', user_id]
216
232
  end
217
233
 
218
234
  def invalid_permission
@@ -235,4 +251,19 @@ class WavefrontAccountTest < WavefrontTestBase
235
251
  { emailAddress: id,
236
252
  groups: %w[browse] }
237
253
  end
254
+
255
+ def perms_payload
256
+ {
257
+ identifier: 'user@example.com',
258
+ groups: [
259
+ 'user_management'
260
+ ],
261
+ userGroups: [
262
+ '8b23136b-ecd2-4cb5-8c92-62477dcc4090'
263
+ ],
264
+ roles: [
265
+ 'Role'
266
+ ]
267
+ }
268
+ end
238
269
  end
@@ -35,6 +35,23 @@ class WavefrontAlertTest < WavefrontTestBase
35
35
  assert_invalid_id { wf.unsnooze(invalid_id) }
36
36
  end
37
37
 
38
+ def test_check_query
39
+ query = {
40
+ inputQuery: 'string',
41
+ translatedInput: 'sum(http_requests_total{method="GET"})',
42
+ queryType: 'PromQL'
43
+ }
44
+ assert_posts('/api/v2/alert/checkQuery', query.to_json) do
45
+ wf.check_query(query)
46
+ end
47
+ end
48
+
49
+ def test_preview
50
+ assert_posts('/api/v2/alert/preview', payload.to_json) do
51
+ wf.preview(payload)
52
+ end
53
+ end
54
+
38
55
  def test_summary
39
56
  assert_gets('/api/v2/alert/summary') { wf.summary }
40
57
  end
@@ -8,7 +8,7 @@ require_relative '../../../lib/wavefront-sdk/core/exception'
8
8
 
9
9
  # Test user mixins
10
10
  #
11
- class WavefrontUserMixinsTest < MiniTest::Test
11
+ class WavefrontUserMixinsTest < Minitest::Test
12
12
  include Wavefront::Mixin::User
13
13
  include Wavefront::Validators
14
14
 
@@ -10,6 +10,18 @@ class WavefrontApiTokenTest < WavefrontTestBase
10
10
  assert_gets('/api/v2/apitoken') { wf.list }
11
11
  end
12
12
 
13
+ def test_list_customer_tokens
14
+ assert_gets('/api/v2/apitoken/customertokens') { wf.list_customer_tokens }
15
+ end
16
+
17
+ def test_describe_customer_token
18
+ assert_invalid_id { wf.describe_customer_token(invalid_token_id) }
19
+
20
+ assert_gets("/api/v2/apitoken/customertokens/#{token_id}") do
21
+ wf.describe_customer_token(token_id)
22
+ end
23
+ end
24
+
13
25
  def test_create
14
26
  assert_posts('/api/v2/apitoken', 'null') { wf.create }
15
27
  assert_raises(ArgumentError) { wf.create('test') }
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../spec_helper'
5
+ require_relative '../test_mixins/general'
6
+
7
+ # Unit tests for Cluster class
8
+ #
9
+ class WavefrontClusterTest < WavefrontTestBase
10
+ def test_describe
11
+ assert_gets('/api/v2/cluster/info') { wf.describe }
12
+ end
13
+ end
@@ -19,7 +19,7 @@ end
19
19
 
20
20
  # Test Wavefront API caller
21
21
  #
22
- class WavefrontApiCallerTest < MiniTest::Test
22
+ class WavefrontApiCallerTest < Minitest::Test
23
23
  attr_reader :wf, :wf_noop, :uri_base, :headers
24
24
 
25
25
  def setup
@@ -6,7 +6,7 @@ require_relative '../../../lib/wavefront-sdk/core/api'
6
6
 
7
7
  # Test SDK core API class
8
8
  #
9
- class WavefrontCoreApiTest < MiniTest::Test
9
+ class WavefrontCoreApiTest < Minitest::Test
10
10
  attr_reader :wf
11
11
 
12
12
  def setup
@@ -7,7 +7,7 @@ require_relative '../../../lib/wavefront-sdk/core/logger'
7
7
 
8
8
  # Test SDK logger class
9
9
  #
10
- class WavefrontLoggerTest < MiniTest::Test
10
+ class WavefrontLoggerTest < Minitest::Test
11
11
  attr_reader :wfl
12
12
 
13
13
  def setup
@@ -20,7 +20,7 @@ ERR_RESP = { error: 'HTTP 415 Unsupported Media Type',
20
20
  # Unit tests for Response class. Also indirectly tests the Status
21
21
  # type.
22
22
  #
23
- class WavefrontResponseTest < MiniTest::Test
23
+ class WavefrontResponseTest < Minitest::Test
24
24
  attr_reader :wfg, :wfb, :wfe
25
25
 
26
26
  def setup
@@ -10,7 +10,7 @@ CONF2 = RESOURCE_DIR.join('test2.conf')
10
10
 
11
11
  # Test SDK base class end-to-end
12
12
  #
13
- class WavefrontCredentialsTest < MiniTest::Test
13
+ class WavefrontCredentialsTest < Minitest::Test
14
14
  def test_initialize_1
15
15
  ENV.delete('WAVEFRONT_ENDPOINT')
16
16
  ENV.delete('WAVEFRONT_TOKEN')
@@ -64,7 +64,7 @@ class Giblets < Wavefront::Credentials; end
64
64
 
65
65
  # And here are the tests
66
66
  #
67
- class GibletsTest < MiniTest::Test
67
+ class GibletsTest < Minitest::Test
68
68
  attr_reader :wf, :raw
69
69
 
70
70
  def setup
@@ -7,7 +7,7 @@ require_relative '../../lib/wavefront-sdk/distribution'
7
7
  # Most of the distribution methods are inherited from the Write
8
8
  # class so they aren't tested again here.
9
9
  #
10
- class WavefrontDistributionTest < MiniTest::Test
10
+ class WavefrontDistributionTest < Minitest::Test
11
11
  attr_reader :wf
12
12
 
13
13
  def setup
@@ -11,6 +11,17 @@ class WavefrontIngestionPolicyTest < WavefrontTestBase
11
11
  include WavefrontTest::Describe
12
12
  include WavefrontTest::Update
13
13
  include WavefrontTest::Delete
14
+ include WavefrontTest::History
15
+
16
+ def test_revert
17
+ assert_posts("/api/v2/usage/ingestionpolicy/#{id}/revert/5", nil, :json) do
18
+ wf.revert(id, 5)
19
+ end
20
+
21
+ assert_raises(Wavefront::Exception::InvalidVersion) { wf.revert(id, 'v5') }
22
+
23
+ assert_invalid_id { wf.revert(invalid_id, 5) }
24
+ end
14
25
 
15
26
  private
16
27
 
@@ -47,6 +47,10 @@ class WavefrontIntegrationTest < WavefrontTestBase
47
47
  assert_gets('/api/v2/integration/status') { wf.statuses }
48
48
  end
49
49
 
50
+ def test_manifests_min
51
+ assert_gets('/api/v2/integration/manifests/min') { wf.manifests_min }
52
+ end
53
+
50
54
  private
51
55
 
52
56
  def api_class