wavefront-sdk 1.6.2 → 2.0.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/.rubocop.yml +6 -0
- data/HISTORY.md +39 -13
- data/README.md +75 -28
- data/Rakefile +1 -1
- data/lib/wavefront-sdk/alert.rb +113 -17
- data/lib/wavefront-sdk/cloudintegration.rb +8 -8
- data/lib/wavefront-sdk/core/api.rb +99 -0
- data/lib/wavefront-sdk/core/api_caller.rb +211 -0
- data/lib/wavefront-sdk/{exception.rb → core/exception.rb} +11 -6
- data/lib/wavefront-sdk/{logger.rb → core/logger.rb} +2 -3
- data/lib/wavefront-sdk/{response.rb → core/response.rb} +69 -52
- data/lib/wavefront-sdk/credentials.rb +6 -3
- data/lib/wavefront-sdk/dashboard.rb +14 -14
- data/lib/wavefront-sdk/{constants.rb → defs/constants.rb} +1 -0
- data/lib/wavefront-sdk/defs/version.rb +1 -0
- data/lib/wavefront-sdk/derivedmetric.rb +14 -14
- data/lib/wavefront-sdk/distribution.rb +75 -0
- data/lib/wavefront-sdk/event.rb +13 -13
- data/lib/wavefront-sdk/externallink.rb +8 -8
- data/lib/wavefront-sdk/integration.rb +9 -9
- data/lib/wavefront-sdk/maintenancewindow.rb +54 -8
- data/lib/wavefront-sdk/message.rb +4 -4
- data/lib/wavefront-sdk/metric.rb +3 -3
- data/lib/wavefront-sdk/notificant.rb +9 -9
- data/lib/wavefront-sdk/paginator/base.rb +148 -0
- data/lib/wavefront-sdk/paginator/delete.rb +11 -0
- data/lib/wavefront-sdk/paginator/get.rb +11 -0
- data/lib/wavefront-sdk/paginator/post.rb +64 -0
- data/lib/wavefront-sdk/paginator/put.rb +11 -0
- data/lib/wavefront-sdk/proxy.rb +7 -7
- data/lib/wavefront-sdk/query.rb +4 -4
- data/lib/wavefront-sdk/report.rb +9 -25
- data/lib/wavefront-sdk/savedsearch.rb +8 -8
- data/lib/wavefront-sdk/search.rb +16 -13
- data/lib/wavefront-sdk/source.rb +14 -14
- data/lib/wavefront-sdk/{mixins.rb → support/mixins.rb} +8 -2
- data/lib/wavefront-sdk/{parse_time.rb → support/parse_time.rb} +2 -0
- data/lib/wavefront-sdk/types/status.rb +52 -0
- data/lib/wavefront-sdk/user.rb +8 -8
- data/lib/wavefront-sdk/validators.rb +52 -3
- data/lib/wavefront-sdk/webhook.rb +8 -8
- data/lib/wavefront-sdk/write.rb +153 -52
- data/lib/wavefront-sdk/writers/api.rb +38 -0
- data/lib/wavefront-sdk/writers/core.rb +146 -0
- data/lib/wavefront-sdk/writers/http.rb +42 -0
- data/lib/wavefront-sdk/writers/socket.rb +66 -0
- data/lib/wavefront-sdk/writers/summary.rb +39 -0
- data/lib/wavefront_sdk.rb +9 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/wavefront-sdk/alert_spec.rb +6 -0
- data/spec/wavefront-sdk/{base_spec.rb → core/api_caller_spec.rb} +28 -41
- data/spec/wavefront-sdk/core/api_spec.rb +31 -0
- data/spec/wavefront-sdk/{logger_spec.rb → core/logger_spec.rb} +3 -3
- data/spec/wavefront-sdk/core/response_spec.rb +77 -0
- data/spec/wavefront-sdk/credentials_spec.rb +15 -10
- data/spec/wavefront-sdk/distribution_spec.rb +78 -0
- data/spec/wavefront-sdk/paginator/base_spec.rb +67 -0
- data/spec/wavefront-sdk/paginator/post_spec.rb +53 -0
- data/spec/wavefront-sdk/report_spec.rb +3 -1
- data/spec/wavefront-sdk/search_spec.rb +25 -0
- data/spec/wavefront-sdk/stdlib/array_spec.rb +2 -1
- data/spec/wavefront-sdk/stdlib/hash_spec.rb +6 -1
- data/spec/wavefront-sdk/stdlib/string_spec.rb +2 -0
- data/spec/wavefront-sdk/{mixins_spec.rb → support/mixins_spec.rb} +2 -2
- data/spec/wavefront-sdk/{parse_time_spec.rb → support/parse_time_spec.rb} +2 -2
- data/spec/wavefront-sdk/validators_spec.rb +64 -1
- data/spec/wavefront-sdk/write_spec.rb +55 -77
- data/spec/wavefront-sdk/writers/api_spec.rb +45 -0
- data/spec/wavefront-sdk/writers/core_spec.rb +49 -0
- data/spec/wavefront-sdk/writers/http_spec.rb +69 -0
- data/spec/wavefront-sdk/writers/socket_spec.rb +104 -0
- data/spec/wavefront-sdk/writers/summary_spec.rb +38 -0
- data/wavefront-sdk.gemspec +1 -1
- metadata +52 -24
- data/lib/wavefront-sdk/base.rb +0 -264
- data/lib/wavefront-sdk/base_write.rb +0 -185
- data/lib/wavefront-sdk/stdlib.rb +0 -5
- data/lib/wavefront-sdk/version.rb +0 -1
- data/spec/wavefront-sdk/base_write_spec.rb +0 -82
- data/spec/wavefront-sdk/response_spec.rb +0 -39
@@ -15,7 +15,7 @@ module Wavefront
|
|
15
15
|
# @return [Map] information for speaking to a Wavefront proxy
|
16
16
|
#
|
17
17
|
class Credentials
|
18
|
-
attr_reader :opts, :config, :creds, :proxy
|
18
|
+
attr_reader :opts, :config, :creds, :proxy, :all
|
19
19
|
|
20
20
|
# Gives you an object of credentials and options for speaking to
|
21
21
|
# Wavefront. It will look in the following places:
|
@@ -57,8 +57,11 @@ module Wavefront
|
|
57
57
|
#
|
58
58
|
def populate(raw)
|
59
59
|
@config = Map(raw)
|
60
|
-
@creds
|
61
|
-
@proxy
|
60
|
+
@creds = Map(raw.select { |k, _v| %i[endpoint token].include?(k) })
|
61
|
+
@proxy = Map(raw.select { |k, _v| %i[proxy port].include?(k) })
|
62
|
+
@all = Map(raw.select do |k, _v|
|
63
|
+
%i[proxy port endpoint token].include?(k)
|
64
|
+
end)
|
62
65
|
end
|
63
66
|
|
64
67
|
# @return [Array] a list of possible credential files
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'core/api'
|
2
2
|
|
3
3
|
module Wavefront
|
4
4
|
#
|
5
5
|
# View and manage dashboards.
|
6
6
|
#
|
7
|
-
class Dashboard <
|
7
|
+
class Dashboard < CoreApi
|
8
8
|
def update_keys
|
9
9
|
%i[id name url description sections]
|
10
10
|
end
|
@@ -17,7 +17,7 @@ module Wavefront
|
|
17
17
|
# @return [Wavefront::Response]
|
18
18
|
#
|
19
19
|
def list(offset = 0, limit = 100)
|
20
|
-
|
20
|
+
api.get('', offset: offset, limit: limit)
|
21
21
|
end
|
22
22
|
|
23
23
|
# POST /api/v2/dashboard
|
@@ -29,7 +29,7 @@ module Wavefront
|
|
29
29
|
#
|
30
30
|
def create(body)
|
31
31
|
raise ArgumentError unless body.is_a?(Hash)
|
32
|
-
|
32
|
+
api.post('', body, 'application/json')
|
33
33
|
end
|
34
34
|
|
35
35
|
# DELETE /api/v2/dashboard/id
|
@@ -43,7 +43,7 @@ module Wavefront
|
|
43
43
|
#
|
44
44
|
def delete(id)
|
45
45
|
wf_dashboard_id?(id)
|
46
|
-
|
46
|
+
api.delete(id)
|
47
47
|
end
|
48
48
|
|
49
49
|
# GET /api/v2/dashboard/id
|
@@ -59,7 +59,7 @@ module Wavefront
|
|
59
59
|
wf_version?(version) if version
|
60
60
|
fragments = [id]
|
61
61
|
fragments += ['history', version] if version
|
62
|
-
|
62
|
+
api.get(fragments.uri_concat)
|
63
63
|
end
|
64
64
|
|
65
65
|
# PUT /api/v2/dashboard/id
|
@@ -77,9 +77,9 @@ module Wavefront
|
|
77
77
|
wf_dashboard_id?(id)
|
78
78
|
raise ArgumentError unless body.is_a?(Hash)
|
79
79
|
|
80
|
-
return
|
80
|
+
return api.put(id, body, 'application/json') unless modify
|
81
81
|
|
82
|
-
|
82
|
+
api.put(id, hash_for_update(describe(id).response, body),
|
83
83
|
'application/json')
|
84
84
|
end
|
85
85
|
|
@@ -91,7 +91,7 @@ module Wavefront
|
|
91
91
|
#
|
92
92
|
def history(id)
|
93
93
|
wf_dashboard_id?(id)
|
94
|
-
|
94
|
+
api.get([id, 'history'].uri_concat)
|
95
95
|
end
|
96
96
|
|
97
97
|
# GET /api/v2/dashboard/id/tag
|
@@ -102,7 +102,7 @@ module Wavefront
|
|
102
102
|
#
|
103
103
|
def tags(id)
|
104
104
|
wf_dashboard_id?(id)
|
105
|
-
|
105
|
+
api.get([id, 'tag'].uri_concat)
|
106
106
|
end
|
107
107
|
|
108
108
|
# POST /api/v2/dashboard/id/tag
|
@@ -116,7 +116,7 @@ module Wavefront
|
|
116
116
|
wf_dashboard_id?(id)
|
117
117
|
tags = Array(tags)
|
118
118
|
tags.each { |t| wf_string?(t) }
|
119
|
-
|
119
|
+
api.post([id, 'tag'].uri_concat, tags.to_json, 'application/json')
|
120
120
|
end
|
121
121
|
|
122
122
|
# DELETE /api/v2/dashboard/id/tag/tagValue
|
@@ -129,7 +129,7 @@ module Wavefront
|
|
129
129
|
def tag_delete(id, tag)
|
130
130
|
wf_dashboard_id?(id)
|
131
131
|
wf_string?(tag)
|
132
|
-
|
132
|
+
api.delete([id, 'tag', tag].uri_concat)
|
133
133
|
end
|
134
134
|
|
135
135
|
# PUT /api/v2/dashboard/id/tag/tagValue
|
@@ -142,7 +142,7 @@ module Wavefront
|
|
142
142
|
def tag_add(id, tag)
|
143
143
|
wf_dashboard_id?(id)
|
144
144
|
wf_string?(tag)
|
145
|
-
|
145
|
+
api.put([id, 'tag', tag].uri_concat)
|
146
146
|
end
|
147
147
|
|
148
148
|
# POST /api/v2/dashboard/id/undelete
|
@@ -153,7 +153,7 @@ module Wavefront
|
|
153
153
|
#
|
154
154
|
def undelete(id)
|
155
155
|
wf_dashboard_id?(id)
|
156
|
-
|
156
|
+
api.post([id, 'undelete'].uri_concat)
|
157
157
|
end
|
158
158
|
end
|
159
159
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
WF_SDK_VERSION = '2.0.0'.freeze
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'core/api'
|
2
2
|
|
3
3
|
module Wavefront
|
4
4
|
#
|
5
5
|
# View and manage derived metrics
|
6
6
|
#
|
7
|
-
class DerivedMetric <
|
7
|
+
class DerivedMetric < CoreApi
|
8
8
|
def update_keys
|
9
9
|
# %i[id name url description sections]
|
10
10
|
end
|
@@ -17,7 +17,7 @@ module Wavefront
|
|
17
17
|
# @return [Wavefront::Response]
|
18
18
|
#
|
19
19
|
def list(offset = 0, limit = 100)
|
20
|
-
|
20
|
+
api.get('', offset: offset, limit: limit)
|
21
21
|
end
|
22
22
|
|
23
23
|
# POST /api/v2/derivedmetric
|
@@ -29,7 +29,7 @@ module Wavefront
|
|
29
29
|
#
|
30
30
|
def create(body)
|
31
31
|
raise ArgumentError unless body.is_a?(Hash)
|
32
|
-
|
32
|
+
api.post('', body, 'application/json')
|
33
33
|
end
|
34
34
|
|
35
35
|
# DELETE /api/v2/derivedmetric/id
|
@@ -43,7 +43,7 @@ module Wavefront
|
|
43
43
|
#
|
44
44
|
def delete(id)
|
45
45
|
wf_derivedmetric_id?(id)
|
46
|
-
|
46
|
+
api.delete(id)
|
47
47
|
end
|
48
48
|
|
49
49
|
# GET /api/v2/derivedmetric/id
|
@@ -59,7 +59,7 @@ module Wavefront
|
|
59
59
|
wf_version?(version) if version
|
60
60
|
fragments = [id]
|
61
61
|
fragments += ['history', version] if version
|
62
|
-
|
62
|
+
api.get(fragments.uri_concat)
|
63
63
|
end
|
64
64
|
|
65
65
|
# PUT /api/v2/derivedmetric/id
|
@@ -77,9 +77,9 @@ module Wavefront
|
|
77
77
|
wf_derivedmetric_id?(id)
|
78
78
|
raise ArgumentError unless body.is_a?(Hash)
|
79
79
|
|
80
|
-
return
|
80
|
+
return api.put(id, body, 'application/json') unless modify
|
81
81
|
|
82
|
-
|
82
|
+
api.put(id, hash_for_update(describe(id).response, body),
|
83
83
|
'application/json')
|
84
84
|
end
|
85
85
|
|
@@ -91,7 +91,7 @@ module Wavefront
|
|
91
91
|
#
|
92
92
|
def history(id)
|
93
93
|
wf_derivedmetric_id?(id)
|
94
|
-
|
94
|
+
api.get([id, 'history'].uri_concat)
|
95
95
|
end
|
96
96
|
|
97
97
|
# GET /api/v2/derivedmetric/id/tag
|
@@ -103,7 +103,7 @@ module Wavefront
|
|
103
103
|
#
|
104
104
|
def tags(id)
|
105
105
|
wf_derivedmetric_id?(id)
|
106
|
-
|
106
|
+
api.get([id, 'tag'].uri_concat)
|
107
107
|
end
|
108
108
|
|
109
109
|
# POST /api/v2/derivedmetric/id/tag
|
@@ -118,7 +118,7 @@ module Wavefront
|
|
118
118
|
wf_derivedmetric_id?(id)
|
119
119
|
tags = Array(tags)
|
120
120
|
tags.each { |t| wf_string?(t) }
|
121
|
-
|
121
|
+
api.post([id, 'tag'].uri_concat, tags.to_json, 'application/json')
|
122
122
|
end
|
123
123
|
|
124
124
|
# DELETE /api/v2/derivedmetric/id/tag/tagValue
|
@@ -131,7 +131,7 @@ module Wavefront
|
|
131
131
|
def tag_delete(id, tag)
|
132
132
|
wf_derivedmetric_id?(id)
|
133
133
|
wf_string?(tag)
|
134
|
-
|
134
|
+
api.delete([id, 'tag', tag].uri_concat)
|
135
135
|
end
|
136
136
|
|
137
137
|
# PUT /api/v2/derivedmetric/id/tag/tagValue
|
@@ -144,7 +144,7 @@ module Wavefront
|
|
144
144
|
def tag_add(id, tag)
|
145
145
|
wf_derivedmetric_id?(id)
|
146
146
|
wf_string?(tag)
|
147
|
-
|
147
|
+
api.put([id, 'tag', tag].uri_concat)
|
148
148
|
end
|
149
149
|
|
150
150
|
# POST /api/v2/derivedmetric/id/undelete
|
@@ -156,7 +156,7 @@ module Wavefront
|
|
156
156
|
#
|
157
157
|
def undelete(id)
|
158
158
|
wf_derivedmetric_id?(id)
|
159
|
-
|
159
|
+
api.post([id, 'undelete'].uri_concat)
|
160
160
|
end
|
161
161
|
end
|
162
162
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require_relative 'write'
|
2
|
+
require_relative 'support/mixins'
|
3
|
+
|
4
|
+
module Wavefront
|
5
|
+
#
|
6
|
+
# Help a user write histogram distributions to a Wavefront proxy
|
7
|
+
#
|
8
|
+
class Distribution < Write
|
9
|
+
include Wavefront::Mixins
|
10
|
+
|
11
|
+
# Make a distribution from a lot of numbers. The returned
|
12
|
+
# distribution is an array of arrays ready for dropping into
|
13
|
+
# #write. If you need a "real" Wavefront representation of the
|
14
|
+
# distribution, use #mk_wf_distribution.
|
15
|
+
# @param args [String, Array] numbers. Can be multiple
|
16
|
+
# arguments, a whitespace-separated string, or one or more
|
17
|
+
# arrays.
|
18
|
+
# @return [Array[Array]] of the form [[1, 3], [4, 5]...]
|
19
|
+
#
|
20
|
+
def mk_distribution(*args)
|
21
|
+
flat = args.flatten
|
22
|
+
raw = flat.first.is_a?(String) ? flat.first.split : flat
|
23
|
+
|
24
|
+
hash = raw.each_with_object(Hash.new(0)) do |v, sum|
|
25
|
+
sum[v] += 1
|
26
|
+
sum
|
27
|
+
end
|
28
|
+
|
29
|
+
hash.to_a.map { |a, b| [b, a.to_f] }
|
30
|
+
end
|
31
|
+
|
32
|
+
def mk_wf_distribution(*args)
|
33
|
+
array2dist(mk_distribution(args))
|
34
|
+
end
|
35
|
+
|
36
|
+
def validation
|
37
|
+
:wf_distribution?
|
38
|
+
end
|
39
|
+
|
40
|
+
def default_port
|
41
|
+
40000
|
42
|
+
end
|
43
|
+
|
44
|
+
# Convert a validated point to a string conforming to
|
45
|
+
# https://docs.wavefront.com/proxies_histograms.html. No
|
46
|
+
# validation is done here.
|
47
|
+
#
|
48
|
+
# @param point [Hash] a hash describing a distribution. See
|
49
|
+
# #write() for the format.
|
50
|
+
#
|
51
|
+
# rubocop:disable Metrics/AbcSize
|
52
|
+
def hash_to_wf(dist)
|
53
|
+
logger.log("writer subclass #{writer}", :debug)
|
54
|
+
format('!%s %i %s %s source=%s %s %s',
|
55
|
+
dist[:interval].to_s.upcase || raise,
|
56
|
+
parse_time(dist.fetch(:ts, Time.now)),
|
57
|
+
array2dist(dist[:value]),
|
58
|
+
dist[:path] || raise,
|
59
|
+
dist.fetch(:source, HOSTNAME),
|
60
|
+
dist[:tags] && dist[:tags].to_wf_tag,
|
61
|
+
opts[:tags] && opts[:tags].to_wf_tag).squeeze(' ').strip
|
62
|
+
rescue StandardError => e
|
63
|
+
puts e
|
64
|
+
raise Wavefront::Exception::InvalidDistribution
|
65
|
+
end
|
66
|
+
# rubocop:enable Metrics/AbcSize
|
67
|
+
|
68
|
+
# Turn an array of arrays into a the values part of a distribution
|
69
|
+
# @return [String]
|
70
|
+
#
|
71
|
+
def array2dist(values)
|
72
|
+
values.map { |x, v| format('#%i %s', x, v) }.join(' ')
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/wavefront-sdk/event.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'core/api'
|
2
2
|
|
3
3
|
module Wavefront
|
4
4
|
#
|
5
5
|
# View and manage events. Events are identified by their millisecond
|
6
6
|
# epoch timestamp.
|
7
7
|
#
|
8
|
-
class Event <
|
8
|
+
class Event < CoreApi
|
9
9
|
def update_keys
|
10
10
|
%i[startTime endTime name annotations]
|
11
11
|
end
|
@@ -38,7 +38,7 @@ module Wavefront
|
|
38
38
|
cursor: cursor,
|
39
39
|
limit: limit }
|
40
40
|
|
41
|
-
|
41
|
+
api.get('', body.cleanse)
|
42
42
|
end
|
43
43
|
|
44
44
|
# POST /api/v2/event
|
@@ -53,7 +53,7 @@ module Wavefront
|
|
53
53
|
#
|
54
54
|
def create(body)
|
55
55
|
raise ArgumentError unless body.is_a?(Hash)
|
56
|
-
|
56
|
+
api.post('', body, 'application/json')
|
57
57
|
end
|
58
58
|
|
59
59
|
# DELETE /api/v2/event/id
|
@@ -64,7 +64,7 @@ module Wavefront
|
|
64
64
|
#
|
65
65
|
def delete(id)
|
66
66
|
wf_event_id?(id)
|
67
|
-
|
67
|
+
api.delete(id)
|
68
68
|
end
|
69
69
|
|
70
70
|
# GET /api/v2/event/id
|
@@ -80,7 +80,7 @@ module Wavefront
|
|
80
80
|
wf_version?(version) if version
|
81
81
|
fragments = [id]
|
82
82
|
fragments += ['history', version] if version
|
83
|
-
|
83
|
+
api.get(fragments.uri_concat)
|
84
84
|
end
|
85
85
|
|
86
86
|
# PUT /api/v2/event/id
|
@@ -100,9 +100,9 @@ module Wavefront
|
|
100
100
|
wf_event_id?(id)
|
101
101
|
raise ArgumentError unless body.is_a?(Hash)
|
102
102
|
|
103
|
-
return
|
103
|
+
return api.put(id, body, 'application/json') unless modify
|
104
104
|
|
105
|
-
|
105
|
+
api.put(id, hash_for_update(describe(id), body), 'application/json')
|
106
106
|
end
|
107
107
|
|
108
108
|
# POST /api/v2/event/id/close
|
@@ -112,7 +112,7 @@ module Wavefront
|
|
112
112
|
#
|
113
113
|
def close(id)
|
114
114
|
wf_event_id?(id)
|
115
|
-
|
115
|
+
api.post([id, 'close'].uri_concat)
|
116
116
|
end
|
117
117
|
|
118
118
|
# GET /api/v2/event/id/tag
|
@@ -124,7 +124,7 @@ module Wavefront
|
|
124
124
|
#
|
125
125
|
def tags(id)
|
126
126
|
wf_event_id?(id)
|
127
|
-
|
127
|
+
api.get([id, 'tag'].uri_concat)
|
128
128
|
end
|
129
129
|
|
130
130
|
# POST /api/v2/event/id/tag
|
@@ -139,7 +139,7 @@ module Wavefront
|
|
139
139
|
wf_event_id?(id)
|
140
140
|
tags = Array(tags)
|
141
141
|
tags.each { |t| wf_string?(t) }
|
142
|
-
|
142
|
+
api.post([id, 'tag'].uri_concat, tags, 'application/json')
|
143
143
|
end
|
144
144
|
|
145
145
|
# DELETE /api/v2/event/id/tag/tagValue
|
@@ -152,7 +152,7 @@ module Wavefront
|
|
152
152
|
def tag_delete(id, tag)
|
153
153
|
wf_event_id?(id)
|
154
154
|
wf_string?(tag)
|
155
|
-
|
155
|
+
api.delete([id, 'tag', tag].uri_concat)
|
156
156
|
end
|
157
157
|
|
158
158
|
# PUT /api/v2/event/id/tag/tagValue
|
@@ -165,7 +165,7 @@ module Wavefront
|
|
165
165
|
def tag_add(id, tag)
|
166
166
|
wf_event_id?(id)
|
167
167
|
wf_string?(tag)
|
168
|
-
|
168
|
+
api.put([id, 'tag', tag].uri_concat)
|
169
169
|
end
|
170
170
|
end
|
171
171
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'core/api'
|
2
2
|
|
3
3
|
module Wavefront
|
4
4
|
#
|
5
5
|
# Manage and query Wavefront external links.
|
6
6
|
#
|
7
|
-
class ExternalLink <
|
7
|
+
class ExternalLink < CoreApi
|
8
8
|
def api_base
|
9
9
|
'/extlink'
|
10
10
|
end
|
@@ -21,7 +21,7 @@ module Wavefront
|
|
21
21
|
# @param limit [Int] the number of link to return
|
22
22
|
#
|
23
23
|
def list(offset = 0, limit = 100)
|
24
|
-
|
24
|
+
api.get('', offset: offset, limit: limit)
|
25
25
|
end
|
26
26
|
|
27
27
|
# POST /api/v2/extlink
|
@@ -32,7 +32,7 @@ module Wavefront
|
|
32
32
|
#
|
33
33
|
def create(body)
|
34
34
|
raise ArgumentError unless body.is_a?(Hash)
|
35
|
-
|
35
|
+
api.post('', body, 'application/json')
|
36
36
|
end
|
37
37
|
|
38
38
|
# DELETE /api/v2/extlink/id
|
@@ -43,7 +43,7 @@ module Wavefront
|
|
43
43
|
#
|
44
44
|
def delete(id)
|
45
45
|
wf_link_id?(id)
|
46
|
-
|
46
|
+
api.delete(id)
|
47
47
|
end
|
48
48
|
|
49
49
|
# GET /api/v2/extlink/id
|
@@ -54,7 +54,7 @@ module Wavefront
|
|
54
54
|
#
|
55
55
|
def describe(id)
|
56
56
|
wf_link_id?(id)
|
57
|
-
|
57
|
+
api.get(id)
|
58
58
|
end
|
59
59
|
|
60
60
|
# PUT /api/v2/extlink/id
|
@@ -72,9 +72,9 @@ module Wavefront
|
|
72
72
|
wf_link_id?(id)
|
73
73
|
raise ArgumentError unless body.is_a?(Hash)
|
74
74
|
|
75
|
-
return
|
75
|
+
return api.put(id, body, 'application/json') unless modify
|
76
76
|
|
77
|
-
|
77
|
+
api.put(id, hash_for_update(describe(id).response, body),
|
78
78
|
'application/json')
|
79
79
|
end
|
80
80
|
end
|