wavefront-sdk 1.0.3 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c09b458b9e9921e9a33d3478fffd60c9428239f
4
- data.tar.gz: 7b2d2bceb5c45fec4c221b62569d7bd089737fe2
3
+ metadata.gz: 2002dacfb813974ef1b2450b4843142bc399d472
4
+ data.tar.gz: 6b6f2ec545568e1ae155b98c9ecf0b6d8b7e6737
5
5
  SHA512:
6
- metadata.gz: 5a616119c5be2f0c074410156240a8647e37dac522193d52e84a3496d38360cb040649cfac4b028732e2b24f835fbaa03be7aadf074b45c61adcf602ca4048fc
7
- data.tar.gz: 5a80bc97dbdbb236208462bb337914f2fe0e899ec5046d8e44ec440b13ff7e657707a5c08cfcb5adaff759448863aa8daff07dd86ec5ac4f40b55e3fcadcf7ad
6
+ metadata.gz: 7f36ed4ec001d74f134c5e9b893cc11e9f71872b885960ceb5da87d7d8915c5b63dbc362604d599f768efa826ea6efa63a17802a8f1bea4ce254fd41184620ae
7
+ data.tar.gz: 1641bf8dadb681d1401c332136fc7dd139379fb65c890e40f5deeee129de973c7f97a19587cdf31285d78c7a76e8d0ae89d4296de180fdf1b91dd70e1be713a3
data/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
  [![Build Status](https://travis-ci.org/snltd/wavefront-sdk.svg?branch=master)](https://travis-ci.org/snltd/wavefront-sdk) [![Code Climate](https://codeclimate.com/github/snltd/wavefront-sdk/badges/gpa.svg)](https://codeclimate.com/github/snltd/wavefront-sdk) [![Issue Count](https://codeclimate.com/github/snltd/wavefront-sdk/badges/issue_count.svg)](https://codeclimate.com/github/snltd/wavefront-sdk) [![Dependency Status](https://gemnasium.com/badges/github.com/snltd/wavefront-sdk.svg)](https://gemnasium.com/github.com/snltd/wavefront-sdk) [![Gem Version](https://badge.fury.io/rb/wavefront-sdk.svg)](https://badge.fury.io/rb/wavefront-sdk) ![](http://ruby-gem-downloads-badge.herokuapp.com/wavefront-sdk?type=total)
3
3
 
4
4
  This is a Ruby SDK for v2 of
5
- [Wavefront](https://www.wavefront.com/)'s public API. It supports Ruby
6
- >= 2.2. It aims to be more lightweight, consistent, simple, and
5
+ [Wavefront](https://www.wavefront.com/)'s public API. It supports
6
+ Ruby >= 2.2. It aims to be more lightweight, consistent, simple, and
7
7
  convenient than an auto-generated SDK.
8
8
 
9
9
  ## Installation
@@ -13,10 +13,12 @@ module Wavefront
13
13
  class InvalidExternalLinkId < ::Exception; end
14
14
  class InvalidGranularity < ::Exception; end
15
15
  class InvalidHostname < ::Exception; end
16
+ class InvalidIntegrationId < ::Exception; end
16
17
  class InvalidMaintenanceWindowId < ::Exception; end
17
18
  class InvalidMessageId < ::Exception; end
18
19
  class InvalidMetricName < ::Exception; end
19
20
  class InvalidMetricValue < ::Exception; end
21
+ class InvalidNotificantId < ::Exception; end
20
22
  class InvalidName < ::Exception; end
21
23
  class InvalidPoint < ::Exception; end
22
24
  class InvalidPrefixLength < ::Exception; end
@@ -0,0 +1,82 @@
1
+ require_relative './base'
2
+
3
+ module Wavefront
4
+ #
5
+ # Manage and query Wavefront integrations.
6
+ #
7
+ class Integration < Base
8
+
9
+ # GET /api/v2/integration
10
+ # Gets a flat list of all Wavefront integrations available,
11
+ # along with their status
12
+ #
13
+ # @param offset [Int] proxy at which the list begins
14
+ # @param limit [Int] the number of proxies to return
15
+ #
16
+ def list(offset = 0, limit = 100)
17
+ api_get('', { offset: offset, limit: limit })
18
+ end
19
+
20
+ # GET /api/v2/integration/id
21
+ # Gets a single Wavefront integration by its id, along with its
22
+ # status
23
+ #
24
+ # @param id [String] ID of the proxy
25
+ # @return [Wavefront::Response]
26
+ #
27
+ def describe(id)
28
+ wf_integration_id?(id)
29
+ api_get(id)
30
+ end
31
+
32
+ # POST /api/v2/integration/id/install
33
+ # Installs a Wavefront integration
34
+ #
35
+ # @param id [String] ID of the integration
36
+ # @return [Wavefront::Response]
37
+ #
38
+ def install(id)
39
+ wf_integration_id?(id)
40
+ api_post([id, 'install'].uri_concat, nil)
41
+ end
42
+
43
+ # POST /api/v2/integration/id/uninstall
44
+ # Uninstalls a Wavefront integration
45
+ #
46
+ # @param id [String] ID of the integration
47
+ # @return [Wavefront::Response]
48
+ #
49
+ def uninstall(id)
50
+ wf_integration_id?(id)
51
+ api_post([id, 'uninstall'].uri_concat, nil)
52
+ end
53
+
54
+ # GET /api/v2/integration/id/status
55
+ # Gets the status of a single Wavefront integration
56
+ #
57
+ # @param id [String] ID of the integration
58
+ # @return [Wavefront::Response]
59
+ #
60
+ def status(id)
61
+ wf_integration_id?(id)
62
+ api_get([id, 'status'].uri_concat)
63
+ end
64
+
65
+ # GET /api/v2/integration/status
66
+ # Gets the status of all Wavefront integrations
67
+ #
68
+ # @return [Wavefront::Response]
69
+ #
70
+ def statuses
71
+ api_get('status')
72
+ end
73
+
74
+ # GET /api/v2/integration/manifests
75
+ # Gets all Wavefront integrations as structured in their
76
+ # integration manifests, along with their status
77
+ #
78
+ def manifests
79
+ api_get('manifests')
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,84 @@
1
+ require_relative './base'
2
+
3
+ module Wavefront
4
+ #
5
+ # Manage and query Wavefront notification targets.
6
+ #
7
+ class Notificant < Base
8
+
9
+ # GET /api/v2/notificant
10
+ # Get all notification targets for a customer
11
+ #
12
+ # @param offset [Int] notificant at which the list begins
13
+ # @param limit [Int] the number of notification targets to return
14
+ #
15
+ def list(offset = 0, limit = 100)
16
+ api_get('', { offset: offset, limit: limit })
17
+ end
18
+
19
+ # POST /api/v2/notificant
20
+ # Create a notification target.
21
+ #
22
+ # @param body [Hash] description of notification target
23
+ # @return [Wavefront::Response]
24
+ #
25
+ def create(body)
26
+ raise ArgumentError unless body.is_a?(Hash)
27
+ api_post('', body, 'application/json')
28
+ end
29
+
30
+ # DELETE /api/v2/notificant/id
31
+ # Delete a specific notificant
32
+ #
33
+ # @param id [String] ID of the notification target
34
+ # @return [Wavefront::Response]
35
+ #
36
+ def delete(id)
37
+ wf_notificant_id?(id)
38
+ api_delete(id)
39
+ end
40
+
41
+ # GET /api/v2/notificant/id
42
+ # Get a specific notification target
43
+ #
44
+ # @param id [String] ID of the notification target
45
+ # @return [Wavefront::Response]
46
+ #
47
+ def describe(id)
48
+ wf_notificant_id?(id)
49
+ api_get(id)
50
+ end
51
+
52
+ # PUT /api/v2/notificant/id
53
+ # Update a specific notification target
54
+ #
55
+ # @param id [String] a Wavefront notification target ID
56
+ # @param body [Hash] key-value hash of the parameters you wish
57
+ # to change
58
+ # @param modify [true, false] if true, use {#describe()} to get
59
+ # a hash describing the existing object, and modify that with
60
+ # the new body. If false, pass the new body straight through.
61
+ # @return [Wavefront::Response]
62
+
63
+ def update(id, body, modify = true)
64
+ wf_notificant_id?(id)
65
+ raise ArgumentError unless body.is_a?(Hash)
66
+
67
+ return api_put(id, body, 'application/json') unless modify
68
+
69
+ api_put(id, hash_for_update(describe(id).response, body),
70
+ 'application/json')
71
+ end
72
+
73
+ # POST /api/v2/notificant/test/id
74
+ # Create a notification target.
75
+ #
76
+ # @param body [Hash] description of notification target
77
+ # @return [Wavefront::Response]
78
+ #
79
+ def test(id)
80
+ wf_notificant_id?(id)
81
+ api_post(['test', id].uri_concat, nil)
82
+ end
83
+ end
84
+ end
@@ -48,6 +48,23 @@ module Wavefront
48
48
  api_delete(id)
49
49
  end
50
50
 
51
+ # POST /api/v2/source/id/description
52
+ # Set description associated with a specific source
53
+
54
+ def description_set(id, description)
55
+ wf_source_id?(id)
56
+ api_post([id, 'description'].uri_concat, description,
57
+ 'application/json')
58
+ end
59
+
60
+ # DELETE /api/v2/source/id/description
61
+ # Remove description from a specific source
62
+
63
+ def description_delete(id)
64
+ wf_source_id?(id)
65
+ api_delete([id, 'description'].uri_concat)
66
+ end
67
+
51
68
  # GET /api/v2/source/id
52
69
  # Get a specific source for a customer.
53
70
  #
@@ -391,5 +391,31 @@ module Wavefront
391
391
  wf_point_tags?(v[:tags]) if v[:tags]
392
392
  true
393
393
  end
394
+
395
+ # Ensure the given argument is a valid Wavefront
396
+ # notificant ID.
397
+ #
398
+ # @param v [String] the notificant name to validate
399
+ # @return True if the notificant name is valid
400
+ # @raise Wavefront::Exception::InvalidNotificantId if the
401
+ # notificant ID is not valid
402
+ #
403
+ def wf_notificant_id?(v)
404
+ return true if v.is_a?(String) && v =~ /^\w{16}$/
405
+ raise Wavefront::Exception::InvalidNotificantId
406
+ end
407
+
408
+ # Ensure the given argument is a valid Wavefront
409
+ # integration ID. These appear to be lower-case strings.
410
+ #
411
+ # @param v [String] the integration name to validate
412
+ # @return True if the integration name is valid
413
+ # @raise Wavefront::Exception::InvalidIntegrationId if the
414
+ # integration ID is not valid
415
+ #
416
+ def wf_integration_id?(v)
417
+ return true if v.is_a?(String) && v =~ /^[a-z0-9]+$/
418
+ raise Wavefront::Exception::InvalidIntegrationId
419
+ end
394
420
  end
395
421
  end
@@ -1 +1 @@
1
- WF_SDK_VERSION = '1.0.3'.freeze
1
+ WF_SDK_VERSION = '1.1.0'.freeze
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../spec_helper'
4
+
5
+ INTEGRATION = 'tester'.freeze
6
+
7
+ # Unit tests for Integration class
8
+ #
9
+ class WavefrontIntegrationTest < WavefrontTestBase
10
+ def test_list
11
+ should_work(:list, 10, '?offset=10&limit=100')
12
+ end
13
+
14
+ def test_install
15
+ should_work(:install, INTEGRATION, ["#{INTEGRATION}/install", nil],
16
+ :post, POST_HEADERS)
17
+ should_be_invalid(:install)
18
+ assert_raises(ArgumentError) { wf.install }
19
+ end
20
+
21
+ def test_uninstall
22
+ should_work(:uninstall, INTEGRATION, ["#{INTEGRATION}/uninstall", nil],
23
+ :post, POST_HEADERS)
24
+ should_be_invalid(:uninstall)
25
+ assert_raises(ArgumentError) { wf.uninstall }
26
+ end
27
+
28
+ def test_describe
29
+ should_work(:describe, INTEGRATION, INTEGRATION)
30
+ should_be_invalid(:describe)
31
+ assert_raises(ArgumentError) { wf.describe }
32
+ end
33
+
34
+ def test_status
35
+ should_work(:status, INTEGRATION, "#{INTEGRATION}/status")
36
+ should_be_invalid(:status)
37
+ assert_raises(ArgumentError) { wf.status }
38
+ end
39
+
40
+ def test_manifests
41
+ should_work(:manifests, nil, 'manifests')
42
+ end
43
+
44
+ def test_statuses
45
+ should_work(:statuses, nil, 'status')
46
+ end
47
+ end
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../spec_helper'
4
+
5
+ NOTIFICANT = '8Bl5l7wxtdGindxk'.freeze
6
+
7
+ # Unit tests for notificant class
8
+ #
9
+ class WavefrontNotificantTest < WavefrontTestBase
10
+ def test_list
11
+ should_work(:list, 10, '?offset=10&limit=100')
12
+ end
13
+
14
+ def test_describe
15
+ should_work(:describe, NOTIFICANT, NOTIFICANT)
16
+ should_be_invalid(:describe)
17
+ assert_raises(ArgumentError) { wf.describe }
18
+ end
19
+
20
+ def test_delete
21
+ should_work(:delete, NOTIFICANT, NOTIFICANT, :delete)
22
+ should_be_invalid('delete')
23
+ end
24
+
25
+ def test_test
26
+ should_work(:test, NOTIFICANT, ["test/#{NOTIFICANT}", nil],
27
+ :post, POST_HEADERS)
28
+ should_be_invalid('test')
29
+ end
30
+ end
@@ -243,4 +243,14 @@ class WavefrontValidatorsTest < MiniTest::Test
243
243
  wf_point?(bad)
244
244
  end
245
245
  end
246
+
247
+ def test_notificant_id
248
+ good = %w(CHTo47HvsPzSaGhh)
249
+ bad = ['CTo47HvsPzSaGhh', [], {}, nil, 'bad id']
250
+ end
251
+
252
+ def test_integration_id
253
+ good = %w(aws tutorial elasticsearch cassandra go)
254
+ bad = ['CTo47HvsPzSaGhh', [], {}, nil, 'bad id']
255
+ end
246
256
  end
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.0.3
4
+ version: 1.1.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: 2017-09-20 00:00:00.000000000 Z
11
+ date: 2017-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -192,10 +192,12 @@ files:
192
192
  - lib/wavefront-sdk/event.rb
193
193
  - lib/wavefront-sdk/exception.rb
194
194
  - lib/wavefront-sdk/externallink.rb
195
+ - lib/wavefront-sdk/integration.rb
195
196
  - lib/wavefront-sdk/maintenancewindow.rb
196
197
  - lib/wavefront-sdk/message.rb
197
198
  - lib/wavefront-sdk/metric.rb
198
199
  - lib/wavefront-sdk/mixins.rb
200
+ - lib/wavefront-sdk/notificant.rb
199
201
  - lib/wavefront-sdk/proxy.rb
200
202
  - lib/wavefront-sdk/query.rb
201
203
  - lib/wavefront-sdk/response.rb
@@ -217,10 +219,12 @@ files:
217
219
  - spec/wavefront-sdk/dashboard_spec.rb
218
220
  - spec/wavefront-sdk/event_spec.rb
219
221
  - spec/wavefront-sdk/externallink_spec.rb
222
+ - spec/wavefront-sdk/integration_spec.rb
220
223
  - spec/wavefront-sdk/maintenancewindow_spec.rb
221
224
  - spec/wavefront-sdk/message_spec.rb
222
225
  - spec/wavefront-sdk/metric_spec.rb
223
226
  - spec/wavefront-sdk/mixins_spec.rb
227
+ - spec/wavefront-sdk/notificant_spec.rb
224
228
  - spec/wavefront-sdk/proxy_spec.rb
225
229
  - spec/wavefront-sdk/query_spec.rb
226
230
  - spec/wavefront-sdk/resources/test.conf
@@ -267,10 +271,12 @@ test_files:
267
271
  - spec/wavefront-sdk/dashboard_spec.rb
268
272
  - spec/wavefront-sdk/event_spec.rb
269
273
  - spec/wavefront-sdk/externallink_spec.rb
274
+ - spec/wavefront-sdk/integration_spec.rb
270
275
  - spec/wavefront-sdk/maintenancewindow_spec.rb
271
276
  - spec/wavefront-sdk/message_spec.rb
272
277
  - spec/wavefront-sdk/metric_spec.rb
273
278
  - spec/wavefront-sdk/mixins_spec.rb
279
+ - spec/wavefront-sdk/notificant_spec.rb
274
280
  - spec/wavefront-sdk/proxy_spec.rb
275
281
  - spec/wavefront-sdk/query_spec.rb
276
282
  - spec/wavefront-sdk/resources/test.conf