wavefront-sdk 1.4.0 → 1.5.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +5 -5
- data/HISTORY.md +64 -0
- data/README.md +1 -1
- data/lib/wavefront-sdk/alert.rb +1 -1
- data/lib/wavefront-sdk/base.rb +5 -5
- data/lib/wavefront-sdk/base_write.rb +2 -2
- data/lib/wavefront-sdk/cloudintegration.rb +1 -1
- data/lib/wavefront-sdk/dashboard.rb +9 -11
- data/lib/wavefront-sdk/derivedmetric.rb +162 -0
- data/lib/wavefront-sdk/event.rb +1 -1
- data/lib/wavefront-sdk/exception.rb +1 -0
- data/lib/wavefront-sdk/externallink.rb +1 -1
- data/lib/wavefront-sdk/integration.rb +1 -1
- data/lib/wavefront-sdk/maintenancewindow.rb +1 -1
- data/lib/wavefront-sdk/message.rb +1 -1
- data/lib/wavefront-sdk/metric.rb +1 -1
- data/lib/wavefront-sdk/mixins.rb +2 -2
- data/lib/wavefront-sdk/notificant.rb +1 -1
- data/lib/wavefront-sdk/proxy.rb +5 -5
- data/lib/wavefront-sdk/query.rb +1 -1
- data/lib/wavefront-sdk/response.rb +1 -1
- data/lib/wavefront-sdk/savedsearch.rb +1 -1
- data/lib/wavefront-sdk/search.rb +1 -1
- data/lib/wavefront-sdk/source.rb +1 -1
- data/lib/wavefront-sdk/user.rb +1 -1
- data/lib/wavefront-sdk/validators.rb +17 -2
- data/lib/wavefront-sdk/version.rb +1 -1
- data/lib/wavefront-sdk/webhook.rb +1 -1
- data/lib/wavefront-sdk/write.rb +1 -1
- data/spec/wavefront-sdk/derivedmetric_spec.rb +66 -0
- data/spec/wavefront-sdk/validators_spec.rb +8 -0
- metadata +7 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 778b77017e311667e540cdfc613ac815f1486946a7765cd6d6a02a8859c8808e
|
|
4
|
+
data.tar.gz: b56b31e97198d16f2b637170527aafc18366597ad58dce4186312681ce8cb4a1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8bd597ebef72aeb412b557d25585b247c8e09e18c6ed35b5d0296bffa640dcece36150f22449bbf47ee630fd104a8502b9d3c4d16e9f9e937c0c0c4a21349415
|
|
7
|
+
data.tar.gz: 38bd84a2693d9a61d3d16b4576990c0cbd7696f2b6499086d7e4725239bc5d949aac008f02ccc8603a5af95139e42fc7222be84a3df889cbedb300033c3e41ef
|
data/.travis.yml
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
language: ruby
|
|
2
2
|
cache: bundler
|
|
3
3
|
rvm:
|
|
4
|
-
- 2.2.
|
|
5
|
-
- 2.3.
|
|
6
|
-
- 2.4.
|
|
7
|
-
- 2.5.
|
|
4
|
+
- 2.2.10
|
|
5
|
+
- 2.3.7
|
|
6
|
+
- 2.4.4
|
|
7
|
+
- 2.5.1
|
|
8
8
|
before_install: gem install bundler --no-rdoc --no-ri
|
|
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.
|
|
17
|
+
ruby: 2.5.1
|
|
18
18
|
notifications:
|
|
19
19
|
email: false
|
|
20
20
|
slack:
|
data/HISTORY.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.5.0 (25/06/2018)
|
|
4
|
+
|
|
5
|
+
* Add [derived
|
|
6
|
+
metric](https://docs.wavefront.com/derived_metrics.html) support.
|
|
7
|
+
* Add this changelog.
|
|
8
|
+
|
|
9
|
+
## 1.4.0 (10/04/2018)
|
|
10
|
+
|
|
11
|
+
* Add support for [direct
|
|
12
|
+
ingestion](https://docs.wavefront.com/direct_ingestion.html).
|
|
13
|
+
|
|
14
|
+
## 1.3.2 (03/04/2018)
|
|
15
|
+
|
|
16
|
+
* Fix regression in write class.
|
|
17
|
+
|
|
18
|
+
## 1.3.1 (03/04/2018)
|
|
19
|
+
|
|
20
|
+
* Fix Ruby 2.2 support.
|
|
21
|
+
* Code tidy and linting improvements.
|
|
22
|
+
|
|
23
|
+
## 1.3.0 (29/03/2018)
|
|
24
|
+
|
|
25
|
+
* Add support for delta metrics.
|
|
26
|
+
* Add automatic pagination support for long lists of objects.
|
|
27
|
+
Such lists can be treated as Ruby enumerables.
|
|
28
|
+
* Assume Wavefront proxies are listening on port 2878, though you
|
|
29
|
+
can still override this.
|
|
30
|
+
* Improve test coverage.
|
|
31
|
+
* Update dependencies.
|
|
32
|
+
* Support Ruby 2.5.
|
|
33
|
+
|
|
34
|
+
## 1.2.1 (12/10/2017)
|
|
35
|
+
|
|
36
|
+
* Fix bug in relative time support.
|
|
37
|
+
* Fix Ruby 2.4 support.
|
|
38
|
+
|
|
39
|
+
## 1.2.0 (12/10/2017)
|
|
40
|
+
|
|
41
|
+
* Support relative times through mixin methods.
|
|
42
|
+
|
|
43
|
+
## 1.1.0 (09/10/2017)
|
|
44
|
+
|
|
45
|
+
* Add support for notificant (alert target) API path.
|
|
46
|
+
* Add support for integration API path.
|
|
47
|
+
* Support new source description set/delete API endpoint.
|
|
48
|
+
|
|
49
|
+
## 1.0.3 (20/09/2017)
|
|
50
|
+
|
|
51
|
+
* Gracefully handle tags with `nil` values.
|
|
52
|
+
* Bump dependencies.
|
|
53
|
+
|
|
54
|
+
## 1.0.2 (04/08/2017)
|
|
55
|
+
|
|
56
|
+
* Maintenance window bugfixes.
|
|
57
|
+
|
|
58
|
+
## 1.0.1 (31/07/2017)
|
|
59
|
+
|
|
60
|
+
* Fix message ID validator.
|
|
61
|
+
|
|
62
|
+
## 1.0.0 (11/06/2017)
|
|
63
|
+
|
|
64
|
+
First official release.
|
data/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# wavefront-sdk
|
|
2
|
-
[](https://travis-ci.org/snltd/wavefront-sdk) [](https://codeclimate.com/github/snltd/wavefront-sdk) [](https://codeclimate.com/github/snltd/wavefront-sdk) [](https://travis-ci.org/snltd/wavefront-sdk) [](https://codeclimate.com/github/snltd/wavefront-sdk) [](https://codeclimate.com/github/snltd/wavefront-sdk) [](https://badge.fury.io/rb/wavefront-sdk) 
|
|
3
3
|
|
|
4
4
|
This is a Ruby SDK for v2 of
|
|
5
5
|
[Wavefront](https://www.wavefront.com/)'s public API. It supports
|
data/lib/wavefront-sdk/alert.rb
CHANGED
data/lib/wavefront-sdk/base.rb
CHANGED
|
@@ -4,11 +4,11 @@ require 'faraday'
|
|
|
4
4
|
require 'pp'
|
|
5
5
|
require 'ostruct'
|
|
6
6
|
require 'addressable'
|
|
7
|
-
require_relative '
|
|
8
|
-
require_relative '
|
|
9
|
-
require_relative '
|
|
10
|
-
require_relative '
|
|
11
|
-
require_relative '
|
|
7
|
+
require_relative 'exception'
|
|
8
|
+
require_relative 'mixins'
|
|
9
|
+
require_relative 'response'
|
|
10
|
+
require_relative 'validators'
|
|
11
|
+
require_relative 'version'
|
|
12
12
|
|
|
13
13
|
module Wavefront
|
|
14
14
|
#
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require_relative '
|
|
1
|
+
require_relative 'base'
|
|
2
2
|
|
|
3
3
|
module Wavefront
|
|
4
4
|
#
|
|
@@ -13,7 +13,7 @@ module Wavefront
|
|
|
13
13
|
# Get all dashboards for a customer.
|
|
14
14
|
#
|
|
15
15
|
# @param offset [Int] dashboard at which the list begins
|
|
16
|
-
# @param limit [Int] the number of
|
|
16
|
+
# @param limit [Int] the number of dashboards to return
|
|
17
17
|
# @return [Wavefront::Response]
|
|
18
18
|
#
|
|
19
19
|
def list(offset = 0, limit = 100)
|
|
@@ -34,9 +34,9 @@ module Wavefront
|
|
|
34
34
|
|
|
35
35
|
# DELETE /api/v2/dashboard/id
|
|
36
36
|
# Delete a specific dashboard.
|
|
37
|
-
# Deleting an active dashboard moves it to 'trash', from where
|
|
38
|
-
# be restored with an #undelete operation. Deleting
|
|
39
|
-
# 'trash' removes it for ever.
|
|
37
|
+
# Deleting an active dashboard moves it to 'trash', from where
|
|
38
|
+
# it can be restored with an #undelete operation. Deleting a
|
|
39
|
+
# dashboard in 'trash' removes it for ever.
|
|
40
40
|
#
|
|
41
41
|
# @param id [String] ID of the dashboard
|
|
42
42
|
# @return [Wavefront::Response]
|
|
@@ -47,8 +47,8 @@ module Wavefront
|
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
# GET /api/v2/dashboard/id
|
|
50
|
-
# Get a specific dashboard / Get a specific historical version
|
|
51
|
-
# specific dashboard.
|
|
50
|
+
# Get a specific dashboard / Get a specific historical version
|
|
51
|
+
# of a specific dashboard.
|
|
52
52
|
#
|
|
53
53
|
# @param id [String] ID of the dashboard
|
|
54
54
|
# @param version [Integer] version of dashboard
|
|
@@ -84,7 +84,7 @@ module Wavefront
|
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
# GET /api/v2/dashboard/id/history
|
|
87
|
-
# Get the version history of
|
|
87
|
+
# Get the version history of a dashboard.
|
|
88
88
|
#
|
|
89
89
|
# @param id [String] ID of the dashboard
|
|
90
90
|
# @return [Wavefront::Response]
|
|
@@ -99,7 +99,6 @@ module Wavefront
|
|
|
99
99
|
#
|
|
100
100
|
# @param id [String] ID of the dashboard
|
|
101
101
|
# @return [Wavefront::Response]
|
|
102
|
-
# response keys
|
|
103
102
|
#
|
|
104
103
|
def tags(id)
|
|
105
104
|
wf_dashboard_id?(id)
|
|
@@ -112,7 +111,6 @@ module Wavefront
|
|
|
112
111
|
# @param id [String] ID of the dashboard
|
|
113
112
|
# @param tags [Array] list of tags to set.
|
|
114
113
|
# @return [Wavefront::Response]
|
|
115
|
-
# response keys
|
|
116
114
|
#
|
|
117
115
|
def tag_set(id, tags)
|
|
118
116
|
wf_dashboard_id?(id)
|
|
@@ -148,7 +146,7 @@ module Wavefront
|
|
|
148
146
|
end
|
|
149
147
|
|
|
150
148
|
# POST /api/v2/dashboard/id/undelete
|
|
151
|
-
# Move
|
|
149
|
+
# Move a dashboard from 'trash' back into active service.
|
|
152
150
|
#
|
|
153
151
|
# @param id [String] ID of the dashboard
|
|
154
152
|
# @return [Wavefront::Response]
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
require_relative 'base'
|
|
2
|
+
|
|
3
|
+
module Wavefront
|
|
4
|
+
#
|
|
5
|
+
# View and manage derived metrics
|
|
6
|
+
#
|
|
7
|
+
class DerivedMetric < Base
|
|
8
|
+
def update_keys
|
|
9
|
+
# %i[id name url description sections]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# GET /api/v2/derivedmetric
|
|
13
|
+
# Get all derived metric definitions for a customer.
|
|
14
|
+
#
|
|
15
|
+
# @param offset [Int] derived metric at which the list begins
|
|
16
|
+
# @param limit [Int] the number of derived metrics to return
|
|
17
|
+
# @return [Wavefront::Response]
|
|
18
|
+
#
|
|
19
|
+
def list(offset = 0, limit = 100)
|
|
20
|
+
api_get('', offset: offset, limit: limit)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# POST /api/v2/derivedmetric
|
|
24
|
+
# Create a specific derived metric definition.
|
|
25
|
+
# Refer to the Swagger API docs for valid keys.
|
|
26
|
+
#
|
|
27
|
+
# @param body [Hash] description of derived metric
|
|
28
|
+
# @return [Wavefront::Response]
|
|
29
|
+
#
|
|
30
|
+
def create(body)
|
|
31
|
+
raise ArgumentError unless body.is_a?(Hash)
|
|
32
|
+
api_post('', body, 'application/json')
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# DELETE /api/v2/derivedmetric/id
|
|
36
|
+
# Delete a specific derived metric definition.
|
|
37
|
+
# Deleting an active derived metric moves it to 'trash', from
|
|
38
|
+
# where it can be restored with an #undelete operation. Deleting
|
|
39
|
+
# a derived metric in 'trash' removes it for ever.
|
|
40
|
+
#
|
|
41
|
+
# @param id [String] ID of the derived metric
|
|
42
|
+
# @return [Wavefront::Response]
|
|
43
|
+
#
|
|
44
|
+
def delete(id)
|
|
45
|
+
wf_derivedmetric_id?(id)
|
|
46
|
+
api_delete(id)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# GET /api/v2/derivedmetric/id
|
|
50
|
+
# Get a specific derived metric definition / Get a specific
|
|
51
|
+
# historical version of a specific derived metric definition.
|
|
52
|
+
#
|
|
53
|
+
# @param id [String] ID of the derived metric
|
|
54
|
+
# @param version [Integer] version of derived metric
|
|
55
|
+
# @return [Wavefront::Response]
|
|
56
|
+
#
|
|
57
|
+
def describe(id, version = nil)
|
|
58
|
+
wf_derivedmetric_id?(id)
|
|
59
|
+
wf_version?(version) if version
|
|
60
|
+
fragments = [id]
|
|
61
|
+
fragments += ['history', version] if version
|
|
62
|
+
api_get(fragments.uri_concat)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# PUT /api/v2/derivedmetric/id
|
|
66
|
+
# Update a specific derived metric definition.
|
|
67
|
+
#
|
|
68
|
+
# @param id [String] a Wavefront alert ID
|
|
69
|
+
# @param body [Hash] key-value hash of the parameters you wish
|
|
70
|
+
# to change
|
|
71
|
+
# @param modify [true, false] if true, use {#describe()} to get
|
|
72
|
+
# a hash describing the existing object, and modify that with
|
|
73
|
+
# the new body. If false, pass the new body straight through.
|
|
74
|
+
# @return [Wavefront::Response]
|
|
75
|
+
|
|
76
|
+
def update(id, body, modify = true)
|
|
77
|
+
wf_derivedmetric_id?(id)
|
|
78
|
+
raise ArgumentError unless body.is_a?(Hash)
|
|
79
|
+
|
|
80
|
+
return api_put(id, body, 'application/json') unless modify
|
|
81
|
+
|
|
82
|
+
api_put(id, hash_for_update(describe(id).response, body),
|
|
83
|
+
'application/json')
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# GET /api/v2/derivedmetric/id/history
|
|
87
|
+
# Get the version history of a derived metric definition.
|
|
88
|
+
#
|
|
89
|
+
# @param id [String] ID of the derived metric
|
|
90
|
+
# @return [Wavefront::Response]
|
|
91
|
+
#
|
|
92
|
+
def history(id)
|
|
93
|
+
wf_derivedmetric_id?(id)
|
|
94
|
+
api_get([id, 'history'].uri_concat)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# GET /api/v2/derivedmetric/id/tag
|
|
98
|
+
# Get all tags associated with a specific derived metric
|
|
99
|
+
# definition.
|
|
100
|
+
#
|
|
101
|
+
# @param id [String] ID of the derived metric
|
|
102
|
+
# @return [Wavefront::Response]
|
|
103
|
+
#
|
|
104
|
+
def tags(id)
|
|
105
|
+
wf_derivedmetric_id?(id)
|
|
106
|
+
api_get([id, 'tag'].uri_concat)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# POST /api/v2/derivedmetric/id/tag
|
|
110
|
+
# Set all tags associated with a specific derived metric
|
|
111
|
+
# definition.
|
|
112
|
+
#
|
|
113
|
+
# @param id [String] ID of the derived metric
|
|
114
|
+
# @param tags [Array] list of tags to set.
|
|
115
|
+
# @return [Wavefront::Response]
|
|
116
|
+
#
|
|
117
|
+
def tag_set(id, tags)
|
|
118
|
+
wf_derivedmetric_id?(id)
|
|
119
|
+
tags = Array(tags)
|
|
120
|
+
tags.each { |t| wf_string?(t) }
|
|
121
|
+
api_post([id, 'tag'].uri_concat, tags.to_json, 'application/json')
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# DELETE /api/v2/derivedmetric/id/tag/tagValue
|
|
125
|
+
# Remove a tag from a specific derived metric definition.
|
|
126
|
+
#
|
|
127
|
+
# @param id [String] ID of the derived metric
|
|
128
|
+
# @param tag [String] tag to delete
|
|
129
|
+
# @return [Wavefront::Response]
|
|
130
|
+
#
|
|
131
|
+
def tag_delete(id, tag)
|
|
132
|
+
wf_derivedmetric_id?(id)
|
|
133
|
+
wf_string?(tag)
|
|
134
|
+
api_delete([id, 'tag', tag].uri_concat)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# PUT /api/v2/derivedmetric/id/tag/tagValue
|
|
138
|
+
# Add a tag to a specific derived metric definition.
|
|
139
|
+
#
|
|
140
|
+
# @param id [String] ID of the derived metric
|
|
141
|
+
# @param tag [String] tag to set.
|
|
142
|
+
# @return [Wavefront::Response]
|
|
143
|
+
#
|
|
144
|
+
def tag_add(id, tag)
|
|
145
|
+
wf_derivedmetric_id?(id)
|
|
146
|
+
wf_string?(tag)
|
|
147
|
+
api_put([id, 'tag', tag].uri_concat)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# POST /api/v2/derivedmetric/id/undelete
|
|
151
|
+
# Move a derived metric definition from 'trash' back into active
|
|
152
|
+
# service.
|
|
153
|
+
#
|
|
154
|
+
# @param id [String] ID of the derived metric
|
|
155
|
+
# @return [Wavefront::Response]
|
|
156
|
+
#
|
|
157
|
+
def undelete(id)
|
|
158
|
+
wf_derivedmetric_id?(id)
|
|
159
|
+
api_post([id, 'undelete'].uri_concat)
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
data/lib/wavefront-sdk/event.rb
CHANGED
|
@@ -8,6 +8,7 @@ module Wavefront
|
|
|
8
8
|
class InvalidAlertSeverity < RuntimeError; end
|
|
9
9
|
class InvalidCloudIntegrationId < RuntimeError; end
|
|
10
10
|
class InvalidDashboardId < RuntimeError; end
|
|
11
|
+
class InvalidDerivedMetricId < RuntimeError; end
|
|
11
12
|
class InvalidEndpoint < RuntimeError; end
|
|
12
13
|
class InvalidEventId < RuntimeError; end
|
|
13
14
|
class InvalidExternalLinkId < RuntimeError; end
|
data/lib/wavefront-sdk/metric.rb
CHANGED
data/lib/wavefront-sdk/mixins.rb
CHANGED
data/lib/wavefront-sdk/proxy.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require_relative '
|
|
1
|
+
require_relative 'base'
|
|
2
2
|
|
|
3
3
|
module Wavefront
|
|
4
4
|
#
|
|
@@ -19,7 +19,7 @@ module Wavefront
|
|
|
19
19
|
# Delete a specific proxy
|
|
20
20
|
#
|
|
21
21
|
# Deleting an active proxy moves it to 'trash', from where it
|
|
22
|
-
# can be restored with an #undelete operation. Deleting
|
|
22
|
+
# can be restored with an #undelete operation. Deleting a proxy
|
|
23
23
|
# in 'trash' removes it for ever.
|
|
24
24
|
#
|
|
25
25
|
# @param id [String] ID of the proxy
|
|
@@ -44,7 +44,7 @@ module Wavefront
|
|
|
44
44
|
# POST /api/v2/proxy/id/undelete
|
|
45
45
|
# Undelete a specific proxy
|
|
46
46
|
#
|
|
47
|
-
# Move
|
|
47
|
+
# Move a proxy from 'trash' back into active service.
|
|
48
48
|
#
|
|
49
49
|
# @param id [String] ID of the proxy
|
|
50
50
|
# @return [Wavefront::Response]
|
|
@@ -57,7 +57,7 @@ module Wavefront
|
|
|
57
57
|
# PUT /api/v2/proxy/id
|
|
58
58
|
# Update the name of a specific proxy
|
|
59
59
|
#
|
|
60
|
-
# Rename
|
|
60
|
+
# Rename a proxy. This changes the human-readable name, not the
|
|
61
61
|
# unique identifier.
|
|
62
62
|
#
|
|
63
63
|
# @param id [String] ID of the proxy
|
|
@@ -70,7 +70,7 @@ module Wavefront
|
|
|
70
70
|
update(id, name: name)
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
# A generic function to change properties of
|
|
73
|
+
# A generic function to change properties of a proxy. So far as I
|
|
74
74
|
# know, only the 'name' property can currently be changed, and we
|
|
75
75
|
# supply a dedicated #rename method for that.
|
|
76
76
|
#
|
data/lib/wavefront-sdk/query.rb
CHANGED
data/lib/wavefront-sdk/search.rb
CHANGED
data/lib/wavefront-sdk/source.rb
CHANGED
data/lib/wavefront-sdk/user.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# rubocop:disable Naming/UncommunicativeMethodParamName
|
|
2
|
-
require_relative '
|
|
3
|
-
require_relative '
|
|
2
|
+
require_relative 'constants'
|
|
3
|
+
require_relative 'exception'
|
|
4
4
|
|
|
5
5
|
module Wavefront
|
|
6
6
|
#
|
|
@@ -243,6 +243,21 @@ module Wavefront
|
|
|
243
243
|
raise Wavefront::Exception::InvalidDashboardId
|
|
244
244
|
end
|
|
245
245
|
|
|
246
|
+
# Ensure the given argument is a valid derived metric ID. IDs
|
|
247
|
+
# are the millisecond epoch timestamp at which the derived
|
|
248
|
+
# metric was created.
|
|
249
|
+
#
|
|
250
|
+
# @param v [String, Integer]
|
|
251
|
+
# @return True if the ID is valid
|
|
252
|
+
# @raise Wavefront::Exception::InvalidDerivedMetricId
|
|
253
|
+
#
|
|
254
|
+
def wf_derivedmetric_id?(v)
|
|
255
|
+
v = v.to_s if v.is_a?(Numeric)
|
|
256
|
+
return true if v.is_a?(String) && v =~ /^\d{13}$/
|
|
257
|
+
|
|
258
|
+
raise Wavefront::Exception::InvalidDerivedMetricId
|
|
259
|
+
end
|
|
260
|
+
|
|
246
261
|
# Ensure the given argument is a valid event ID. Event IDs are
|
|
247
262
|
# an epoch-millisecond timestamp followed by a : followed by the
|
|
248
263
|
# name of the event.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
WF_SDK_VERSION = '1.
|
|
1
|
+
WF_SDK_VERSION = '1.5.0'.freeze
|
data/lib/wavefront-sdk/write.rb
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require_relative '../spec_helper'
|
|
4
|
+
|
|
5
|
+
DERIVED_METRIC = '1529926075038'.freeze
|
|
6
|
+
DERIVED_METRIC_BODY = {
|
|
7
|
+
minutes: 5,
|
|
8
|
+
name: 'test_1',
|
|
9
|
+
query: 'aliasMetric(ts("test.metric"), "derived.test_1")',
|
|
10
|
+
tags: { customerTags: ['test'] },
|
|
11
|
+
includeObsoleteMetrics: false,
|
|
12
|
+
processRateMinutes: 1
|
|
13
|
+
}.freeze
|
|
14
|
+
|
|
15
|
+
# Unit tests for dashboard class
|
|
16
|
+
#
|
|
17
|
+
class WavefrontDerivedMetricTest < WavefrontTestBase
|
|
18
|
+
def test_list
|
|
19
|
+
should_work(:list, 10, '?offset=10&limit=100')
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_create
|
|
23
|
+
should_work(:create, DERIVED_METRIC_BODY, '', :post,
|
|
24
|
+
JSON_POST_HEADERS, DERIVED_METRIC_BODY.to_json)
|
|
25
|
+
assert_raises(ArgumentError) { wf.create }
|
|
26
|
+
assert_raises(ArgumentError) { wf.create('test') }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_describe
|
|
30
|
+
should_work(:describe, DERIVED_METRIC, DERIVED_METRIC)
|
|
31
|
+
assert_raises(ArgumentError) { wf.describe }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_describe_v
|
|
35
|
+
should_work(:describe, [DERIVED_METRIC, 4], "#{DERIVED_METRIC}/history/4")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_delete
|
|
39
|
+
should_work(:delete, DERIVED_METRIC, DERIVED_METRIC, :delete)
|
|
40
|
+
should_be_invalid(:delete)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_history
|
|
44
|
+
should_work(:history, DERIVED_METRIC, "#{DERIVED_METRIC}/history")
|
|
45
|
+
should_be_invalid(:history)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_update
|
|
49
|
+
should_work(:update, [DERIVED_METRIC, DERIVED_METRIC_BODY, false],
|
|
50
|
+
DERIVED_METRIC, :put, JSON_POST_HEADERS,
|
|
51
|
+
DERIVED_METRIC_BODY.to_json)
|
|
52
|
+
should_be_invalid(:update, ['!invalid derived metric!',
|
|
53
|
+
DERIVED_METRIC_BODY])
|
|
54
|
+
assert_raises(ArgumentError) { wf.update }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_tags
|
|
58
|
+
tag_tester(DERIVED_METRIC)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_undelete
|
|
62
|
+
should_work(:undelete, DERIVED_METRIC, ["#{DERIVED_METRIC}/undelete",
|
|
63
|
+
nil], :post, POST_HEADERS)
|
|
64
|
+
should_be_invalid(:undelete)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -141,6 +141,14 @@ class WavefrontValidatorsTest < MiniTest::Test
|
|
|
141
141
|
good_and_bad('wf_version?', 'InvalidVersion', good, bad)
|
|
142
142
|
end
|
|
143
143
|
|
|
144
|
+
def test_wf_derivedmetric_id?
|
|
145
|
+
good = %w[1529926075038 1529936045036]
|
|
146
|
+
bad = %w[metricid 152992607503 15299260750384 lq%rPlSg2CFMSrg6
|
|
147
|
+
lq6rPlSg2CFMSrg]
|
|
148
|
+
good_and_bad('wf_derivedmetric_id?', 'InvalidDerivedMetricId',
|
|
149
|
+
good, bad)
|
|
150
|
+
end
|
|
151
|
+
|
|
144
152
|
def test_wf_link_id?
|
|
145
153
|
good = %w[lq6rPlSg2CFMSrg6]
|
|
146
154
|
bad = %w[lq%rPlSg2CFMSrg6 lq6rPlSg2CFMSrg]
|
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: 1.
|
|
4
|
+
version: 1.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Robert Fisher
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-06-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|
|
@@ -189,6 +189,7 @@ files:
|
|
|
189
189
|
- ".rubocop.yml"
|
|
190
190
|
- ".travis.yml"
|
|
191
191
|
- Gemfile
|
|
192
|
+
- HISTORY.md
|
|
192
193
|
- LICENSE.txt
|
|
193
194
|
- README.md
|
|
194
195
|
- Rakefile
|
|
@@ -199,6 +200,7 @@ files:
|
|
|
199
200
|
- lib/wavefront-sdk/constants.rb
|
|
200
201
|
- lib/wavefront-sdk/credentials.rb
|
|
201
202
|
- lib/wavefront-sdk/dashboard.rb
|
|
203
|
+
- lib/wavefront-sdk/derivedmetric.rb
|
|
202
204
|
- lib/wavefront-sdk/event.rb
|
|
203
205
|
- lib/wavefront-sdk/exception.rb
|
|
204
206
|
- lib/wavefront-sdk/externallink.rb
|
|
@@ -229,6 +231,7 @@ files:
|
|
|
229
231
|
- spec/wavefront-sdk/cloudintegration_spec.rb
|
|
230
232
|
- spec/wavefront-sdk/credentials_spec.rb
|
|
231
233
|
- spec/wavefront-sdk/dashboard_spec.rb
|
|
234
|
+
- spec/wavefront-sdk/derivedmetric_spec.rb
|
|
232
235
|
- spec/wavefront-sdk/event_spec.rb
|
|
233
236
|
- spec/wavefront-sdk/externallink_spec.rb
|
|
234
237
|
- spec/wavefront-sdk/integration_spec.rb
|
|
@@ -272,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
272
275
|
version: '0'
|
|
273
276
|
requirements: []
|
|
274
277
|
rubyforge_project:
|
|
275
|
-
rubygems_version: 2.7.
|
|
278
|
+
rubygems_version: 2.7.7
|
|
276
279
|
signing_key:
|
|
277
280
|
specification_version: 4
|
|
278
281
|
summary: SDK for Wavefront API v2
|
|
@@ -284,6 +287,7 @@ test_files:
|
|
|
284
287
|
- spec/wavefront-sdk/cloudintegration_spec.rb
|
|
285
288
|
- spec/wavefront-sdk/credentials_spec.rb
|
|
286
289
|
- spec/wavefront-sdk/dashboard_spec.rb
|
|
290
|
+
- spec/wavefront-sdk/derivedmetric_spec.rb
|
|
287
291
|
- spec/wavefront-sdk/event_spec.rb
|
|
288
292
|
- spec/wavefront-sdk/externallink_spec.rb
|
|
289
293
|
- spec/wavefront-sdk/integration_spec.rb
|