wavefront-cli 4.1.0 → 4.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: 48f9a11ef858f502c05d4c4d89080a31267f70d96430e88e44deba5b2f929015
4
- data.tar.gz: a1bbc741a8379fb2a5783688a858b8c12b5d020a1501d58478042fc303ca43c3
3
+ metadata.gz: 3c4a1d42c967b17f864ba74a9f8581d04df349c014e27a2729c5d8e5587e436b
4
+ data.tar.gz: ca290107fdc4488e165ab07713692d446eb13ddd5e430f8ee63aaf33239bf430
5
5
  SHA512:
6
- metadata.gz: 759172c664ff1b81f2e199afceb052a61f31f4c91b7f72ea69ad5e511dc19d7397d9731d7e03269d75b88bd3baa52bfedc3bc289c166a84b590fb71ea9bc7a11
7
- data.tar.gz: 5c7a9545f5ea086dce5bc02588ddf678ebad99321e55c68026a9e12ad0645b5a4a0bffcffac155ca238ad79370cd00cf146bd8033780f83dfabe2d7322b6c378
6
+ metadata.gz: b28118415ce64ef71ddf2d04417b26079f796884f895a82510c3ccfcb9883c188972e6e07b0961896cbe8e90272198ace216957d035b2715892a1b9c260f2292
7
+ data.tar.gz: b8e523c837ae979c554476f6aaec258788374b1ade012669ead8c2f3a2b0ba9f88da88fa349761acdbd6f12beea1460bda6cd011fb5bf9b71fa7a0715feaf960
data/HISTORY.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.2.0 (01/07/2019)
4
+ * Add `-M` (`--items-only`) option to all commands. For
5
+ machine-parseable formats, this filters the API response, giving only
6
+ the `items` array, which should usually be suitable for batch
7
+ importing. This is a more sophisticated and flexible implementation of
8
+ 4.1.0's `dump` subcommand.
9
+
3
10
  ## 4.1.0 (27/06/2019)
4
11
  * Add `dump` subcommand for all importable object types. Produces
5
12
  JSON or YAML output.
@@ -1,6 +1,6 @@
1
1
  require_relative '../stdlib/string'
2
2
 
3
- CMN = '[-DnV] [-c file] [-P profile] [-E endpoint] [-t token] ' \
3
+ CMN = '[-DnVM] [-c file] [-P profile] [-E endpoint] [-t token] ' \
4
4
  '[-f format]'.freeze
5
5
 
6
6
  # A base class which all command classes extend.
@@ -20,6 +20,7 @@ class WavefrontCommandBase
20
20
  '-n, --noop do not perform API calls',
21
21
  '-V, --verbose be verbose',
22
22
  '-f, --format=STRING output format',
23
+ '-M, --items-only only show items in machine-parseable formats',
23
24
  '-h, --help show this message']
24
25
  end
25
26
 
@@ -16,8 +16,8 @@ module WavefrontOutput
16
16
 
17
17
  def initialize(resp = {}, options = {})
18
18
  @cmd = options[:class]
19
- @resp = resp
20
19
  @options = options
20
+ @resp = filtered_response(resp)
21
21
  end
22
22
 
23
23
  # We used to call #run directly, but now we use this wrapper to
@@ -31,6 +31,24 @@ module WavefrontOutput
31
31
  command_class.run
32
32
  end
33
33
 
34
+ def filtered_response(resp)
35
+ return resp unless options[:itemsonly]
36
+ items_only(resp)
37
+ end
38
+
39
+ def items_only(resp)
40
+ if allow_items_only?
41
+ return resp[:items] if resp.key?(:items)
42
+
43
+ raise(WavefrontCli::Exception::UnsupportedOutput,
44
+ 'API response does not contain items object.')
45
+ end
46
+
47
+ raise(WavefrontCli::Exception::UnsupportedOutput,
48
+ format("'%s' format does not support items-only output.",
49
+ my_format))
50
+ end
51
+
34
52
  def my_format
35
53
  self.class.name.split('::').last.downcase
36
54
  end
@@ -47,5 +65,9 @@ module WavefrontOutput
47
65
  require_relative command_file
48
66
  Object.const_get(command_class_name).new(resp, options)
49
67
  end
68
+
69
+ def allow_items_only?
70
+ false
71
+ end
50
72
  end
51
73
  end
@@ -8,5 +8,9 @@ module WavefrontOutput
8
8
  def _run
9
9
  resp.to_json
10
10
  end
11
+
12
+ def allow_items_only?
13
+ true
14
+ end
11
15
  end
12
16
  end
@@ -12,5 +12,9 @@ module WavefrontOutput
12
12
  def _run
13
13
  resp
14
14
  end
15
+
16
+ def allow_items_only?
17
+ true
18
+ end
15
19
  end
16
20
  end
@@ -11,5 +11,9 @@ module WavefrontOutput
11
11
  def _run
12
12
  JSON.parse(resp.to_json).to_yaml
13
13
  end
14
+
15
+ def allow_items_only?
16
+ true
17
+ end
14
18
  end
15
19
  end
@@ -1 +1 @@
1
- WF_CLI_VERSION = '4.1.0'.freeze
1
+ WF_CLI_VERSION = '4.2.0'.freeze
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: 4.1.0
4
+ version: 4.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-06-27 00:00:00.000000000 Z
11
+ date: 2019-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt