wavefront-sdk 0.1.3 → 0.1.5
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/lib/wavefront-sdk/cloudintegration.rb +6 -6
- data/lib/wavefront-sdk/dashboard.rb +28 -17
- data/lib/wavefront-sdk/event.rb +9 -9
- data/lib/wavefront-sdk/externallink.rb +21 -10
- data/lib/wavefront-sdk/maintenancewindow.rb +21 -9
- data/lib/wavefront-sdk/proxy.rb +5 -5
- data/lib/wavefront-sdk/query.rb +12 -1
- data/lib/wavefront-sdk/response.rb +22 -3
- data/lib/wavefront-sdk/savedsearch.rb +6 -6
- data/lib/wavefront-sdk/source.rb +25 -17
- data/lib/wavefront-sdk/user.rb +5 -5
- data/lib/wavefront-sdk/version.rb +1 -1
- data/lib/wavefront-sdk/webhook.rb +20 -9
- data/lib/wavefront-sdk/write.rb +0 -21
- data/spec/wavefront-sdk/dashboard_spec.rb +3 -2
- data/spec/wavefront-sdk/externallink_spec.rb +2 -2
- data/spec/wavefront-sdk/maintenancewindow_spec.rb +1 -1
- data/spec/wavefront-sdk/response_spec.rb +0 -18
- data/spec/wavefront-sdk/source_spec.rb +1 -1
- data/spec/wavefront-sdk/webhook_spec.rb +1 -1
- 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: d40567787f9b9712aec60c01fc49a6efb30d31ae
|
4
|
+
data.tar.gz: db8147e94b8589d1bd06aed17b6624b19729c3a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdb83339828a884226d9df89c3376245aebf8d68c2f2cdc3cafb07a73d2cf12ecba6c5faf2bbdc793f11dd7f99423a8e86c941f9ba26b0d54b21f27f2a1a52ac
|
7
|
+
data.tar.gz: c901b39875e0828471bce2c59be8db34ca97d05d459dcb6f7405d58f748241e2e13fc0104f6d5090fcfc74d44ec6a378bf16425a6ddc172c73495989b4aade7c
|
data/Gemfile.lock
CHANGED
@@ -12,7 +12,7 @@ module Wavefront
|
|
12
12
|
#
|
13
13
|
# @param offset [Int] integration at which the list begins
|
14
14
|
# @param limit [Int] the number of integration to return
|
15
|
-
# @return [
|
15
|
+
# @return [Wavefront::Response]
|
16
16
|
#
|
17
17
|
def list(offset = 0, limit = 100)
|
18
18
|
api_get('', { offset: offset, limit: limit })
|
@@ -23,7 +23,7 @@ module Wavefront
|
|
23
23
|
# valid keys.
|
24
24
|
#
|
25
25
|
# @param body [Hash] description of integration
|
26
|
-
# @return [
|
26
|
+
# @return [Wavefront::Response]
|
27
27
|
#
|
28
28
|
def create(body)
|
29
29
|
raise ArgumentError unless body.is_a?(Hash)
|
@@ -38,7 +38,7 @@ module Wavefront
|
|
38
38
|
# integration in 'trash' removes it for ever.
|
39
39
|
#
|
40
40
|
# @param id [String] ID of the integration
|
41
|
-
# @return [
|
41
|
+
# @return [Wavefront::Response]
|
42
42
|
#
|
43
43
|
def delete(id)
|
44
44
|
wf_cloudintegration_id?(id)
|
@@ -49,7 +49,7 @@ module Wavefront
|
|
49
49
|
# Get a specific cloud integration
|
50
50
|
#
|
51
51
|
# @param id [String] ID of the integration
|
52
|
-
# @return [
|
52
|
+
# @return [Wavefront::Response]
|
53
53
|
#
|
54
54
|
def describe(id)
|
55
55
|
wf_cloudintegration_id?(id)
|
@@ -60,7 +60,7 @@ module Wavefront
|
|
60
60
|
# Update a specific cloud integration
|
61
61
|
#
|
62
62
|
# @param id [String] ID of the integration
|
63
|
-
# @param body [
|
63
|
+
# @param body [Wavefront::Response]
|
64
64
|
#
|
65
65
|
def update(id, body)
|
66
66
|
wf_cloudintegration_id?(id)
|
@@ -72,7 +72,7 @@ module Wavefront
|
|
72
72
|
# Undelete a specific cloud integration
|
73
73
|
#
|
74
74
|
# @param id [String] ID of the integration
|
75
|
-
# @return [
|
75
|
+
# @return [Wavefront::Response]
|
76
76
|
#
|
77
77
|
def undelete(id)
|
78
78
|
wf_cloudintegration_id?(id)
|
@@ -5,13 +5,16 @@ module Wavefront
|
|
5
5
|
# View and manage dashboards.
|
6
6
|
#
|
7
7
|
class Dashboard < Base
|
8
|
+
def update_keys
|
9
|
+
%i(id name url description sections)
|
10
|
+
end
|
8
11
|
|
9
12
|
# GET /api/v2/dashboard
|
10
13
|
# Get all dashboards for a customer.
|
11
14
|
#
|
12
15
|
# @param offset [Int] dashboard at which the list begins
|
13
16
|
# @param limit [Int] the number of dashboard to return
|
14
|
-
# @return [
|
17
|
+
# @return [Wavefront::Response]
|
15
18
|
#
|
16
19
|
def list(offset = 0, limit = 100)
|
17
20
|
api_get('', { offset: offset, limit: limit })
|
@@ -22,7 +25,7 @@ module Wavefront
|
|
22
25
|
# Refer to the Swagger API docs for valid keys.
|
23
26
|
#
|
24
27
|
# @param body [Hash] description of dashboard
|
25
|
-
# @return [
|
28
|
+
# @return [Wavefront::Response]
|
26
29
|
#
|
27
30
|
def create(body)
|
28
31
|
raise ArgumentError unless body.is_a?(Hash)
|
@@ -36,7 +39,7 @@ module Wavefront
|
|
36
39
|
# 'trash' removes it for ever.
|
37
40
|
#
|
38
41
|
# @param id [String] ID of the dashboard
|
39
|
-
# @return [
|
42
|
+
# @return [Wavefront::Response]
|
40
43
|
#
|
41
44
|
def delete(id)
|
42
45
|
wf_dashboard_id?(id)
|
@@ -49,7 +52,7 @@ module Wavefront
|
|
49
52
|
#
|
50
53
|
# @param id [String] ID of the dashboard
|
51
54
|
# @param version [Integer] version of dashboard
|
52
|
-
# @return [
|
55
|
+
# @return [Wavefront::Response]
|
53
56
|
#
|
54
57
|
def describe(id, version = nil)
|
55
58
|
wf_dashboard_id?(id)
|
@@ -62,22 +65,30 @@ module Wavefront
|
|
62
65
|
# PUT /api/v2/dashboard/id
|
63
66
|
# Update a specific dashboard.
|
64
67
|
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
# @
|
69
|
-
#
|
70
|
-
|
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)
|
71
77
|
wf_dashboard_id?(id)
|
72
78
|
raise ArgumentError unless body.is_a?(Hash)
|
73
|
-
|
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')
|
74
84
|
end
|
75
85
|
|
86
|
+
|
76
87
|
# GET /api/v2/dashboard/id/history
|
77
88
|
# Get the version history of an dashboard.
|
78
89
|
#
|
79
90
|
# @param id [String] ID of the dashboard
|
80
|
-
# @return [
|
91
|
+
# @return [Wavefront::Response]
|
81
92
|
#
|
82
93
|
def history(id)
|
83
94
|
wf_dashboard_id?(id)
|
@@ -88,7 +99,7 @@ module Wavefront
|
|
88
99
|
# Get all tags associated with a specific dashboard.
|
89
100
|
#
|
90
101
|
# @param id [String] ID of the dashboard
|
91
|
-
# @return [
|
102
|
+
# @return [Wavefront::Response]
|
92
103
|
# response keys
|
93
104
|
#
|
94
105
|
def tags(id)
|
@@ -101,7 +112,7 @@ module Wavefront
|
|
101
112
|
#
|
102
113
|
# @param id [String] ID of the dashboard
|
103
114
|
# @param tags [Array] list of tags to set.
|
104
|
-
# @return [
|
115
|
+
# @return [Wavefront::Response]
|
105
116
|
# response keys
|
106
117
|
#
|
107
118
|
def tag_set(id, tags)
|
@@ -116,7 +127,7 @@ module Wavefront
|
|
116
127
|
#
|
117
128
|
# @param id [String] ID of the dashboard
|
118
129
|
# @param tag [String] tag to delete
|
119
|
-
# @return [
|
130
|
+
# @return [Wavefront::Response]
|
120
131
|
#
|
121
132
|
def tag_delete(id, tag)
|
122
133
|
wf_dashboard_id?(id)
|
@@ -129,7 +140,7 @@ module Wavefront
|
|
129
140
|
#
|
130
141
|
# @param id [String] ID of the dashboard
|
131
142
|
# @param tag [String] tag to set.
|
132
|
-
# @return [
|
143
|
+
# @return [Wavefront::Response]
|
133
144
|
#
|
134
145
|
def tag_add(id, tag)
|
135
146
|
wf_dashboard_id?(id)
|
@@ -141,7 +152,7 @@ module Wavefront
|
|
141
152
|
# Move an dashboard from 'trash' back into active service.
|
142
153
|
#
|
143
154
|
# @param id [String] ID of the dashboard
|
144
|
-
# @return [
|
155
|
+
# @return [Wavefront::Response]
|
145
156
|
#
|
146
157
|
def undelete(id)
|
147
158
|
wf_dashboard_id?(id)
|
data/lib/wavefront-sdk/event.rb
CHANGED
@@ -21,7 +21,7 @@ module Wavefront
|
|
21
21
|
# current time.
|
22
22
|
# @param cursor [String] I think this must start with a timestamp.
|
23
23
|
# @param limit [Integer] the number of events to return
|
24
|
-
# @return [
|
24
|
+
# @return [Wavefront::Response]
|
25
25
|
#
|
26
26
|
def list(from = nil, to = nil, limit = 100, cursor = nil)
|
27
27
|
raise ArgumentError unless from && to
|
@@ -46,7 +46,7 @@ module Wavefront
|
|
46
46
|
# Refer to the Swagger docs for more information.
|
47
47
|
#
|
48
48
|
# @param body [Hash] description of event
|
49
|
-
# @return [
|
49
|
+
# @return [Wavefront::Response]
|
50
50
|
#
|
51
51
|
def create(body)
|
52
52
|
raise ArgumentError unless body.is_a?(Hash)
|
@@ -57,7 +57,7 @@ module Wavefront
|
|
57
57
|
# Delete a specific event.
|
58
58
|
#
|
59
59
|
# @param id [String] ID of the alert
|
60
|
-
# @return [
|
60
|
+
# @return [Wavefront::Response]
|
61
61
|
#
|
62
62
|
def delete(id)
|
63
63
|
wf_event_id?(id)
|
@@ -70,7 +70,7 @@ module Wavefront
|
|
70
70
|
#
|
71
71
|
# @param id [String] ID of the event
|
72
72
|
# @param version [Integer] version of event
|
73
|
-
# @return [
|
73
|
+
# @return [Wavefront::Response]
|
74
74
|
#
|
75
75
|
def describe(id, version = nil)
|
76
76
|
wf_event_id?(id)
|
@@ -91,7 +91,7 @@ module Wavefront
|
|
91
91
|
# object will be fetched and merged with the user-supplied body.
|
92
92
|
# The resulting object will be passed to the API. If this is
|
93
93
|
# false, the body will be passed through unmodified.
|
94
|
-
# @return [
|
94
|
+
# @return [Wavefront::Response]
|
95
95
|
#
|
96
96
|
def update(id, body, modify = true)
|
97
97
|
wf_event_id?(id)
|
@@ -116,7 +116,7 @@ module Wavefront
|
|
116
116
|
# Get all tags associated with a specific event
|
117
117
|
#
|
118
118
|
# @param id [String] ID of the event
|
119
|
-
# @return [
|
119
|
+
# @return [Wavefront::Response]
|
120
120
|
# response keys
|
121
121
|
#
|
122
122
|
def tags(id)
|
@@ -129,7 +129,7 @@ module Wavefront
|
|
129
129
|
#
|
130
130
|
# @param id [String] ID of the event
|
131
131
|
# @param tags [Array] list of tags to set.
|
132
|
-
# @return [
|
132
|
+
# @return [Wavefront::Response]
|
133
133
|
# response keys
|
134
134
|
#
|
135
135
|
def tag_set(id, tags)
|
@@ -144,7 +144,7 @@ module Wavefront
|
|
144
144
|
#
|
145
145
|
# @param id [String] ID of the event
|
146
146
|
# @param tag [String] tag to delete
|
147
|
-
# @return [
|
147
|
+
# @return [Wavefront::Response]
|
148
148
|
#
|
149
149
|
def tag_delete(id, tag)
|
150
150
|
wf_event_id?(id)
|
@@ -157,7 +157,7 @@ module Wavefront
|
|
157
157
|
#
|
158
158
|
# @param id [String] ID of the event
|
159
159
|
# @param tag [String] tag to set.
|
160
|
-
# @return [
|
160
|
+
# @return [Wavefront::Response]
|
161
161
|
#
|
162
162
|
def tag_add(id, tag)
|
163
163
|
wf_event_id?(id)
|
@@ -9,6 +9,10 @@ module Wavefront
|
|
9
9
|
'/extlink'
|
10
10
|
end
|
11
11
|
|
12
|
+
def update_keys
|
13
|
+
%i(name template description)
|
14
|
+
end
|
15
|
+
|
12
16
|
# GET /api/v2/extlink
|
13
17
|
# Get all external links for a customer
|
14
18
|
#
|
@@ -23,7 +27,7 @@ module Wavefront
|
|
23
27
|
# Create a specific external link.
|
24
28
|
#
|
25
29
|
# @param body [Hash] a description of the external link.
|
26
|
-
# @return [
|
30
|
+
# @return [Wavefront::Response]
|
27
31
|
#
|
28
32
|
def create(body)
|
29
33
|
raise ArgumentError unless body.is_a?(Hash)
|
@@ -34,7 +38,7 @@ module Wavefront
|
|
34
38
|
# Delete a specific external link.
|
35
39
|
#
|
36
40
|
# @param id [String] ID of the link
|
37
|
-
# @return [
|
41
|
+
# @return [Wavefront::Response]
|
38
42
|
#
|
39
43
|
def delete(id)
|
40
44
|
wf_link_id?(id)
|
@@ -45,7 +49,7 @@ module Wavefront
|
|
45
49
|
# Get a specific external link.
|
46
50
|
#
|
47
51
|
# @param id [String] ID of the limnk
|
48
|
-
# @return [
|
52
|
+
# @return [Wavefront::Response]
|
49
53
|
#
|
50
54
|
def describe(id)
|
51
55
|
wf_link_id?(id)
|
@@ -55,15 +59,22 @@ module Wavefront
|
|
55
59
|
# PUT /api/v2/extlink/id
|
56
60
|
# Update a specific external link.
|
57
61
|
#
|
58
|
-
# @param id [String]
|
59
|
-
# @param body [Hash]
|
60
|
-
#
|
61
|
-
# @
|
62
|
-
#
|
63
|
-
|
62
|
+
# @param id [String] a Wavefront external link ID
|
63
|
+
# @param body [Hash] key-value hash of the parameters you wish
|
64
|
+
# to change
|
65
|
+
# @param modify [true, false] if true, use {#describe()} to get
|
66
|
+
# a hash describing the existing object, and modify that with
|
67
|
+
# the new body. If false, pass the new body straight through.
|
68
|
+
# @return [Wavefront::Response]
|
69
|
+
|
70
|
+
def update(id, body, modify = true)
|
64
71
|
wf_link_id?(id)
|
65
72
|
raise ArgumentError unless body.is_a?(Hash)
|
66
|
-
|
73
|
+
|
74
|
+
return api_put(id, body, 'application/json') unless modify
|
75
|
+
|
76
|
+
api_put(id, hash_for_update(describe(id).response, body),
|
77
|
+
'application/json')
|
67
78
|
end
|
68
79
|
end
|
69
80
|
end
|
@@ -5,6 +5,10 @@ module Wavefront
|
|
5
5
|
# Manage and query Wavefront maintenance windows
|
6
6
|
#
|
7
7
|
class MaintenanceWindow < Base
|
8
|
+
def update_keys
|
9
|
+
%i(reason title startTimeInSeconds endTimeInSeconds
|
10
|
+
relevantCustomerTags relevantHostTags)
|
11
|
+
end
|
8
12
|
|
9
13
|
# GET /api/v2/maintenancewindow
|
10
14
|
# Get all maintenance windows for a customer.
|
@@ -24,7 +28,7 @@ module Wavefront
|
|
24
28
|
# @param body [Hash] a hash of parameters describing the window.
|
25
29
|
# Please refer to the Wavefront Swagger docs for key:value
|
26
30
|
# information
|
27
|
-
# @return [
|
31
|
+
# @return [Wavefront::Response]
|
28
32
|
#
|
29
33
|
def create(body)
|
30
34
|
raise ArgumentError unless body.is_a?(Hash)
|
@@ -35,7 +39,7 @@ module Wavefront
|
|
35
39
|
# Delete a specific maintenance window.
|
36
40
|
#
|
37
41
|
# @param id [String, Integer] ID of the maintenance window
|
38
|
-
# @return [
|
42
|
+
# @return [Wavefront::Response]
|
39
43
|
#
|
40
44
|
def delete(id)
|
41
45
|
wf_maintenance_window_id?(id)
|
@@ -46,7 +50,7 @@ module Wavefront
|
|
46
50
|
# Get a specific maintenance window.
|
47
51
|
#
|
48
52
|
# @param id [String, Integer] ID of the maintenance window
|
49
|
-
# @return [
|
53
|
+
# @return [Wavefront::Response]
|
50
54
|
#
|
51
55
|
def describe(id)
|
52
56
|
wf_maintenance_window_id?(id)
|
@@ -56,14 +60,22 @@ module Wavefront
|
|
56
60
|
# PUT /api/v2/maintenancewindow/id
|
57
61
|
# Update a specific maintenance window.
|
58
62
|
#
|
59
|
-
# @param
|
60
|
-
# @
|
61
|
-
#
|
62
|
-
#
|
63
|
-
|
63
|
+
# @param id [String] a Wavefront maintenance window ID
|
64
|
+
# @param body [Hash] key-value hash of the parameters you wish
|
65
|
+
# to change
|
66
|
+
# @param modify [true, false] if true, use {#describe()} to get
|
67
|
+
# a hash describing the existing object, and modify that with
|
68
|
+
# the new body. If false, pass the new body straight through.
|
69
|
+
# @return [Wavefront::Response]
|
70
|
+
|
71
|
+
def update(id, body, modify = true)
|
64
72
|
wf_maintenance_window_id?(id)
|
65
73
|
raise ArgumentError unless body.is_a?(Hash)
|
66
|
-
|
74
|
+
|
75
|
+
return api_put(id, body, 'application/json') unless modify
|
76
|
+
|
77
|
+
api_put(id, hash_for_update(describe(id).response, body),
|
78
|
+
'application/json')
|
67
79
|
end
|
68
80
|
end
|
69
81
|
end
|
data/lib/wavefront-sdk/proxy.rb
CHANGED
@@ -24,7 +24,7 @@ module Wavefront
|
|
24
24
|
# in 'trash' removes it for ever.
|
25
25
|
#
|
26
26
|
# @param id [String] ID of the proxy
|
27
|
-
# @return [
|
27
|
+
# @return [Wavefront::Response]
|
28
28
|
#
|
29
29
|
def delete(id)
|
30
30
|
wf_proxy_id?(id)
|
@@ -35,7 +35,7 @@ module Wavefront
|
|
35
35
|
# Get a specific proxy
|
36
36
|
#
|
37
37
|
# @param id [String] ID of the proxy
|
38
|
-
# @return [
|
38
|
+
# @return [Wavefront::Response]
|
39
39
|
#
|
40
40
|
def describe(id)
|
41
41
|
wf_proxy_id?(id)
|
@@ -48,7 +48,7 @@ module Wavefront
|
|
48
48
|
# Move an proxy from 'trash' back into active service.
|
49
49
|
#
|
50
50
|
# @param id [String] ID of the proxy
|
51
|
-
# @return [
|
51
|
+
# @return [Wavefront::Response]
|
52
52
|
#
|
53
53
|
def undelete(id)
|
54
54
|
wf_proxy_id?(id)
|
@@ -63,7 +63,7 @@ module Wavefront
|
|
63
63
|
#
|
64
64
|
# @param id [String] ID of the proxy
|
65
65
|
# @param name [String] new name
|
66
|
-
# @return [
|
66
|
+
# @return [Wavefront::Response]
|
67
67
|
#
|
68
68
|
def rename(id, name)
|
69
69
|
wf_proxy_id?(id)
|
@@ -79,7 +79,7 @@ module Wavefront
|
|
79
79
|
# @param payload [Hash] a key: value hash, where the key is the
|
80
80
|
# property to change and the value is its desired value. No
|
81
81
|
# validation is performed on any part of the payload.
|
82
|
-
# @return [
|
82
|
+
# @return [Wavefront::Response]
|
83
83
|
#
|
84
84
|
def update(id, payload)
|
85
85
|
wf_proxy_id?(id)
|
data/lib/wavefront-sdk/query.rb
CHANGED
@@ -26,7 +26,7 @@ module Wavefront
|
|
26
26
|
# May be a Ruby Time object, or epoch milliseconds.
|
27
27
|
# @param options [Hash] any other options defined in the API
|
28
28
|
# @raise [ArgumentError] if query is not a string
|
29
|
-
# @return [Wavefront::Response
|
29
|
+
# @return [Wavefront::Response]
|
30
30
|
#
|
31
31
|
def query(query, granularity = nil, t_start = nil, t_end = nil,
|
32
32
|
options = {})
|
@@ -75,5 +75,16 @@ module Wavefront
|
|
75
75
|
|
76
76
|
api_get('raw', options)
|
77
77
|
end
|
78
|
+
|
79
|
+
# Fake a response which looks like we get from all the other
|
80
|
+
# paths. The default response is a single array.
|
81
|
+
#
|
82
|
+
def response_shim(body, status)
|
83
|
+
{ response: JSON.parse(body),
|
84
|
+
status: { result: status == 200 ? 'OK' : 'ERROR',
|
85
|
+
message: '',
|
86
|
+
code: status },
|
87
|
+
}.to_json
|
88
|
+
end
|
78
89
|
end
|
79
90
|
end
|
@@ -31,7 +31,11 @@ module Wavefront
|
|
31
31
|
# has changed underneath us.
|
32
32
|
#
|
33
33
|
def initialize(json, status, debug = false)
|
34
|
-
|
34
|
+
begin
|
35
|
+
raw = json.empty? ? {} : JSON.parse(json, symbolize_names: true)
|
36
|
+
rescue
|
37
|
+
raw = { message: json, code: status }
|
38
|
+
end
|
35
39
|
|
36
40
|
@status = build_status(raw, status)
|
37
41
|
@response = build_response(raw)
|
@@ -47,7 +51,15 @@ module Wavefront
|
|
47
51
|
end
|
48
52
|
|
49
53
|
def build_response(raw)
|
50
|
-
|
54
|
+
if raw.is_a?(Hash)
|
55
|
+
if raw.key?(:response)
|
56
|
+
Map(raw[:response])
|
57
|
+
else
|
58
|
+
Map.new
|
59
|
+
end
|
60
|
+
else
|
61
|
+
Map.new
|
62
|
+
end
|
51
63
|
end
|
52
64
|
end
|
53
65
|
|
@@ -75,9 +87,16 @@ module Wavefront
|
|
75
87
|
def initialize(raw, status)
|
76
88
|
obj = raw.key?(:status) ? raw[:status] : raw
|
77
89
|
|
78
|
-
@result = obj[:result] || nil
|
79
90
|
@message = obj[:message] || nil
|
80
91
|
@code = obj[:code] || status
|
92
|
+
|
93
|
+
@result = if obj[:result]
|
94
|
+
obj[:result]
|
95
|
+
elsif status == 200
|
96
|
+
'OK'
|
97
|
+
else
|
98
|
+
'ERROR'
|
99
|
+
end
|
81
100
|
end
|
82
101
|
end
|
83
102
|
end
|
@@ -12,7 +12,7 @@ module Wavefront
|
|
12
12
|
#
|
13
13
|
# @param offset [Int] saved search at which the list begins
|
14
14
|
# @param limit [Int] the number of saved searches to return
|
15
|
-
# @return [
|
15
|
+
# @return [Wavefront::Response]
|
16
16
|
#
|
17
17
|
def list(offset = 0, limit = 100)
|
18
18
|
api_get('', { offset: offset, limit: limit })
|
@@ -23,7 +23,7 @@ module Wavefront
|
|
23
23
|
# valid keys.
|
24
24
|
#
|
25
25
|
# @param body [Hash] description of saved search
|
26
|
-
# @return [
|
26
|
+
# @return [Wavefront::Response]
|
27
27
|
#
|
28
28
|
def create(body)
|
29
29
|
raise ArgumentError unless body.is_a?(Hash)
|
@@ -34,7 +34,7 @@ module Wavefront
|
|
34
34
|
# Delete a specific saved search.
|
35
35
|
#
|
36
36
|
# @param id [String] ID of the saved search
|
37
|
-
# @return [
|
37
|
+
# @return [Wavefront::Response]
|
38
38
|
#
|
39
39
|
def delete(id)
|
40
40
|
wf_savedsearch_id?(id)
|
@@ -45,7 +45,7 @@ module Wavefront
|
|
45
45
|
# Get a specific saved search.
|
46
46
|
#
|
47
47
|
# @param id [String] ID of the saved search
|
48
|
-
# @return [
|
48
|
+
# @return [Wavefront::Response]
|
49
49
|
#
|
50
50
|
def describe(id)
|
51
51
|
wf_savedsearch_id?(id)
|
@@ -56,7 +56,7 @@ module Wavefront
|
|
56
56
|
# Update a specific saved search.
|
57
57
|
#
|
58
58
|
# @param id [String] ID of the saved search
|
59
|
-
# @param body [
|
59
|
+
# @param body [Wavefront::Response]
|
60
60
|
#
|
61
61
|
def update(id, body)
|
62
62
|
wf_savedsearch_id?(id)
|
@@ -70,7 +70,7 @@ module Wavefront
|
|
70
70
|
# @param entitytype [String] type of entity to retrieve
|
71
71
|
# @param offset [Int] saved search at which the list begins
|
72
72
|
# @param limit [Int] the number of saved searches to return
|
73
|
-
# @return [
|
73
|
+
# @return [Wavefront::Response]
|
74
74
|
#
|
75
75
|
def entity(entitytype, offset = 0, limit = 100)
|
76
76
|
wf_savedsearch_entity?(entitytype)
|
data/lib/wavefront-sdk/source.rb
CHANGED
@@ -5,13 +5,16 @@ module Wavefront
|
|
5
5
|
# View and manage source metadata.
|
6
6
|
#
|
7
7
|
class Source < Base
|
8
|
+
def update_keys
|
9
|
+
%i(sourceName tags description)
|
10
|
+
end
|
8
11
|
|
9
12
|
# GET /api/v2/source
|
10
13
|
# Get all sources for a customer
|
11
14
|
#
|
12
15
|
# @param offset [Int] source at which the list begins
|
13
16
|
# @param limit [Int] the number of sources to return
|
14
|
-
# @return [
|
17
|
+
# @return [Wavefront::Response]
|
15
18
|
#
|
16
19
|
def list(offset = 0, limit = 100)
|
17
20
|
api_get('', { offset: offset, limit: limit })
|
@@ -23,7 +26,7 @@ module Wavefront
|
|
23
26
|
# Refer to the Swagger API docs for valid keys.
|
24
27
|
#
|
25
28
|
# @param body [Hash] description of source
|
26
|
-
# @return [
|
29
|
+
# @return [Wavefront::Response]
|
27
30
|
#
|
28
31
|
def create(body)
|
29
32
|
raise ArgumentError unless body.is_a?(Hash)
|
@@ -34,7 +37,7 @@ module Wavefront
|
|
34
37
|
# Delete metadata (description and tags) for a specific source.
|
35
38
|
#
|
36
39
|
# @param id [String] ID of the source
|
37
|
-
# @return [
|
40
|
+
# @return [Wavefront::Response]
|
38
41
|
#
|
39
42
|
def delete(id)
|
40
43
|
wf_source_id?(id)
|
@@ -45,7 +48,7 @@ module Wavefront
|
|
45
48
|
# Get a specific source for a customer.
|
46
49
|
#
|
47
50
|
# @param id [String] ID of the source
|
48
|
-
# @return [
|
51
|
+
# @return [Wavefront::Response]
|
49
52
|
#
|
50
53
|
def describe(id, version = nil)
|
51
54
|
wf_source_id?(id)
|
@@ -58,23 +61,29 @@ module Wavefront
|
|
58
61
|
# PUT /api/v2/source/id
|
59
62
|
# Update metadata (description or tags) for a specific source.
|
60
63
|
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
# @
|
65
|
-
#
|
66
|
-
|
64
|
+
# @param id [String] a Wavefront alert ID
|
65
|
+
# @param body [Hash] key-value hash of the parameters you wish
|
66
|
+
# to change
|
67
|
+
# @param modify [true, false] if true, use {#describe()} to get
|
68
|
+
# a hash describing the existing object, and modify that with
|
69
|
+
# the new body. If false, pass the new body straight through.
|
70
|
+
# @return [Wavefront::Response]
|
71
|
+
|
72
|
+
def update(id, body, modify = true)
|
67
73
|
wf_source_id?(id)
|
68
74
|
raise ArgumentError unless body.is_a?(Hash)
|
69
|
-
|
75
|
+
|
76
|
+
return api_put(id, body, 'application/json') unless modify
|
77
|
+
|
78
|
+
api_put(id, hash_for_update(describe(id).response, body),
|
79
|
+
'application/json')
|
70
80
|
end
|
71
81
|
|
72
82
|
# GET /api/v2/source/id/tag
|
73
83
|
# Get all tags associated with a specific source.
|
74
84
|
#
|
75
85
|
# @param id [String] ID of the source
|
76
|
-
# @return [
|
77
|
-
# response keys
|
86
|
+
# @return [Wavefront::Response]
|
78
87
|
#
|
79
88
|
def tags(id)
|
80
89
|
wf_source_id?(id)
|
@@ -86,8 +95,7 @@ module Wavefront
|
|
86
95
|
#
|
87
96
|
# @param id [String] ID of the source
|
88
97
|
# @param tags [Array] list of tags to set.
|
89
|
-
# @return [
|
90
|
-
# response keys
|
98
|
+
# @return [Wavefront::Response]
|
91
99
|
#
|
92
100
|
def tag_set(id, tags)
|
93
101
|
wf_source_id?(id)
|
@@ -101,7 +109,7 @@ module Wavefront
|
|
101
109
|
#
|
102
110
|
# @param id [String] ID of the source
|
103
111
|
# @param tag [String] tag to delete
|
104
|
-
# @return [
|
112
|
+
# @return [Wavefront::Response]
|
105
113
|
#
|
106
114
|
def tag_delete(id, tag)
|
107
115
|
wf_source_id?(id)
|
@@ -114,7 +122,7 @@ module Wavefront
|
|
114
122
|
#
|
115
123
|
# @param id [String] ID of the source
|
116
124
|
# @param tag [String] tag to set.
|
117
|
-
# @return [
|
125
|
+
# @return [Wavefront::Response]
|
118
126
|
#
|
119
127
|
def tag_add(id, tag)
|
120
128
|
wf_source_id?(id)
|
data/lib/wavefront-sdk/user.rb
CHANGED
@@ -19,7 +19,7 @@ module Wavefront
|
|
19
19
|
# @param body [Hash] a hash of parameters describing the user.
|
20
20
|
# Please refer to the Wavefront Swagger docs for key:value
|
21
21
|
# information
|
22
|
-
# @return [
|
22
|
+
# @return [Wavefront::Response]
|
23
23
|
#
|
24
24
|
def create(body, send_email = false)
|
25
25
|
raise ArgumentError unless body.is_a?(Hash)
|
@@ -30,7 +30,7 @@ module Wavefront
|
|
30
30
|
# Delete a specific user.
|
31
31
|
#
|
32
32
|
# @param id [String] ID of the user
|
33
|
-
# @return [
|
33
|
+
# @return [Wavefront::Response]
|
34
34
|
#
|
35
35
|
def delete(id)
|
36
36
|
wf_user_id?(id)
|
@@ -41,7 +41,7 @@ module Wavefront
|
|
41
41
|
# Retrieves a user by identifier (email addr).
|
42
42
|
#
|
43
43
|
# @param id [String] ID of the user
|
44
|
-
# @return [
|
44
|
+
# @return [Wavefront::Response]
|
45
45
|
#
|
46
46
|
def describe(id)
|
47
47
|
wf_user_id?(id)
|
@@ -59,7 +59,7 @@ module Wavefront
|
|
59
59
|
# embedded_charts, events_management,
|
60
60
|
# external_links_management, host_tag_management,
|
61
61
|
# metrics_management, user_management,
|
62
|
-
# @return [
|
62
|
+
# @return [Wavefront::Response]
|
63
63
|
#
|
64
64
|
def grant(id, group)
|
65
65
|
wf_user_id?(id)
|
@@ -75,7 +75,7 @@ module Wavefront
|
|
75
75
|
# @param group [String] group to add user to. We do not validate
|
76
76
|
# this so that changes to the API do not mandate changes to
|
77
77
|
# the SDK. See #update for valid values.
|
78
|
-
# @return [
|
78
|
+
# @return [Wavefront::Response]
|
79
79
|
#
|
80
80
|
def revoke(id, group)
|
81
81
|
wf_user_id?(id)
|
@@ -1 +1 @@
|
|
1
|
-
WF_SDK_VERSION = '0.1.
|
1
|
+
WF_SDK_VERSION = '0.1.5'.freeze
|
@@ -5,6 +5,9 @@ module Wavefront
|
|
5
5
|
# Manage and query Wavefront webhooks
|
6
6
|
#
|
7
7
|
class Webhook < Base
|
8
|
+
def update_keys
|
9
|
+
%i(title description template title triggers recipient)
|
10
|
+
end
|
8
11
|
|
9
12
|
# GET /api/v2/webhook
|
10
13
|
# Get all webhooks for a customer.
|
@@ -22,7 +25,7 @@ module Wavefront
|
|
22
25
|
# @param body [Hash] a hash of parameters describing the webhook.
|
23
26
|
# Please refer to the Wavefront Swagger docs for key:value
|
24
27
|
# information
|
25
|
-
# @return [
|
28
|
+
# @return [Wavefront::Response]
|
26
29
|
#
|
27
30
|
def create(body)
|
28
31
|
raise ArgumentError unless body.is_a?(Hash)
|
@@ -33,7 +36,7 @@ module Wavefront
|
|
33
36
|
# Delete a specific webhook.
|
34
37
|
#
|
35
38
|
# @param id [String, Integer] ID of the webhook
|
36
|
-
# @return [
|
39
|
+
# @return [Wavefront::Response]
|
37
40
|
#
|
38
41
|
def delete(id)
|
39
42
|
wf_webhook_id?(id)
|
@@ -44,7 +47,7 @@ module Wavefront
|
|
44
47
|
# Get a specific webhook.
|
45
48
|
#
|
46
49
|
# @param id [String, Integer] ID of the webhook
|
47
|
-
# @return [
|
50
|
+
# @return [Wavefront::Response]
|
48
51
|
#
|
49
52
|
def describe(id)
|
50
53
|
wf_webhook_id?(id)
|
@@ -54,14 +57,22 @@ module Wavefront
|
|
54
57
|
# PUT /api/v2/webhook/id
|
55
58
|
# Update a specific webhook.
|
56
59
|
#
|
57
|
-
# @param
|
58
|
-
# @
|
59
|
-
#
|
60
|
-
#
|
61
|
-
|
60
|
+
# @param id [String] a Wavefront webhook ID
|
61
|
+
# @param body [Hash] key-value hash of the parameters you wish
|
62
|
+
# to change
|
63
|
+
# @param modify [true, false] if true, use {#describe()} to get
|
64
|
+
# a hash describing the existing object, and modify that with
|
65
|
+
# the new body. If false, pass the new body straight through.
|
66
|
+
# @return [Wavefront::Response]
|
67
|
+
|
68
|
+
def update(id, body, modify = true)
|
62
69
|
wf_webhook_id?(id)
|
63
70
|
raise ArgumentError unless body.is_a?(Hash)
|
64
|
-
|
71
|
+
|
72
|
+
return api_put(id, body, 'application/json') unless modify
|
73
|
+
|
74
|
+
api_put(id, hash_for_update(describe(id).response, body),
|
75
|
+
'application/json')
|
65
76
|
end
|
66
77
|
end
|
67
78
|
end
|
data/lib/wavefront-sdk/write.rb
CHANGED
@@ -211,25 +211,4 @@ module Wavefront
|
|
211
211
|
@net = creds
|
212
212
|
end
|
213
213
|
end
|
214
|
-
|
215
|
-
#class Response
|
216
|
-
# The Write response forges status and response methods to look
|
217
|
-
# like other classes and create a more consistent interface. As
|
218
|
-
# the request does not happen over HTTP, there's not much to put
|
219
|
-
# in the status object. The response object is the contents of
|
220
|
-
# the summary variable.
|
221
|
-
#
|
222
|
-
# @response=#<struct sent=1, rejected=0, unsent=0>,
|
223
|
-
# @status=#<struct result="OK", message=nil, code=nil>>
|
224
|
-
#
|
225
|
-
#class Write < Base
|
226
|
-
#def populate(raw, status)
|
227
|
-
#@response = Struct.new(*raw.keys).new(*raw.values).freeze
|
228
|
-
#
|
229
|
-
#ok = raw[:rejected] == 0 && raw[:unsent] == 0 ? 'OK' : 'ERROR'
|
230
|
-
#
|
231
|
-
#@status = Struct.new(:result, :message, :code).new(ok, nil, nil)
|
232
|
-
#end
|
233
|
-
#end
|
234
|
-
#end
|
235
214
|
end
|
@@ -56,8 +56,9 @@ class WavefrontDashboardTest < WavefrontTestBase
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_update
|
59
|
-
should_work(:update, [DASHBOARD, DASHBOARD_BODY
|
60
|
-
JSON_POST_HEADERS,
|
59
|
+
should_work(:update, [DASHBOARD, DASHBOARD_BODY, false],
|
60
|
+
DASHBOARD, :put, JSON_POST_HEADERS,
|
61
|
+
DASHBOARD_BODY.to_json)
|
61
62
|
should_be_invalid(:update, ['!invalid dash!', DASHBOARD_BODY])
|
62
63
|
assert_raises(ArgumentError) { wf.update }
|
63
64
|
end
|
@@ -50,11 +50,11 @@ class WavefrontExternalLinkTest < WavefrontTestBase
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_update
|
53
|
-
should_work(:update, [EXTERNAL_LINK, EXTERNAL_LINK_BODY],
|
53
|
+
should_work(:update, [EXTERNAL_LINK, EXTERNAL_LINK_BODY, false],
|
54
54
|
EXTERNAL_LINK, :put, JSON_POST_HEADERS,
|
55
55
|
EXTERNAL_LINK_BODY.to_json)
|
56
56
|
|
57
|
-
should_work(:update, [EXTERNAL_LINK, EXTERNAL_LINK_BODY_2],
|
57
|
+
should_work(:update, [EXTERNAL_LINK, EXTERNAL_LINK_BODY_2, false],
|
58
58
|
EXTERNAL_LINK, :put, JSON_POST_HEADERS,
|
59
59
|
EXTERNAL_LINK_BODY_2.to_json)
|
60
60
|
|
@@ -40,7 +40,7 @@ class WavefrontMaintenanceWindowTest < WavefrontTestBase
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def test_update
|
43
|
-
should_work(:update, [WINDOW, WINDOW_BODY], WINDOW, :put,
|
43
|
+
should_work(:update, [WINDOW, WINDOW_BODY, false], WINDOW, :put,
|
44
44
|
JSON_POST_HEADERS, WINDOW_BODY.to_json)
|
45
45
|
should_be_invalid(:update, ['abcde', WINDOW_BODY])
|
46
46
|
assert_raises(ArgumentError) { wf.update }
|
@@ -25,23 +25,5 @@ class WavefrontResponseTest < MiniTest::Test
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_initialize_bad_data
|
28
|
-
assert_raises(Wavefront::Exception::UnparseableResponse) do
|
29
|
-
Wavefront::Response.new('merp', 200)
|
30
|
-
end
|
31
|
-
|
32
|
-
assert_raises(Wavefront::Exception::UnparseableResponse) do
|
33
|
-
Wavefront::Response.new(
|
34
|
-
'{"status":{"result":"OK","message":"","code":200}', 200)
|
35
|
-
end
|
36
|
-
|
37
|
-
assert_raises(Wavefront::Exception::UnparseableResponse) do
|
38
|
-
Wavefront::Response.new(
|
39
|
-
'{"status":{"result":"OK","message":"","code":200}', 200)
|
40
|
-
end
|
41
|
-
|
42
|
-
assert_raises(Wavefront::Exception::UnparseableResponse) do
|
43
|
-
Wavefront::Response.new(
|
44
|
-
'{"response":{"items":[{"name":"test agent"}],"offset":0 }', 200)
|
45
|
-
end
|
46
28
|
end
|
47
29
|
end
|
@@ -36,7 +36,7 @@ class WavefrontSourceTest < WavefrontTestBase
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_update
|
39
|
-
should_work(:update, [SOURCE, SOURCE_BODY], SOURCE, :put,
|
39
|
+
should_work(:update, [SOURCE, SOURCE_BODY, false], SOURCE, :put,
|
40
40
|
JSON_POST_HEADERS, SOURCE_BODY.to_json)
|
41
41
|
should_be_invalid(:update, ['!invalid source!', SOURCE_BODY])
|
42
42
|
assert_raises(ArgumentError) { wf.update }
|
@@ -42,7 +42,7 @@ class WavefrontWebhookTest < WavefrontTestBase
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_update
|
45
|
-
should_work(:update, [WEBHOOK, WEBHOOK_BODY], WEBHOOK, :put,
|
45
|
+
should_work(:update, [WEBHOOK, WEBHOOK_BODY, false], WEBHOOK, :put,
|
46
46
|
JSON_POST_HEADERS, WEBHOOK_BODY.to_json)
|
47
47
|
should_be_invalid(:update, ['abcde', WEBHOOK_BODY])
|
48
48
|
assert_raises(ArgumentError) { wf.update }
|
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.5
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|