wavefront-sdk 4.0.0 → 5.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +12 -1
  3. data/HISTORY.md +28 -0
  4. data/README.md +3 -2
  5. data/lib/wavefront-sdk/account.rb +104 -3
  6. data/lib/wavefront-sdk/api_mixins/user.rb +10 -0
  7. data/lib/wavefront-sdk/cloudintegration.rb +27 -0
  8. data/lib/wavefront-sdk/core/exception.rb +3 -0
  9. data/lib/wavefront-sdk/credentials.rb +28 -9
  10. data/lib/wavefront-sdk/defs/version.rb +3 -1
  11. data/lib/wavefront-sdk/distribution.rb +2 -0
  12. data/lib/wavefront-sdk/paginator/base.rb +21 -15
  13. data/lib/wavefront-sdk/query.rb +0 -1
  14. data/lib/wavefront-sdk/role.rb +128 -0
  15. data/lib/wavefront-sdk/spy.rb +126 -0
  16. data/lib/wavefront-sdk/stdlib/array.rb +1 -1
  17. data/lib/wavefront-sdk/user.rb +31 -0
  18. data/lib/wavefront-sdk/usergroup.rb +17 -16
  19. data/lib/wavefront-sdk/validators.rb +31 -7
  20. data/lib/wavefront-sdk/writers/core.rb +2 -2
  21. data/spec/.rubocop.yml +13 -3
  22. data/spec/support/minitest_assertions.rb +5 -11
  23. data/spec/wavefront-sdk/account_spec.rb +107 -1
  24. data/spec/wavefront-sdk/cloudintegration_spec.rb +38 -0
  25. data/spec/wavefront-sdk/core/logger_spec.rb +3 -3
  26. data/spec/wavefront-sdk/credentials_spec.rb +5 -4
  27. data/spec/wavefront-sdk/metric_helper_spec.rb +1 -1
  28. data/spec/wavefront-sdk/role_spec.rb +96 -0
  29. data/spec/wavefront-sdk/{unstable/spy_spec.rb → spy_spec.rb} +3 -3
  30. data/spec/wavefront-sdk/user_spec.rb +8 -0
  31. data/spec/wavefront-sdk/usergroup_spec.rb +21 -11
  32. data/spec/wavefront-sdk/validators_spec.rb +16 -0
  33. data/spec/wavefront-sdk/writers/core_spec.rb +1 -1
  34. data/wavefront-sdk.gemspec +6 -6
  35. metadata +23 -24
  36. data/lib/wavefront-sdk/monitoredcluster.rb +0 -93
  37. data/lib/wavefront-sdk/unstable/spy.rb +0 -134
  38. data/spec/wavefront-sdk/monitoredcluster_spec.rb +0 -55
@@ -1,134 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../defs/constants'
4
- require_relative '../core/api'
5
-
6
- module Wavefront
7
- module Unstable
8
- #
9
- # THIS IS AN UNSTABLE CLASS. PLEASE REFER TO README.md.
10
- #
11
- # Everything about this API is different from the public one. To make it
12
- # appear similar we must change various things we normally take for
13
- # granted.
14
- #
15
- # This class is built according to the documentation at
16
- # https://docs.wavefront.com/wavefront_monitoring_spy.html
17
- #
18
- class Spy < CoreApi
19
- # https://<cluster>.wavefront.com/api/spy/points
20
- # Gets new metric data points that are added to existing time series.
21
- # @param sampling [Float] the amount of points to sample, from 0
22
- # (none) to 1 (all)
23
- # @param filter [Hash] with the following keys:
24
- # :prefix [String] only list points whose metric name begins with this
25
- # case-sensitive string
26
- # :host [Array] only list points if source name begins with this
27
- # case-sensitive string
28
- # :tag_key [String,Array[String]] only list points with one or more of
29
- # the given points tags
30
- # @param options [Hash] with the following keys
31
- # :timestamp [Boolean] prefix each block of streamed data with a
32
- # timestamp
33
- # :timeout [Integer] how many seconds to run the spy. After this time
34
- # the method returns
35
- # @raise Wavefront::Exception::InvalidSamplingValue
36
- # @return [Nil]
37
- #
38
- def points(sampling = 0.01, filters = {}, options = {})
39
- wf_sampling_value?(sampling)
40
- api.get_stream('points', points_filter(sampling, filters), options)
41
- end
42
-
43
- # Gets new histograms that are added to existing time series.
44
- # @param sampling [Float] see #points
45
- # @param filter [Hash] see #points
46
- # @param options [Hash] see #points
47
- # @raise Wavefront::Exception::InvalidSamplingValue
48
- # @return [Nil]
49
- #
50
- def histograms(sampling = 0.01, filters = {}, options = {})
51
- wf_sampling_value?(sampling)
52
- api.get_stream('histograms',
53
- histograms_filter(sampling, filters),
54
- options)
55
- end
56
-
57
- # https://<cluster>.wavefront.com/api/spy/spans
58
- # Gets new spans with existing source names and span tags.
59
- # @param sampling [Float] see #points
60
- # @param filter [Hash] see #points
61
- # @param options [Hash] see #points
62
- # @raise Wavefront::Exception::InvalidSamplingValue
63
- # @return [Nil]
64
- #
65
- def spans(sampling = 0.01, filters = {}, options = {})
66
- wf_sampling_value?(sampling)
67
- api.get_stream('spans', spans_filter(sampling, filters), options)
68
- end
69
-
70
- # https://<cluster>.wavefront.com/api/spy/ids
71
- # Gets newly allocated IDs that correspond to new metric names, source
72
- # names, point tags, or span tags. A new ID generally indicates that a
73
- # new time series has been introduced.
74
- # @param sampling [Float] see #points
75
- # @param filter [Hash] with keys:
76
- # :prefix [String] only list assignments whose metric name begins with
77
- # this case-sensitive string
78
- # :type [String] one of METRIC, SPAN, HOST or STRING
79
- # @param options [Hash] see #points
80
- #
81
- def ids(sampling = 0.01, filters = {}, options = {})
82
- wf_sampling_value?(sampling)
83
- api.get_stream('ids', ids_filter(sampling, filters), options)
84
- end
85
-
86
- def api_path
87
- '/api/spy'
88
- end
89
-
90
- # We have to try to make the response we get from the API look
91
- # like the one we get from the public API. To begin with, it's
92
- # nothing like it.
93
- #
94
- # This method must be public because a #respond_to? looks for
95
- # it.
96
- #
97
- def _response_shim(resp, status)
98
- { response: parse_response(resp),
99
- status: { result: status == 200 ? 'OK' : 'ERROR',
100
- message: extract_api_message(status, resp),
101
- code: status } }.to_json
102
- end
103
-
104
- private
105
-
106
- def points_filter(sampling, filters)
107
- { metric: filters.fetch(:prefix, nil),
108
- host: filters.fetch(:host, nil),
109
- sampling: sampling,
110
- pointTagKey: filters.fetch(:tag_key, nil) }.compact
111
- end
112
-
113
- def histograms_filter(sampling, filters)
114
- { histogram: filters.fetch(:prefix, nil),
115
- host: filters.fetch(:host, nil),
116
- sampling: sampling,
117
- histogramTagKey: filters.fetch(:tag_key, nil) }.compact
118
- end
119
-
120
- def spans_filter(sampling, filters)
121
- { name: filters.fetch(:prefix, nil),
122
- host: filters.fetch(:host, nil),
123
- sampling: sampling,
124
- spanTagKey: filters.fetch(:tag_key, nil) }.compact
125
- end
126
-
127
- def ids_filter(sampling, filters)
128
- { name: filters.fetch(:prefix, nil),
129
- type: filters.fetch(:type, nil),
130
- sampling: sampling }.compact
131
- end
132
- end
133
- end
134
- end
@@ -1,55 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require_relative '../spec_helper'
5
- require_relative '../test_mixins/general'
6
- require_relative '../test_mixins/tag'
7
-
8
- # Unit tests for MonitoredCluster class
9
- #
10
- class WavefrontMonitoredClusterTest < WavefrontTestBase
11
- include WavefrontTest::Create
12
- include WavefrontTest::Delete
13
- include WavefrontTest::Describe
14
- include WavefrontTest::List
15
- include WavefrontTest::Update
16
- include WavefrontTest::Tag
17
-
18
- def test_merge
19
- assert_puts("/api/v2/monitoredcluster/merge/#{id}/#{id2}", nil, :json) do
20
- wf.merge(id, id2)
21
- end
22
-
23
- assert_invalid_id { wf.merge(id, invalid_id) }
24
- end
25
-
26
- private
27
-
28
- def api_class
29
- 'monitoredcluster'
30
- end
31
-
32
- def id
33
- 'k8s-sample'
34
- end
35
-
36
- def id2
37
- 'eks-cluster'
38
- end
39
-
40
- def invalid_id
41
- '!!!!'
42
- end
43
-
44
- def payload
45
- { id: 'k8s-sample',
46
- name: 'Sample cluster',
47
- platform: 'EKS',
48
- version: '1.2',
49
- additionalTags: {
50
- region: 'us-west-2',
51
- az: 'testing'
52
- },
53
- tags: %w[alertTag1] }
54
- end
55
- end