wavefront-cli 2.1.6 → 2.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: 4f2e02d1e31da1b3ad2fd05c895813c97349e833c270b7bc843c63591b428d82
4
- data.tar.gz: bdcf1886e4f5a28387e0ff8a669ebb8517e3d794bee15c0fc6ec19262e9844b7
3
+ metadata.gz: f672ae4ac7f81edd35c18b5ceff7a187b2e2450cf31ec4b8551de2b3c2f5521f
4
+ data.tar.gz: 4c6d64235013f1a56c92f129347d9e006d72c213f51eabc66cc2055aa7497dcb
5
5
  SHA512:
6
- metadata.gz: e48473c939d7be914f2effa82f5542a0395baa3cd7150a5e3f80d27a6b08e34bb026ce41f8623ccec15cb7044f7e256c5685a058d0c903725623a04c972ed43d
7
- data.tar.gz: f2443319167863a1cbb90201dd6db6ce711233b2877af8b4841df3311ba9691f6adaea1eb242bf209d231bf0a3c86a4e140dbe62efdb143e49b83a8724f2627d
6
+ metadata.gz: 8b6e35748122d99bcef965a0f86224679537b0b23b7175ac822255c5ee6321c42938c12eba5a1aca2bbe4dd256435c61525558fed3155dbe6eb70b1e5d3d9255
7
+ data.tar.gz: db39b5d27705c1d5d4a7f8431e306c0f137ef55322ca8bb958895b0ee0b2331f53d1a7d69fce50c5042de2faf8a9d247cb757277139c8bcd6f4c0ddb2388d6c2
data/.travis.yml CHANGED
@@ -1,9 +1,10 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.2.7
5
- - 2.3.4
6
- - 2.4.1
4
+ - 2.2.9
5
+ - 2.3.6
6
+ - 2.4.3
7
+ - 2.5.0
7
8
  before_install: gem install bundler --no-rdoc --no-ri
8
9
  deploy:
9
10
  provider: rubygems
@@ -13,5 +14,4 @@ deploy:
13
14
  on:
14
15
  tags: true
15
16
  repo: snltd/wavefront-cli
16
- ruby: 2.3.4
17
-
17
+ ruby: 2.3.6
@@ -36,6 +36,29 @@ module WavefrontCli
36
36
  wf.history(options[:'<id>'], options[:offset], options[:limit])
37
37
  end
38
38
 
39
+ def do_firing
40
+ find_in_state(:firing)
41
+ end
42
+
43
+ def do_snoozed
44
+ find_in_state(:snoozed)
45
+ end
46
+
47
+ # Does the work for #do_firing() and #do_snoozed()
48
+ # @param status [Symbol,String] the alert status you wish to
49
+ # find
50
+ # @return Wavefront::Response
51
+ #
52
+ def find_in_state(status)
53
+ search = do_search([format('status=%s', status)])
54
+
55
+ items = search.response.items.map do |i|
56
+ { name: i.name, id: i.id, startTime: i.event.startTime }
57
+ end
58
+
59
+ search.tap { |s| s.response[:items] = items }
60
+ end
61
+
39
62
  # Take a previously exported alert, and construct a hash which
40
63
  # create() can use to re-create it.
41
64
  #
@@ -289,11 +289,11 @@ module WavefrontCli
289
289
  wf.update(options[:'<id>'], k => v)
290
290
  end
291
291
 
292
- def do_search
292
+ def do_search(cond = options[:'<condition>'])
293
293
  require 'wavefront-sdk/search'
294
294
  wfs = Wavefront::Search.new(mk_creds, mk_opts)
295
295
 
296
- query = conds_to_query(options[:'<condition>'])
296
+ query = conds_to_query(cond)
297
297
 
298
298
  wfs.search(klass_word, query, limit: options[:limit],
299
299
  offset: options[:offset] ||
@@ -8,6 +8,8 @@ class WavefrontCommandAlert < WavefrontCommandBase
8
8
  end
9
9
  def _commands
10
10
  ["list #{CMN} [-l] [-f format] [-o offset] [-L limit]",
11
+ "firing #{CMN} [-o offset] [-L limit]",
12
+ "snoozed #{CMN} [-o offset] [-L limit]",
11
13
  "describe #{CMN} [-f format] [-v version] <id>",
12
14
  "delete #{CMN} <id>",
13
15
  "undelete #{CMN} <id>",
@@ -1,16 +1,15 @@
1
1
  # For development against a local checkout of the SDK, uncomment
2
2
  # this block
3
3
  #
4
- #dir = Pathname.new(__FILE__).dirname.realpath.parent.parent.parent
5
- #$LOAD_PATH.<< dir + 'lib'
6
- #$LOAD_PATH.<< dir + 'wavefront-sdk' + 'lib'
4
+ # dir = Pathname.new(__FILE__).dirname.realpath.parent.parent.parent
5
+ # $LOAD_PATH.<< dir + 'lib'
6
+ # $LOAD_PATH.<< dir + 'wavefront-sdk' + 'lib'
7
7
 
8
8
  require 'pathname'
9
9
  require 'pp'
10
10
  require 'docopt'
11
11
  require_relative './version'
12
12
  require_relative './exception'
13
-
14
13
  require_relative './opt_handler'
15
14
 
16
15
  CMD_DIR = Pathname.new(__FILE__).dirname + 'commands'
@@ -15,6 +15,16 @@ module WavefrontDisplay
15
15
  multicolumn(:id, :status, :name)
16
16
  end
17
17
 
18
+ def do_firing
19
+ readable_time_arr(:startTime)
20
+ multicolumn(:id, :name, :startTime)
21
+ end
22
+
23
+ def do_snoozed
24
+ readable_time_arr(:startTime)
25
+ multicolumn(:id, :name, :startTime)
26
+ end
27
+
18
28
  def do_describe
19
29
  readable_time(:created, :lastProcessedMillis,
20
30
  :lastNotificationMillis, :createdEpochMillis,
@@ -37,6 +47,7 @@ module WavefrontDisplay
37
47
  def do_unsnooze
38
48
  puts "Unsnoozed alert '#{options[:'<id>']}'."
39
49
  end
50
+
40
51
  def do_summary
41
52
  kw = data.keys.map(&:size).max + 2
42
53
  data.delete_if { |_k, v| v.zero? } unless options[:all]
@@ -122,10 +122,10 @@ module WavefrontDisplay
122
122
  if raw.respond_to?(:moreItems) && raw.moreItems == true
123
123
  if raw.respond_to?(:offset) && raw.respond_to?(:limit)
124
124
  enditem = raw.limit > 0 ? raw.offset + raw.limit - 1 : 0
125
- puts format('Showing items %d to %d. Use -o and -L for more.',
125
+ puts format('List shows items %d to %d. Use -o and -L for more.',
126
126
  raw.offset, enditem)
127
127
  else
128
- puts 'Showing paginated output. Use -o and -L for more.'
128
+ puts 'List shows paginated output. Use -o and -L for more.'
129
129
  end
130
130
  end
131
131
  end
@@ -234,7 +234,7 @@ module WavefrontDisplay
234
234
  end
235
235
  end
236
236
 
237
- # Modify, in-place, the data structure to make times
237
+ # Modify, in-place, the @data structure to make times
238
238
  # human-readable. Automatically handles second and millisecond
239
239
  # epoch times. Currently only operates on top-level keys.
240
240
  #
@@ -246,6 +246,15 @@ module WavefrontDisplay
246
246
  keys.each { |k| data[k] = human_time(data[k]) if data.key?(k) }
247
247
  end
248
248
 
249
+ # As for #readable_time, but when @data is an array. For
250
+ # instance in "firing" alerts
251
+ #
252
+ def readable_time_arr(*keys)
253
+ data.map do |row|
254
+ keys.each { |k| row[k] = human_time(row[k]) if row.key?(k) }
255
+ end
256
+ end
257
+
249
258
  # Make a time human-readable. Automatically deals with epoch
250
259
  # seconds and epoch milliseconds
251
260
  #
@@ -1 +1 @@
1
- WF_CLI_VERSION = '2.1.6'.freeze
1
+ WF_CLI_VERSION = '2.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: 2.1.6
4
+ version: 2.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: 2018-01-11 00:00:00.000000000 Z
11
+ date: 2018-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt
@@ -289,7 +289,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
289
289
  version: '0'
290
290
  requirements: []
291
291
  rubyforge_project:
292
- rubygems_version: 2.7.4
292
+ rubygems_version: 2.7.6
293
293
  signing_key:
294
294
  specification_version: 4
295
295
  summary: CLI for Wavefront API v2