wavefront-cli 2.9.2 → 2.9.3
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 +4 -4
- data/HISTORY.md +4 -0
- data/lib/wavefront-cli/alert.rb +12 -1
- data/lib/wavefront-cli/display/alert.rb +4 -4
- data/lib/wavefront-cli/display/base.rb +17 -12
- data/lib/wavefront-cli/version.rb +1 -1
- data/spec/wavefront-cli/display/base_spec.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f715afc29d378a6e84b9ce7ad2b7ade17047a85d2ae6e1280605322d87085c0e
|
4
|
+
data.tar.gz: 35ebc020f4201d6890625a62cf346d46aacf3eb7250ddaa7015dce34fb4ef93e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61a94256695771c09205e5a5d26bedf2f45c35fc4e2ba9a6c4d03cec23cbeeed465f12f807d06d5135b63bd6af5f7956a8778ed3c5885fa5e363994d2ae0fbe8
|
7
|
+
data.tar.gz: 6722fd63e13d7178015c7960d5b8d615de73e49d3c54cf98e17d9cbd05d42ba4280e7b1ecc184b3d42e24f37a3db7405f9548ffbc486095971db6bb7dcf65a9b
|
data/HISTORY.md
CHANGED
data/lib/wavefront-cli/alert.rb
CHANGED
@@ -53,12 +53,23 @@ module WavefrontCli
|
|
53
53
|
search = do_search([format('status=%s', status)])
|
54
54
|
|
55
55
|
items = search.response.items.map do |i|
|
56
|
-
{ name: i.name, id: i.id,
|
56
|
+
{ name: i.name, id: i.id, time: state_time(i) }
|
57
57
|
end
|
58
58
|
|
59
59
|
search.tap { |s| s.response[:items] = items }
|
60
60
|
end
|
61
61
|
|
62
|
+
# Snoozed alerts don't have a start time, they have a "snoozed"
|
63
|
+
# time. This is -1 if they are snoozed forever: the formatting
|
64
|
+
# methods know what to do with that.
|
65
|
+
# @return [Integer]
|
66
|
+
#
|
67
|
+
def state_time(item)
|
68
|
+
return item[:event][:startTime] if item.key?(:event)
|
69
|
+
return item[:snoozed] if item.key?(:snoozed)
|
70
|
+
nil
|
71
|
+
end
|
72
|
+
|
62
73
|
# Take a previously exported alert, and construct a hash which
|
63
74
|
# create() can use to re-create it.
|
64
75
|
#
|
@@ -16,13 +16,13 @@ module WavefrontDisplay
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def do_firing
|
19
|
-
readable_time_arr(:
|
20
|
-
multicolumn(:id, :
|
19
|
+
readable_time_arr(:time)
|
20
|
+
multicolumn(:id, :time, :name)
|
21
21
|
end
|
22
22
|
|
23
23
|
def do_snoozed
|
24
|
-
readable_time_arr(:
|
25
|
-
multicolumn(:id, :
|
24
|
+
readable_time_arr(:time)
|
25
|
+
multicolumn(:id, :time, :name)
|
26
26
|
end
|
27
27
|
|
28
28
|
def do_describe
|
@@ -267,27 +267,32 @@ module WavefrontDisplay
|
|
267
267
|
# used for unit tests.
|
268
268
|
# return [String] a human-readable timestamp
|
269
269
|
#
|
270
|
-
# rubocop:disable Metrics/MethodLength
|
271
270
|
def human_time(time, force_utc = false)
|
272
271
|
raise ArgumentError unless time.is_a?(Numeric) || time.is_a?(String)
|
273
|
-
str = time.to_s
|
274
272
|
|
275
|
-
if
|
276
|
-
fmt = '%Q'
|
277
|
-
out_fmt = HUMAN_TIME_FORMAT_MS
|
278
|
-
elsif str =~ /^\d{10}$/
|
279
|
-
fmt = '%s'
|
280
|
-
out_fmt = HUMAN_TIME_FORMAT
|
281
|
-
else
|
282
|
-
raise ArgumentError
|
283
|
-
end
|
273
|
+
return 'FOREVER' if time == -1
|
284
274
|
|
275
|
+
str = time.to_s
|
276
|
+
fmt, out_fmt = time_formats(str)
|
285
277
|
# rubocop:disable Style/DateTime
|
286
278
|
ret = DateTime.strptime(str, fmt).to_time
|
287
279
|
# rubocop:enable Style/DateTime
|
288
280
|
ret = ret.utc if force_utc
|
289
281
|
ret.strftime(out_fmt)
|
290
282
|
end
|
291
|
-
|
283
|
+
|
284
|
+
# How do we format a timestamp?
|
285
|
+
# @param str [String] an epoch timestamp, as a string
|
286
|
+
# @return [String, String] DateTime formatter, strptime formatter
|
287
|
+
#
|
288
|
+
def time_formats(str)
|
289
|
+
if str =~ /^\d{13}$/
|
290
|
+
['%Q', HUMAN_TIME_FORMAT_MS]
|
291
|
+
elsif str =~ /^\d{10}$/
|
292
|
+
['%s', HUMAN_TIME_FORMAT]
|
293
|
+
else
|
294
|
+
raise ArgumentError
|
295
|
+
end
|
296
|
+
end
|
292
297
|
end
|
293
298
|
end
|
@@ -1 +1 @@
|
|
1
|
-
WF_CLI_VERSION = '2.9.
|
1
|
+
WF_CLI_VERSION = '2.9.3'.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.9.
|
4
|
+
version: 2.9.3
|
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-
|
11
|
+
date: 2018-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|