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,62 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'zlib'
5
+ require_relative '../spec_helper'
6
+ require_relative '../../lib/wavefront-sdk/internals'
7
+
8
+ # Tests for internal methods
9
+ #
10
+ class TestInternals < Minitest::Test
11
+ attr_reader :t
12
+
13
+ def setup
14
+ @t = Wavefront::Internals.new
15
+ end
16
+
17
+ def test_sdk_files
18
+ result = t.sdk_files
19
+ assert_instance_of(Array, result)
20
+ assert(result.all?(&:file?))
21
+ assert(result.all? { |f| f.extname == '.rb' })
22
+ end
23
+
24
+ def test_supported_api_paths
25
+ result = t.supported_api_paths
26
+ assert_instance_of(Array, result)
27
+ assert paths_are_good(result)
28
+ end
29
+
30
+ def test_remote_api_paths
31
+ result = t.remote_api_paths(spec_resource)
32
+
33
+ assert paths_are_good(result)
34
+ end
35
+
36
+ def paths_are_good(result)
37
+ verbs = %w[GET PUT POST PATCH DELETE]
38
+
39
+ assert(result.all? do |verb, path|
40
+ verbs.include?(verb) && (path == '/report' ||
41
+ path.match?(%r{^/api/(v2|spy)/}))
42
+ end)
43
+
44
+ assert_includes(result, ['GET', '/api/v2/usage/ingestionpolicy/{id}'])
45
+ assert_includes(result, ['POST', '/api/v2/dashboard/acl/add'])
46
+ assert_includes(result, ['PUT', '/api/v2/dashboard/{id}/tag/{tagValue}'])
47
+
48
+ assert_includes(result, ['POST', '/api/v2/search/derivedmetric'])
49
+ assert_includes(result, ['POST', '/api/v2/search/derivedmetric/deleted'])
50
+ # assert_includes(result,
51
+ # ['POST', '/api/v2/search/derivedmetric/deleted/facets'])
52
+ # assert_includes(result,
53
+ # ['POST', '/api/v2/search/derivedmetric/deleted/{facet}'])
54
+ assert_includes(result, ['POST', '/api/v2/search/derivedmetric/facets'])
55
+ assert_includes(result, ['POST', '/api/v2/search/derivedmetric/{facet}'])
56
+ assert_includes(result, ['POST', '/api/v2/search/event'])
57
+ end
58
+
59
+ def spec_resource
60
+ Zlib::GzipReader.new(File.open(RESOURCE_DIR.join('swagger.spec.gz'))).read
61
+ end
62
+ end
@@ -13,7 +13,7 @@ WH_TAGS = { t1: 'v1', t2: 'v2' }.freeze
13
13
  # Tests for the MetricHelper class.
14
14
  #
15
15
  # rubocop:disable Style/NumericLiterals
16
- class WavefrontMetricHelperTest < MiniTest::Test
16
+ class WavefrontMetricHelperTest < Minitest::Test
17
17
  attr_reader :wf, :wfd
18
18
 
19
19
  def setup
@@ -6,7 +6,7 @@ require_relative '../../lib/wavefront-sdk/defs/version'
6
6
 
7
7
  # Tests for things that aren't in the SDK itself.
8
8
  #
9
- class WavefrontMiscTest < MiniTest::Test
9
+ class WavefrontMiscTest < Minitest::Test
10
10
  # Check the latest version mentioned in the changelog is the version the SDK
11
11
  # defines itself as.
12
12
  #
@@ -0,0 +1,35 @@
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 Webhook class
8
+ #
9
+ class WavefrontWebhookTest < WavefrontTestBase
10
+ include WavefrontTest::Describe
11
+ include WavefrontTest::List
12
+ include WavefrontTest::Update
13
+
14
+ private
15
+
16
+ def api_class
17
+ 'monitoredapplication'
18
+ end
19
+
20
+ def id
21
+ 'beachshirts'
22
+ end
23
+
24
+ def invalid_id
25
+ '+-+-+-+'
26
+ end
27
+
28
+ def payload
29
+ {
30
+ application: 'beachshirts',
31
+ satisfiedLatencyMillis: 100_000,
32
+ hidden: 'false'
33
+ }
34
+ end
35
+ end
@@ -18,7 +18,7 @@ end
18
18
 
19
19
  # Paginator tests
20
20
  #
21
- class WavefrontPaginatorBaseTest < MiniTest::Test
21
+ class WavefrontPaginatorBaseTest < Minitest::Test
22
22
  attr_reader :wf, :apicaller, :conn
23
23
 
24
24
  def setup
@@ -19,7 +19,7 @@ end
19
19
 
20
20
  # Test POST pagination
21
21
  #
22
- class WavefrontPaginatorPostTest < MiniTest::Test
22
+ class WavefrontPaginatorPostTest < Minitest::Test
23
23
  attr_reader :wf, :apicaller, :conn
24
24
 
25
25
  def setup
@@ -27,6 +27,20 @@ class WavefrontProxyTest < WavefrontTestBase
27
27
  end
28
28
  end
29
29
 
30
+ def test_config
31
+ assert_invalid_id { wf.config(invalid_id) }
32
+
33
+ assert_gets("/api/v2/proxy/#{id}/config") { wf.config(id) }
34
+ end
35
+
36
+ def test_preprocessor_rules
37
+ assert_invalid_id { wf.preprocessor_rules(invalid_id) }
38
+
39
+ assert_gets("/api/v2/proxy/#{id}/preprocessorRules") do
40
+ wf.preprocessor_rules(id)
41
+ end
42
+ end
43
+
30
44
  private
31
45
 
32
46
  def api_class
@@ -0,0 +1,47 @@
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 SpanSamplingPolicy class
8
+ #
9
+ class WavefrontSpanSamplingPolicyTest < WavefrontTestBase
10
+ include WavefrontTest::Create
11
+ include WavefrontTest::DeleteUndelete
12
+ include WavefrontTest::Describe
13
+ include WavefrontTest::History
14
+ include WavefrontTest::List
15
+ include WavefrontTest::Update
16
+
17
+ def test_deleted
18
+ assert_gets('/api/v2/spansamplingpolicy/deleted') { wf.deleted }
19
+ end
20
+
21
+ private
22
+
23
+ # used by the things we #include
24
+ #
25
+ def api_class
26
+ 'spansamplingpolicy'
27
+ end
28
+
29
+ def id
30
+ 'test_policy'
31
+ end
32
+
33
+ def invalid_id
34
+ {}
35
+ end
36
+
37
+ def payload
38
+ {
39
+ name: 'Test',
40
+ id: 'test',
41
+ active: false,
42
+ expression: "{{sourceName}}='localhost'",
43
+ description: 'test description',
44
+ samplingPercent: 100
45
+ }
46
+ end
47
+ end
@@ -6,7 +6,7 @@ require_relative '../../lib/wavefront-sdk/spy'
6
6
 
7
7
  # Unit tests for Spy class
8
8
  #
9
- class WavefrontSpyTest < MiniTest::Test
9
+ class WavefrontSpyTest < Minitest::Test
10
10
  attr_reader :wf
11
11
 
12
12
  def setup
@@ -6,7 +6,7 @@ require_relative '../../../lib/wavefront-sdk/stdlib/array'
6
6
 
7
7
  # Test extensions to stdlib's Array class
8
8
  #
9
- class ArrayTest < MiniTest::Test
9
+ class ArrayTest < Minitest::Test
10
10
  def test_uri_concat
11
11
  assert_equal('a/b', %w[a b].uri_concat)
12
12
  assert_equal('/a/b', ['', 'a', 'b'].uri_concat)
@@ -6,7 +6,7 @@ require_relative '../../../lib/wavefront-sdk/stdlib/hash'
6
6
 
7
7
  # Test extensions to stdlib hash class
8
8
  #
9
- class HashTest < MiniTest::Test
9
+ class HashTest < Minitest::Test
10
10
  def test_to_wf_tag
11
11
  assert_equal('', {}.to_wf_tag)
12
12
  assert_equal('gt1="gv1" gt2="gv2"',
@@ -6,7 +6,7 @@ require_relative '../../../lib/wavefront-sdk/stdlib/string'
6
6
 
7
7
  # Test extensions to stdlib's String class
8
8
  #
9
- class StringTest < MiniTest::Test
9
+ class StringTest < Minitest::Test
10
10
  def test_tagescape
11
11
  assert_equal('value', 'value'.tagescape)
12
12
  assert_equal('two words', 'two words'.tagescape)
@@ -7,7 +7,7 @@ require 'spy/integration'
7
7
 
8
8
  # Test SDK mixins
9
9
  #
10
- class WavefrontMixinsTest < MiniTest::Test
10
+ class WavefrontMixinsTest < Minitest::Test
11
11
  include Wavefront::Mixins
12
12
 
13
13
  def test_parse_time
@@ -9,7 +9,7 @@ TSM = 1_517_151_869_523
9
9
 
10
10
  # Test parse_time class
11
11
  #
12
- class WavefrontParseTimeTest < MiniTest::Test
12
+ class WavefrontParseTimeTest < Minitest::Test
13
13
  attr_reader :pts, :ptm
14
14
 
15
15
  def setup
@@ -6,7 +6,7 @@ require_relative '../../../lib/wavefront-sdk/unstable/chart'
6
6
 
7
7
  # Unit tests for Chart class
8
8
  #
9
- class WavefrontChartTest < MiniTest::Test
9
+ class WavefrontChartTest < Minitest::Test
10
10
  attr_reader :wf
11
11
 
12
12
  def setup
@@ -2,7 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require_relative '../spec_helper'
5
- require_relative '../test_mixins/general'
6
5
 
7
6
  # Unit tests for Usage class
8
7
  #
@@ -8,7 +8,7 @@ require_relative '../../lib/wavefront-sdk/validators'
8
8
 
9
9
  # Validator tests, obviously. Happy now Rubocop?
10
10
  #
11
- class WavefrontValidatorsTest < MiniTest::Test
11
+ class WavefrontValidatorsTest < Minitest::Test
12
12
  include Wavefront::Validators
13
13
 
14
14
  def good_and_bad(method, exception, good, bad)
@@ -396,6 +396,15 @@ class WavefrontValidatorsTest < MiniTest::Test
396
396
  bad)
397
397
  end
398
398
 
399
+ def test_wf_managedapplication_id
400
+ good = %w[test-app other-app application]
401
+ bad = ['', [], {}, 'a' * 1000, '£"^WR"!']
402
+ good_and_bad('wf_monitoredapplication_id?',
403
+ 'InvalidMonitoredApplicationId',
404
+ good,
405
+ bad)
406
+ end
407
+
399
408
  def test_wf_sampling_value
400
409
  good = [0, 0.01, 0.003, 0.05]
401
410
  bad = ['a', 0.1, 0.99, 1, -1, 1.1]
@@ -427,4 +436,11 @@ class WavefrontValidatorsTest < MiniTest::Test
427
436
  bad = %w[fa312fb-5ff4-420d-862d-5d6d99ed6bcf thing 123]
428
437
  good_and_bad('wf_metricspolicy_id?', 'InvalidMetricsPolicyId', good, bad)
429
438
  end
439
+
440
+ def test_wf_spansamplingpolicy_id
441
+ good = ['My Policy', 'policy', 'etc_etc_etc']
442
+ bad = [Pathname.pwd, nil]
443
+ good_and_bad('wf_spansamplingpolicy_id?', 'InvalidSpanSamplingPolicyId',
444
+ good, bad)
445
+ end
430
446
  end
@@ -11,7 +11,7 @@ require_relative 'resources/dummy_points'
11
11
  # This class is sufficiently different to the API calling classes
12
12
  # that it doesn't use spec helper or inherit anything.
13
13
  #
14
- class WavefrontWriteTest < MiniTest::Test
14
+ class WavefrontWriteTest < Minitest::Test
15
15
  attr_reader :wf, :wf_noop, :wf_tags
16
16
 
17
17
  def setup
@@ -10,7 +10,7 @@ HEADERS = POST_HEADERS.merge('Content-Type': 'application/octet-stream')
10
10
  # The report class test will test that an API call is made. Here all
11
11
  # that's left to test is the #validate_credentials method.
12
12
  #
13
- class WavefrontWriterApiTest < MiniTest::Test
13
+ class WavefrontWriterApiTest < Minitest::Test
14
14
  attr_reader :wf
15
15
 
16
16
  def setup
@@ -30,7 +30,7 @@ end
30
30
 
31
31
  # Test methods common to 'write' and 'report'
32
32
  #
33
- class WavefrontCoreWriteTest < MiniTest::Test
33
+ class WavefrontCoreWriteTest < Minitest::Test
34
34
  attr_reader :wf, :wf_tags
35
35
 
36
36
  def setup
@@ -10,7 +10,7 @@ WH_CREDS = { proxy: 'wavefront-proxy' }.freeze
10
10
 
11
11
  # Test HTTP transport
12
12
  #
13
- class WavefrontWriterSocketTest < MiniTest::Test
13
+ class WavefrontWriterSocketTest < Minitest::Test
14
14
  attr_reader :wf
15
15
 
16
16
  def setup
@@ -15,7 +15,7 @@ WS_CREDS = { proxy: 'wavefront-proxy' }.freeze
15
15
 
16
16
  # The Proxy class writes to a proxy TCP socket
17
17
  #
18
- class WavefrontWriterSocketTest < MiniTest::Test
18
+ class WavefrontWriterSocketTest < Minitest::Test
19
19
  attr_reader :wf, :wf_noop
20
20
 
21
21
  def setup
@@ -17,7 +17,7 @@ WU_CREDS = { socket: UNIX_SOCK }.freeze
17
17
 
18
18
  # Test UNIX Datagram socket writing
19
19
  #
20
- class WavefrontWriterUnixTest < MiniTest::Test
20
+ class WavefrontWriterUnixTest < Minitest::Test
21
21
  attr_reader :wf, :wf_noop
22
22
 
23
23
  def setup
@@ -6,7 +6,7 @@ require_relative '../../spec_helper'
6
6
 
7
7
  # Tests for summarizer
8
8
  #
9
- class WavefronWriterSummaryTest < MiniTest::Test
9
+ class WavefronWriterSummaryTest < Minitest::Test
10
10
  attr_reader :wf
11
11
 
12
12
  def setup
@@ -21,21 +21,10 @@ Gem::Specification.new do |gem|
21
21
  gem.bindir = 'bin'
22
22
 
23
23
  gem.add_dependency 'addressable', '~> 2.8'
24
- gem.add_dependency 'faraday', '~> 1.1'
24
+ gem.add_dependency 'faraday', '~> 2.7'
25
25
  gem.add_dependency 'inifile', '~> 3.0'
26
26
  gem.add_dependency 'map', '~> 6.6'
27
27
 
28
- gem.add_development_dependency 'minitest', '~> 5.17'
29
- gem.add_development_dependency 'rake', '~> 13.0'
30
- gem.add_development_dependency 'rubocop', '~> 1.43'
31
- gem.add_development_dependency 'rubocop-minitest', '~> 0.26'
32
- gem.add_development_dependency 'rubocop-performance', '~> 1.15'
33
- gem.add_development_dependency 'rubocop-rake', '~> 0.6'
34
- gem.add_development_dependency 'simplecov', '~> 0.18'
35
- gem.add_development_dependency 'spy', '1.0'
36
- gem.add_development_dependency 'webmock', '~> 3.18'
37
- gem.add_development_dependency 'yard', '~> 0.9'
38
-
39
- gem.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
28
+ gem.required_ruby_version = Gem::Requirement.new('>= 3.0')
40
29
  gem.metadata['rubygems_mfa_required'] = 'true'
41
30
  end