wavefront-cli 3.1.4 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a1d06ffcd9e35ee8533ad1f02a13de47b8e9cd8a68f77382da1b3fb672c7b15
4
- data.tar.gz: 6a20be8bb474cb3b981c641f9c0667a5e7fd4a0b3bc4e3c7a80872fb6019e40f
3
+ metadata.gz: d8904f27867cfabaaaf9c47132f52a439fa5fdef900745986789c901a0f61ef0
4
+ data.tar.gz: f30e315802c139c36f53c7d9e462e7b684bac5ab0ddebbead90210edbe317385
5
5
  SHA512:
6
- metadata.gz: 5ce5c22835ae09b59dcaf3153d54540f9b9548a213344934bedebf030ae80e3a5eb2be35684de13509558b0889570217f162b396304ae92aeaa043bdc261cbbc
7
- data.tar.gz: d28b8c665f5d911090acef88922e4157766deb5f90554c7d4f5a19bf0a81c1d5f9f754e5e866e5382b127becf0ef2ea48fb233435b01c030711a028ff411f52e
6
+ metadata.gz: 9fbc2243bf64547d80d6082c1e0c6308dfd1327d112b67897afaf98b715841aed1323bf2aa3394656eb357c17404354c80e315e26d641c30289a2466fc0dce93
7
+ data.tar.gz: 21808c3a636e72bbcf056fad0572e96d313f2e87823e9c04d88fc5934ac308686f1cb1f7a96306cef81ae61a4a65453228265a1d4eff6636a46d9081485ef6e2
data/HISTORY.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.2.0 (30/04/2019)
4
+ * New `apitoken` command lets you manage your own API tokens.
5
+ * Require 3.2.0 of [the SDK](https://github.com/snltd/wavefront-sdk).
6
+
3
7
  ## 3.1.4 (02/05/2019)
4
8
  * Fix `alert import` missing tags bug.
5
- * Add import and notificants.
9
+ * Allow importing of notificants.
6
10
 
7
11
  ## 3.1.3 (24/04/2019)
8
12
  * Fix `write distribution` bug. Points would be sent, but results
data/README.md CHANGED
@@ -31,6 +31,7 @@ Usage:
31
31
 
32
32
  Commands:
33
33
  alert view and manage alerts
34
+ apitoken view and manage API tokens
34
35
  cloudintegration view and manage cloud integrations
35
36
  config create and manage local configuration
36
37
  dashboard view and manage dashboards
@@ -44,6 +45,7 @@ Commands:
44
45
  proxy view and manage Wavefront proxies
45
46
  query query the Wavefront API
46
47
  savedsearch view and manage saved searches
48
+ settings view and manage system preferences
47
49
  source view and manage source tags and descriptions
48
50
  user view and manage Wavefront users
49
51
  usergroup view and manage Wavefront user groups
@@ -0,0 +1,24 @@
1
+ require_relative 'base'
2
+
3
+ module WavefrontCli
4
+ #
5
+ # CLI coverage for the v2 'derivedmetric' API.
6
+ #
7
+ class ApiToken < WavefrontCli::Base
8
+ def validator_exception
9
+ Wavefront::Exception::InvalidApiTokenId
10
+ end
11
+
12
+ def do_list
13
+ wf.list
14
+ end
15
+
16
+ def do_create
17
+ wf.create
18
+ end
19
+
20
+ def do_rename
21
+ wf.rename(options[:'<id>'], options[:'<name>'])
22
+ end
23
+ end
24
+ end
@@ -233,6 +233,11 @@ module WavefrontCli
233
233
  # @return System exit
234
234
  #
235
235
  def display_api_error(status)
236
+ if status.code == 404
237
+ abort 'API path not found. Perhaps your account does not ' \
238
+ 'support this feature.'
239
+ end
240
+
236
241
  msg = status.message || 'No further information'
237
242
  abort format('ERROR: API code %s: %s.', status.code, msg.chomp('.'))
238
243
  end
@@ -0,0 +1,31 @@
1
+ require_relative 'base'
2
+
3
+ # Define the apitoken command.
4
+ #
5
+ class WavefrontCommandApitoken < WavefrontCommandBase
6
+ def description
7
+ 'view and manage API tokens'
8
+ end
9
+
10
+ def sdk_file
11
+ 'apitoken'
12
+ end
13
+
14
+ def sdk_class
15
+ 'ApiToken'
16
+ end
17
+
18
+ def _commands
19
+ ["list #{CMN} [-O fields]",
20
+ "create #{CMN}",
21
+ "delete #{CMN} <id>",
22
+ "rename #{CMN} <id> <name>",
23
+ tag_commands]
24
+ end
25
+
26
+ def _options
27
+ [common_options,
28
+ '-O, --fields=F1,F2,... only show given fields',
29
+ '-f, --format=STRING output format']
30
+ end
31
+ end
@@ -149,7 +149,6 @@ class WavefrontCliController
149
149
  # rubocop:enable Metrics/MethodLength
150
150
  # rubocop:enable Metrics/AbcSize
151
151
 
152
- #
153
152
  # @param error [WavefrontCli::Exception::CredentialError]
154
153
  #
155
154
  def handle_missing_credentials(error)
@@ -0,0 +1,16 @@
1
+ require_relative 'base'
2
+
3
+ module WavefrontDisplay
4
+ #
5
+ # Format human-readable output for API token commands
6
+ #
7
+ class ApiToken < Base
8
+ def do_list_brief
9
+ multicolumn(:tokenID, :tokenName)
10
+ end
11
+
12
+ def do_create
13
+ puts data.last[:tokenID]
14
+ end
15
+ end
16
+ end
@@ -1 +1 @@
1
- WF_CLI_VERSION = '3.1.4'.freeze
1
+ WF_CLI_VERSION = '3.2.0'.freeze
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ word = 'apitoken'
4
+
5
+ require_relative '../spec_helper'
6
+ require_relative "../../lib/wavefront-cli/#{word}"
7
+
8
+ id = '17db4cc1-65f6-40a8-a1fa-6fcae460c4bd'
9
+ bad_id = 'bad_id'
10
+
11
+ k = WavefrontCli::ApiToken
12
+
13
+ describe "#{word} command" do
14
+ missing_creds(word, ['list',
15
+ 'create',
16
+ "delete #{id}",
17
+ "rename #{id} name"])
18
+
19
+ invalid_ids(word, ["delete #{bad_id}", "rename #{bad_id} name"])
20
+
21
+ cmd_to_call(word, 'list', { path: "/api/v2/#{word}" }, k)
22
+
23
+ cmd_noop(word, 'list',
24
+ ["GET https://metrics.wavefront.com/api/v2/#{word}"], k)
25
+ cmd_noop(word, 'create',
26
+ ["POST https://metrics.wavefront.com/api/v2/#{word}"], k)
27
+ cmd_noop(word, "delete #{id}",
28
+ ["DELETE https://metrics.wavefront.com/api/v2/#{word}/#{id}"], k)
29
+
30
+ cmd_to_call(word, "rename #{id} newname",
31
+ { method: :put, path: "/api/v2/#{word}/#{id}",
32
+ body: { tokenID: id,
33
+ tokenName: 'newname' },
34
+ headers: JSON_POST_HEADERS }, k)
35
+ end
@@ -24,7 +24,7 @@ Gem::Specification.new do |gem|
24
24
 
25
25
  gem.add_runtime_dependency 'docopt', '~> 0.6.0'
26
26
  gem.add_runtime_dependency 'inifile', '~> 3.0'
27
- gem.add_runtime_dependency 'wavefront-sdk', '~> 3.0', '>= 3.0.2'
27
+ gem.add_runtime_dependency 'wavefront-sdk', '~> 3.2', '>= 3.2.0'
28
28
 
29
29
  gem.add_development_dependency 'minitest', '~> 5.11', '>= 5.11.0'
30
30
  gem.add_development_dependency 'rake', '~> 12.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wavefront-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.4
4
+ version: 3.2.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: 2019-05-02 00:00:00.000000000 Z
11
+ date: 2019-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt
@@ -42,22 +42,22 @@ dependencies:
42
42
  name: wavefront-sdk
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '3.0'
48
45
  - - ">="
49
46
  - !ruby/object:Gem::Version
50
- version: 3.0.2
47
+ version: 3.2.0
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: '3.2'
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - "~>"
56
- - !ruby/object:Gem::Version
57
- version: '3.0'
58
55
  - - ">="
59
56
  - !ruby/object:Gem::Version
60
- version: 3.0.2
57
+ version: 3.2.0
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.2'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: minitest
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -166,10 +166,12 @@ files:
166
166
  - Rakefile
167
167
  - bin/wf
168
168
  - lib/wavefront-cli/alert.rb
169
+ - lib/wavefront-cli/apitoken.rb
169
170
  - lib/wavefront-cli/base.rb
170
171
  - lib/wavefront-cli/cloudintegration.rb
171
172
  - lib/wavefront-cli/commands/.rubocop.yml
172
173
  - lib/wavefront-cli/commands/alert.rb
174
+ - lib/wavefront-cli/commands/apitoken.rb
173
175
  - lib/wavefront-cli/commands/base.rb
174
176
  - lib/wavefront-cli/commands/cloudintegration.rb
175
177
  - lib/wavefront-cli/commands/config.rb
@@ -197,6 +199,7 @@ files:
197
199
  - lib/wavefront-cli/dashboard.rb
198
200
  - lib/wavefront-cli/derivedmetric.rb
199
201
  - lib/wavefront-cli/display/alert.rb
202
+ - lib/wavefront-cli/display/apitoken.rb
200
203
  - lib/wavefront-cli/display/base.rb
201
204
  - lib/wavefront-cli/display/cloudintegration.rb
202
205
  - lib/wavefront-cli/display/dashboard.rb
@@ -261,6 +264,7 @@ files:
261
264
  - spec/.rubocop.yml
262
265
  - spec/spec_helper.rb
263
266
  - spec/wavefront-cli/alert_spec.rb
267
+ - spec/wavefront-cli/apitoken_spec.rb
264
268
  - spec/wavefront-cli/base_spec.rb
265
269
  - spec/wavefront-cli/cloudintegration_spec.rb
266
270
  - spec/wavefront-cli/commands/alert_spec.rb
@@ -375,6 +379,7 @@ test_files:
375
379
  - spec/.rubocop.yml
376
380
  - spec/spec_helper.rb
377
381
  - spec/wavefront-cli/alert_spec.rb
382
+ - spec/wavefront-cli/apitoken_spec.rb
378
383
  - spec/wavefront-cli/base_spec.rb
379
384
  - spec/wavefront-cli/cloudintegration_spec.rb
380
385
  - spec/wavefront-cli/commands/alert_spec.rb