wavefront-cli 2.13.0 → 2.15.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: c9007cbf188f6962a31b04002c5b64c86e85bbc2ddad05e5299647706970ad65
4
- data.tar.gz: 6b5daf8e04b6d5090837620f51dc9e1b5ce3c9d45227fe66d118a2adb94e758b
3
+ metadata.gz: acd004964f7c14a26b9857cdb8f2fc1781b52cfa1a1deee654db16a501203b69
4
+ data.tar.gz: 141f7be085e49e02624348da8edb1c37c5adac283ffd15d8574015c5230c6ad4
5
5
  SHA512:
6
- metadata.gz: c224961d3690bed9d069d689d632c726262342ad4cc278b1942d4e70cc54a4263e0d89eda027b156cd93fde9184db04f831f75cbad3fe374f5a45f3eb7f30769
7
- data.tar.gz: 2b20581ec22ae10242eea44ff07862b43eeb5bac057774b56aa6f3a363379298dbaca416859d1c274770edb376fe4bf3f85484876e16db23a475c457b850ac1b
6
+ metadata.gz: c88f783fe7710432538c7a583df5789034a583736cbcb2bc3356e4a1e3d6b4f415aa282aa710c0f72f5c6e9210f0fd173a0a54579b90d1578fefeff3b9adf212
7
+ data.tar.gz: 7dce2b8ac086b16353f1a73280398874e858e906893cd81a0d948e144727f8ebdcaf94c9001532bf8e1ca86f6b21fa4b959f6801c54405271d92800af85d9522
data/HISTORY.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.15.0 (18/12/2018)
4
+ * Gracefully handle ctrl-c.
5
+ * Add `install` and `uninstall` subcommands to `wf alert`.
6
+ * Add `enable` and `disable` subcommands to `wf cloudintegration`.
7
+ * Add `fav` and `unfav` commands to `wf dashboard`.
8
+ * Add `alert install`, `alert uninstall`, `installed`, and
9
+ `manifest` commands to `wf integration`.
10
+ * Require 2.2.0 of [wavefront-sdk](https://github.com/snltd/wavefront-sdk).
11
+
12
+ ## 2.14.0 (15/12/2018)
13
+ * Add `-n` to `dashboard`'s `list` and `queries` commands to omit
14
+ system-owned dashboards.
15
+ * Let `queries` subcommand accept an optional ID.
16
+
3
17
  ## 2.13.0 (11/12/2018)
4
18
  * Add CSV output for `query` command.
5
19
  * Add multiple format outputs for all applicable `alert`
@@ -55,11 +55,23 @@ module WavefrontCli
55
55
  end
56
56
 
57
57
  def do_queries
58
- wf.list(0, :all).tap do |r|
59
- r.response.items.map! { |a| { id: a.id, condition: a.condition } }
58
+ resp, data = one_or_all
59
+
60
+ resp.tap do |r|
61
+ r.response.items = data.map do |a|
62
+ { id: a.id, condition: a.condition }
63
+ end
60
64
  end
61
65
  end
62
66
 
67
+ def do_install
68
+ wf.install(options[:'<id>'])
69
+ end
70
+
71
+ def do_uninstall
72
+ wf.uninstall(options[:'<id>'])
73
+ end
74
+
63
75
  # How many alerts are in the given state? If none, say so,
64
76
  # rather than just printing nothing.
65
77
  #
@@ -352,8 +352,13 @@ module WavefrontCli
352
352
  # harm inheriting unneeded things. Some classes override them.
353
353
  #
354
354
  def do_list
355
- return wf.list(ALL_PAGE_SIZE, :all) if options[:all]
356
- wf.list(options[:offset] || 0, options[:limit] || 100)
355
+ list = if options[:all]
356
+ wf.list(ALL_PAGE_SIZE, :all)
357
+ else
358
+ wf.list(options[:offset] || 0, options[:limit] || 100)
359
+ end
360
+
361
+ respond_to?(:list_filter) ? list_filter(list) : list
357
362
  end
358
363
 
359
364
  def do_describe
@@ -457,5 +462,21 @@ module WavefrontCli
457
462
  def import_to_create(raw)
458
463
  raw.delete_if { |k, _v| k == 'id' }
459
464
  end
465
+
466
+ # Return a detailed description of one item, if an ID has been
467
+ # given, or all items if it has not.
468
+ #
469
+ def one_or_all
470
+ if options[:'<id>']
471
+ resp = wf.describe(options[:'<id>'])
472
+ data = [resp.response]
473
+ else
474
+ options[:all] = true
475
+ resp = do_list
476
+ data = resp.response.items
477
+ end
478
+
479
+ [resp, data]
480
+ end
460
481
  end
461
482
  end
@@ -8,5 +8,13 @@ module WavefrontCli
8
8
  def validator_exception
9
9
  Wavefront::Exception::InvalidCloudIntegrationId
10
10
  end
11
+
12
+ def do_enable
13
+ wf.enable(options[:'<id>'])
14
+ end
15
+
16
+ def do_disable
17
+ wf.disable(options[:'<id>'])
18
+ end
11
19
  end
12
20
  end
@@ -26,7 +26,9 @@ class WavefrontCommandAlert < WavefrontCommandBase
26
26
  "tag add #{CMN} <id> <tag>",
27
27
  "tag delete #{CMN} <id> <tag>",
28
28
  "currently #{CMN} [-f format] <state>",
29
- "queries #{CMN} [-f format] [-b]",
29
+ "queries #{CMN} [-f format] [-b] [<id>]",
30
+ "install #{CMN} <id>",
31
+ "uninstall #{CMN} <id>",
30
32
  "summary #{CMN} [-f format] [-a]"]
31
33
  end
32
34
 
@@ -20,6 +20,8 @@ class WavefrontCommandCloudintegration < WavefrontCommandBase
20
20
  "describe #{CMN} [-f format] <id>",
21
21
  "delete #{CMN} <id>",
22
22
  "undelete #{CMN} <id>",
23
+ "enable #{CMN} <id>",
24
+ "disable #{CMN} <id>",
23
25
  "import #{CMN} <file>",
24
26
  "search #{CMN} [-al] [-f format] [-o offset] [-L limit] <condition>..."]
25
27
  end
@@ -8,7 +8,7 @@ class WavefrontCommandDashboard < WavefrontCommandBase
8
8
  end
9
9
 
10
10
  def _commands
11
- ["list #{CMN} [-al] [-f format] [-o offset] [-L limit]",
11
+ ["list #{CMN} [-alN] [-f format] [-o offset] [-L limit]",
12
12
  "describe #{CMN} [-f format] [-v version] <id>",
13
13
  "import #{CMN} [-f format] <file>",
14
14
  "update #{CMN} <key=value> <id>",
@@ -16,7 +16,9 @@ class WavefrontCommandDashboard < WavefrontCommandBase
16
16
  "undelete #{CMN} <id>",
17
17
  "history #{CMN} [-f format] [-o offset] [-L limit] <id>",
18
18
  "search #{CMN} [-al] [-f format] [-o offset] [-L limit] <condition>...",
19
- "queries #{CMN} [-f format] [-b]",
19
+ "queries #{CMN} [-f format] [-b] [<id>]",
20
+ "fav #{CMN} <id>",
21
+ "unfav #{CMN} <id>",
20
22
  tag_commands]
21
23
  end
22
24
 
@@ -28,6 +30,7 @@ class WavefrontCommandDashboard < WavefrontCommandBase
28
30
  '-L, --limit=COUNT number of dashboards or revisions to list',
29
31
  '-v, --version=INTEGER version of dashboard',
30
32
  '-b, --brief do not show dashboard names',
33
+ '-N, --no-system do not show system-owned dashboards',
31
34
  '-f, --format=STRING output format']
32
35
  end
33
36
  end
@@ -15,6 +15,10 @@ class WavefrontCommandIntegration < WavefrontCommandBase
15
15
  "manifests #{CMN}",
16
16
  "status #{CMN} <id>",
17
17
  "statuses #{CMN}",
18
+ "alert install #{CMN} <id>",
19
+ "alert uninstall #{CMN} <id>",
20
+ "installed #{CMN} [-f format]",
21
+ "manifests #{CMN} [-f format]",
18
22
  "search #{CMN} [-al] [-f format] [-o offset] [-L limit] <condition>..."]
19
23
  end
20
24
 
@@ -102,6 +102,8 @@ class WavefrontCliController
102
102
  def run_command(cli_class_obj)
103
103
  cli_class_obj.validate_opts
104
104
  cli_class_obj.run
105
+ rescue Interrupt
106
+ abort "\nOperation aborted at user request."
105
107
  rescue WavefrontCli::Exception::CredentialError => e
106
108
  abort "Credential error. #{e.message}"
107
109
  rescue WavefrontCli::Exception::UnsupportedOutput => e
@@ -5,6 +5,11 @@ module WavefrontCli
5
5
  # CLI coverage for the v2 'dashboard' API.
6
6
  #
7
7
  class Dashboard < WavefrontCli::Base
8
+ def list_filter(list)
9
+ return list unless options[:nosystem]
10
+ list.tap { |l| l.response.items.delete_if { |d| d[:systemOwned] } }
11
+ end
12
+
8
13
  def do_describe
9
14
  wf.describe(options[:'<id>'], options[:version])
10
15
  end
@@ -25,15 +30,23 @@ module WavefrontCli
25
30
  end
26
31
 
27
32
  def do_queries
28
- resp = wf.list(0, :all)
33
+ resp, data = one_or_all
29
34
 
30
- queries = resp.response.items.each_with_object({}) do |d, a|
35
+ queries = data.each_with_object({}) do |d, a|
31
36
  a[d.id] = extract_values(d, 'query')
32
37
  end
33
38
 
34
39
  resp.tap { |r| r.response.items = queries }
35
40
  end
36
41
 
42
+ def do_fav
43
+ wf.favorite(options[:'<id>'])
44
+ end
45
+
46
+ def do_unfav
47
+ wf.unfavorite(options[:'<id>'])
48
+ end
49
+
37
50
  # @param obj [Object] the thing to search
38
51
  # @param key [String, Symbol] the key to search for
39
52
  # @param aggr [Array] values of matched keys
@@ -14,5 +14,13 @@ module WavefrontDisplay
14
14
  drop_fields(:forceSave, :inTrash, :deleted)
15
15
  long_output
16
16
  end
17
+
18
+ def do_enable
19
+ puts "Enabled #{options[:'<id>']}."
20
+ end
21
+
22
+ def do_disable
23
+ puts "Disabled #{options[:'<id>']}."
24
+ end
17
25
  end
18
26
  end
@@ -26,5 +26,13 @@ module WavefrontDisplay
26
26
  long_output
27
27
  end
28
28
  end
29
+
30
+ def do_fav
31
+ puts "Added #{options[:'<id>']} to favourites."
32
+ end
33
+
34
+ def do_unfav
35
+ puts "Removed #{options[:'<id>']} from favourites."
36
+ end
29
37
  end
30
38
  end
@@ -8,5 +8,17 @@ module WavefrontDisplay
8
8
  def do_list_brief
9
9
  multicolumn(:id, :name, :description)
10
10
  end
11
+
12
+ def do_installed
13
+ multicolumn(:id, :name, :description)
14
+ end
15
+
16
+ def do_install_all_alerts
17
+ puts "Installed alerts for #{options[:'<id>']}."
18
+ end
19
+
20
+ def do_uninstall_all_alerts
21
+ puts "Uninstalled alerts for #{options[:'<id>']}."
22
+ end
11
23
  end
12
24
  end
@@ -10,6 +10,10 @@ module WavefrontCli
10
10
  end
11
11
 
12
12
  def do_manifests
13
+ if options[:format] == 'human'
14
+ abort 'Human-readable manifest output is not supported.'
15
+ end
16
+
13
17
  wf.manifests
14
18
  end
15
19
 
@@ -21,8 +25,20 @@ module WavefrontCli
21
25
  wf.uninstall(options[:'<id>'])
22
26
  end
23
27
 
28
+ def do_alert_install
29
+ wf.install_all_alerts(options[:'<id>'])
30
+ end
31
+
32
+ def do_alert_uninstall
33
+ wf.uninstall_all_alerts(options[:'<id>'])
34
+ end
35
+
24
36
  def do_statuses
25
37
  wf.statuses
26
38
  end
39
+
40
+ def do_installed
41
+ wf.installed
42
+ end
27
43
  end
28
44
  end
@@ -1 +1 @@
1
- WF_CLI_VERSION = '2.13.0'.freeze
1
+ WF_CLI_VERSION = '2.15.0'.freeze
@@ -47,9 +47,14 @@ describe "#{word} command" do
47
47
  path: "/api/v2/#{word}/#{id}/snooze?seconds=800")
48
48
  cmd_to_call(word, "unsnooze #{id}",
49
49
  method: :post, path: "/api/v2/#{word}/#{id}/unsnooze")
50
+ cmd_to_call(word, "install #{id}",
51
+ method: :post, path: "/api/v2/#{word}/#{id}/install")
52
+ cmd_to_call(word, "uninstall #{id}",
53
+ method: :post, path: "/api/v2/#{word}/#{id}/uninstall")
50
54
  cmd_to_call(word, 'summary', path: "/api/v2/#{word}/summary")
51
55
  invalid_ids(word, ["describe #{bad_id}", "delete #{bad_id}",
52
56
  "undelete #{bad_id}", "snooze #{bad_id}",
57
+ "install #{bad_id}", "uninstall #{bad_id}",
53
58
  "snooze -T 500 #{bad_id}"])
54
59
  tag_tests(word, id, bad_id)
55
60
  end
@@ -28,6 +28,13 @@ describe 'cloudintegration command' do
28
28
  cmd_to_call(word, "undelete #{id}",
29
29
  { method: :post,
30
30
  path: "/api/v2/cloudintegration/#{id}/undelete" }, k)
31
+ cmd_to_call(word, "enable #{id}",
32
+ { method: :post,
33
+ path: "/api/v2/cloudintegration/#{id}/enable" }, k)
34
+ cmd_to_call(word, "disable #{id}",
35
+ { method: :post,
36
+ path: "/api/v2/cloudintegration/#{id}/disable" }, k)
31
37
  invalid_ids(word, ["describe #{bad_id}", "delete #{bad_id}",
32
- "undelete #{bad_id}"])
38
+ "undelete #{bad_id}", "disable #{bad_id}",
39
+ "enable #{bad_id}"])
33
40
  end
@@ -39,6 +39,10 @@ describe "#{word} command" do
39
39
  sort: { field: 'id', ascending: true } },
40
40
  headers: JSON_POST_HEADERS)
41
41
 
42
+ cmd_to_call(word, "fav #{id}",
43
+ method: :post, path: "/api/v2/#{word}/#{id}/favorite")
44
+ cmd_to_call(word, "unfav #{id}",
45
+ method: :post, path: "/api/v2/#{word}/#{id}/unfavorite")
42
46
  cmd_to_call(word, "undelete #{id}",
43
47
  method: :post, path: "/api/v2/#{word}/#{id}/undelete")
44
48
  invalid_ids(word, ["describe #{bad_id}", "delete #{bad_id}",
@@ -12,12 +12,33 @@ describe "#{word} command" do
12
12
  "uninstall #{id}", "status #{id}", 'statuses',
13
13
  'manifests'])
14
14
  list_tests(word)
15
- cmd_to_call(word, "describe #{id}", path: "/api/v2/#{word}/#{id}")
15
+
16
+ cmd_to_call(word, "status #{id}", path: "/api/v2/#{word}/#{id}/status")
17
+
16
18
  cmd_to_call(word, "install #{id}",
17
19
  method: :post, path: "/api/v2/#{word}/#{id}/install")
20
+
18
21
  cmd_to_call(word, "uninstall #{id}",
19
22
  method: :post, path: "/api/v2/#{word}/#{id}/uninstall")
23
+
24
+ cmd_to_call(word, "alert install #{id}",
25
+ method: :post,
26
+ path: "/api/v2/#{word}/#{id}/install-all-alerts")
27
+
28
+ cmd_to_call(word, "alert uninstall #{id}",
29
+ method: :post,
30
+ path: "/api/v2/#{word}/#{id}/uninstall-all-alerts")
31
+
32
+ cmd_to_call(word, "describe #{id}", path: "/api/v2/#{word}/#{id}")
33
+
20
34
  cmd_to_call(word, "status #{id}", path: "/api/v2/#{word}/#{id}/status")
35
+
36
+ cmd_to_call(word, 'installed', path: "/api/v2/#{word}/installed")
37
+
38
+ cmd_to_call(word, 'manifests', path: "/api/v2/#{word}/manifests")
39
+
21
40
  invalid_ids(word, ["describe #{bad_id}", "install #{bad_id}",
41
+ "alert install #{bad_id}",
42
+ "alert uninstall #{bad_id}",
22
43
  "uninstall #{bad_id}", "status #{bad_id}"])
23
44
  end
@@ -23,7 +23,7 @@ Gem::Specification.new do |gem|
23
23
  gem.require_paths = %w[lib]
24
24
 
25
25
  gem.add_runtime_dependency 'docopt', '~> 0.6.0'
26
- gem.add_runtime_dependency 'wavefront-sdk', '~> 2.1', '>= 2.1.0'
26
+ gem.add_runtime_dependency 'wavefront-sdk', '~> 2.2', '>= 2.2.0'
27
27
 
28
28
  gem.add_development_dependency 'bundler', '~> 1.3'
29
29
  gem.add_development_dependency 'minitest', '~> 5.11', '>= 5.11.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: 2.13.0
4
+ version: 2.15.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: 2018-12-12 00:00:00.000000000 Z
11
+ date: 2018-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt
@@ -30,20 +30,20 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.1.0
33
+ version: 2.2.0
34
34
  - - "~>"
35
35
  - !ruby/object:Gem::Version
36
- version: '2.1'
36
+ version: '2.2'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 2.1.0
43
+ version: 2.2.0
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '2.1'
46
+ version: '2.2'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement