wavefront-sdk 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +10 -10
- data/lib/wavefront-sdk/alert.rb +36 -24
- data/lib/wavefront-sdk/event.rb +3 -1
- data/lib/wavefront-sdk/response.rb +1 -1
- data/lib/wavefront-sdk/version.rb +1 -1
- data/spec/wavefront-sdk/alert_spec.rb +2 -2
- data/spec/wavefront-sdk/event_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f37a97bd03c5522bb5dbbfcb25e13645ae724d60
|
4
|
+
data.tar.gz: 1649e2709f06702ef3dc459157dfbe67c920eb01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9af27034b0984bbb7f3eb02d5ef254c8a57a497bddc6dc8d6585795b8c49e8009dfce6839cb9b6c45baf6d9ba113bed2b895d047aef3bca45065ae62375464ab
|
7
|
+
data.tar.gz: 6189ac5bc2267c07050940ce83ca5f77c89a0c6ce20f6476d0dbe2817f84223c17b8a8e4d89fae35dc0106bef39025417dd3700953b8637c7265d8f93ddbf7bf
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -15,7 +15,7 @@ $ gem install wavefront-sdk
|
|
15
15
|
|
16
16
|
or to build locally,
|
17
17
|
|
18
|
-
|
18
|
+
```
|
19
19
|
$ gem build wavefront-sdk.gemspec
|
20
20
|
```
|
21
21
|
|
@@ -27,16 +27,16 @@ rubydoc.info](http://www.rubydoc.info/gems/wavefront-sdk/).
|
|
27
27
|
|
28
28
|
## Examples
|
29
29
|
|
30
|
-
First, let's list the IDs of the users in our account. The `list()`
|
31
|
-
will return a `Wavefront::Response` object. This object has
|
32
|
-
`status` and `response` methods. `status` always yields a
|
33
|
-
|
34
|
-
|
30
|
+
First, let's list the IDs of the users in our account. The `list()`
|
31
|
+
method will return a `Wavefront::Response` object. This object has
|
32
|
+
`status` and `response` methods. `status` always yields a structure
|
33
|
+
containing `result`, `message` and `code` fields which can be
|
34
|
+
inspected to ensure an API call was processed successfully.
|
35
35
|
`response` gives you a the JSON response from the API, conveniently
|
36
|
-
processed and turned into a
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
processed and turned into a [`Map`](https://github.com/ahoward/map)
|
37
|
+
object. Map objects can be interrogated in various ways. For
|
38
|
+
instance `map['items']`, `map[:items]` and `map.items` will all get
|
39
|
+
you to the same place.
|
40
40
|
|
41
41
|
|
42
42
|
```ruby
|
data/lib/wavefront-sdk/alert.rb
CHANGED
@@ -6,6 +6,10 @@ module Wavefront
|
|
6
6
|
# epoch timestamp. Returns a Wavefront::Response::Alert object.
|
7
7
|
#
|
8
8
|
class Alert < Base
|
9
|
+
def update_keys
|
10
|
+
%i(id name target condition displayExpression minutes
|
11
|
+
resolveAfterMinutes severity additionalInformation)
|
12
|
+
end
|
9
13
|
|
10
14
|
# GET /api/v2/alert
|
11
15
|
# Get all alerts for a customer
|
@@ -24,7 +28,7 @@ module Wavefront
|
|
24
28
|
# generic POST of a hash.
|
25
29
|
#
|
26
30
|
# @param body [Hash] description of alert
|
27
|
-
# @return [
|
31
|
+
# @return [Wavefront::Response]
|
28
32
|
#
|
29
33
|
def create(body)
|
30
34
|
raise ArgumentError unless body.is_a?(Hash)
|
@@ -39,7 +43,7 @@ module Wavefront
|
|
39
43
|
# 'trash' removes it for ever.
|
40
44
|
#
|
41
45
|
# @param id [String] ID of the alert
|
42
|
-
# @return [
|
46
|
+
# @return [Wavefront::Response]
|
43
47
|
#
|
44
48
|
def delete(id)
|
45
49
|
wf_alert_id?(id)
|
@@ -53,7 +57,7 @@ module Wavefront
|
|
53
57
|
#
|
54
58
|
# @param id [String] ID of the alert
|
55
59
|
# @param version [Integer] version of alert
|
56
|
-
# @return [
|
60
|
+
# @return [Wavefront::Response]
|
57
61
|
#
|
58
62
|
def describe(id, version = nil)
|
59
63
|
wf_alert_id?(id)
|
@@ -67,24 +71,36 @@ module Wavefront
|
|
67
71
|
# Update a specific alert.
|
68
72
|
#
|
69
73
|
# @param id [String] a Wavefront alert ID
|
70
|
-
# @param body [Hash]
|
71
|
-
#
|
72
|
-
#
|
73
|
-
|
74
|
+
# @param body [Hash] key-value hash of the parameters you wish
|
75
|
+
# to change
|
76
|
+
# @param modify [true, false] if true, use {#describe()} to get
|
77
|
+
# a hash describing the existing object, and modify that with
|
78
|
+
# the new body. If false, pass the new body straight through.
|
79
|
+
# @return [Wavefront::Response]
|
80
|
+
|
81
|
+
def update(id, body, modify = true)
|
74
82
|
wf_alert_id?(id)
|
75
83
|
raise ArgumentError unless body.is_a?(Hash)
|
76
|
-
|
84
|
+
|
85
|
+
return api_put(id, body, 'application/json') unless modify
|
86
|
+
|
87
|
+
api_put(id, hash_for_update(describe(id).response, body),
|
88
|
+
'application/json')
|
77
89
|
end
|
78
90
|
|
79
91
|
# GET /api/v2/alert/id/history
|
80
92
|
# Get the version history of a specific alert.
|
81
93
|
#
|
82
94
|
# @param id [String] ID of the alert
|
83
|
-
# @return [
|
95
|
+
# @return [Wavefront::Response]
|
84
96
|
#
|
85
|
-
def history(id)
|
97
|
+
def history(id, offset = nil, limit = nil)
|
86
98
|
wf_alert_id?(id)
|
87
|
-
|
99
|
+
qs = {}
|
100
|
+
qs[:offset] = offset if offset
|
101
|
+
qs[:limit] = limit if limit
|
102
|
+
|
103
|
+
api_get([id, 'history'].uri_concat, qs)
|
88
104
|
end
|
89
105
|
|
90
106
|
# POST /api/v2/alert/id/snooze
|
@@ -92,9 +108,8 @@ module Wavefront
|
|
92
108
|
#
|
93
109
|
# @param id [String] ID of the alert
|
94
110
|
# @param seconds [Integer] how many seconds to snooze for.
|
95
|
-
# Nil is indefinite
|
96
|
-
# @return [
|
97
|
-
# response keys
|
111
|
+
# Nil is indefinite.
|
112
|
+
# @return [Wavefront::Response]
|
98
113
|
#
|
99
114
|
def snooze(id, seconds = nil)
|
100
115
|
wf_alert_id?(id)
|
@@ -106,8 +121,7 @@ module Wavefront
|
|
106
121
|
# Get all tags associated with a specific alert.
|
107
122
|
#
|
108
123
|
# @param id [String] ID of the alert
|
109
|
-
# @return [
|
110
|
-
# response keys
|
124
|
+
# @return [Wavefront::Response]
|
111
125
|
#
|
112
126
|
def tags(id)
|
113
127
|
wf_alert_id?(id)
|
@@ -119,8 +133,7 @@ module Wavefront
|
|
119
133
|
#
|
120
134
|
# @param id [String] ID of the alert
|
121
135
|
# @param tags [Array] list of tags to set.
|
122
|
-
# @return [
|
123
|
-
# response keys
|
136
|
+
# @return [Wavefront::Response]
|
124
137
|
#
|
125
138
|
def tag_set(id, tags)
|
126
139
|
wf_alert_id?(id)
|
@@ -134,7 +147,7 @@ module Wavefront
|
|
134
147
|
#
|
135
148
|
# @param id [String] ID of the alert
|
136
149
|
# @param tag [String] tag to delete
|
137
|
-
# @return [
|
150
|
+
# @return [Wavefront::Response]
|
138
151
|
#
|
139
152
|
def tag_delete(id, tag)
|
140
153
|
wf_alert_id?(id)
|
@@ -147,7 +160,7 @@ module Wavefront
|
|
147
160
|
#
|
148
161
|
# @param id [String] ID of the alert
|
149
162
|
# @param tag [String] tag to set.
|
150
|
-
# @return [
|
163
|
+
# @return [Wavefront::Response]
|
151
164
|
#
|
152
165
|
def tag_add(id, tag)
|
153
166
|
wf_alert_id?(id)
|
@@ -159,7 +172,7 @@ module Wavefront
|
|
159
172
|
# Undelete a specific alert.
|
160
173
|
#
|
161
174
|
# @param id [String] ID of the alert
|
162
|
-
# @return [
|
175
|
+
# @return [Wavefront::Response]
|
163
176
|
#
|
164
177
|
def undelete(id)
|
165
178
|
wf_alert_id?(id)
|
@@ -170,8 +183,7 @@ module Wavefront
|
|
170
183
|
# Unsnooze a specific alert.
|
171
184
|
#
|
172
185
|
# @param id [String] ID of the alert
|
173
|
-
# @return [
|
174
|
-
# response keys
|
186
|
+
# @return [Wavefront::Response]
|
175
187
|
#
|
176
188
|
def unsnooze(id)
|
177
189
|
wf_alert_id?(id)
|
@@ -181,7 +193,7 @@ module Wavefront
|
|
181
193
|
# GET /api/v2/alert/summary
|
182
194
|
# Count alerts of various statuses for a customer
|
183
195
|
#
|
184
|
-
# @return [
|
196
|
+
# @return [Wavefront::Response]
|
185
197
|
#
|
186
198
|
def summary
|
187
199
|
api_get('summary')
|
data/lib/wavefront-sdk/event.rb
CHANGED
@@ -6,7 +6,9 @@ module Wavefront
|
|
6
6
|
# epoch timestamp.
|
7
7
|
#
|
8
8
|
class Event < Base
|
9
|
-
|
9
|
+
def update_keys
|
10
|
+
%i(startTime endTime name annotations)
|
11
|
+
end
|
10
12
|
|
11
13
|
# GET /api/v2/event
|
12
14
|
# List all the events for a customer within a time range.
|
@@ -1 +1 @@
|
|
1
|
-
WF_SDK_VERSION = '0.1.
|
1
|
+
WF_SDK_VERSION = '0.1.3'.freeze
|
@@ -55,8 +55,8 @@ class WavefrontAlertTest < WavefrontTestBase
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def test_update
|
58
|
-
should_work(:update, [ALERT, ALERT_BODY], ALERT, :put,
|
59
|
-
JSON_POST_HEADERS, ALERT_BODY
|
58
|
+
should_work(:update, [ALERT, ALERT_BODY, false], ALERT, :put,
|
59
|
+
JSON_POST_HEADERS, ALERT_BODY)
|
60
60
|
should_be_invalid(:update, ['abcde', ALERT_BODY])
|
61
61
|
assert_raises(ArgumentError) { wf.update }
|
62
62
|
end
|
@@ -67,8 +67,8 @@ class WavefrontEventTest < WavefrontTestBase
|
|
67
67
|
def test_update
|
68
68
|
should_work(:update, [EVENT, EVENT_BODY, false], EVENT, :put,
|
69
69
|
JSON_POST_HEADERS, EVENT_BODY.to_json)
|
70
|
-
|
71
|
-
|
70
|
+
should_be_invalid(:update, ['abcde', EVENT_BODY])
|
71
|
+
assert_raises(ArgumentError) { wf.update }
|
72
72
|
end
|
73
73
|
|
74
74
|
def test_delete
|
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: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Fisher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|