Class: WavefrontDisplay::Alert

Inherits:
Base
  • Object
show all
Defined in:
lib/wavefront-cli/display/alert.rb

Overview

Format human-readable output for alerts.

Constant Summary

Constants included from WavefrontCli::Constants

WavefrontCli::Constants::DEFAULT_OPTS, WavefrontCli::Constants::HUMAN_TIME_FORMAT, WavefrontCli::Constants::HUMAN_TIME_FORMAT_MS

Instance Attribute Summary

Attributes inherited from Base

#data, #options, #raw

Instance Method Summary collapse

Methods inherited from Base

#do_delete, #do_import, #do_search, #do_search_brief, #do_tag_add, #do_tag_clear, #do_tag_delete, #do_tag_set, #do_tags, #do_undelete, #drop_fields, #friendly_name, #human_time, #initialize, #key_width, #long_output, #multicolumn, #pagination_line, #put_id_first, #readable_time, #readable_time_arr, #run, #run_error, #run_list, #run_search

Constructor Details

This class inherits a constructor from WavefrontDisplay::Base

Instance Method Details

#do_describeObject



28
29
30
31
32
33
34
35
# File 'lib/wavefront-cli/display/alert.rb', line 28

def do_describe
  readable_time(:created, :lastProcessedMillis,
                :lastNotificationMillis, :createdEpochMillis,
                :updatedEpochMillis, :updated)
  drop_fields(:conditionQBEnabled, :displayExpressionQBEnabled,
              :displayExpressionQBSerialization)
  long_output
end

#do_firingObject



18
19
20
21
# File 'lib/wavefront-cli/display/alert.rb', line 18

def do_firing
  readable_time_arr(:startTime)
  multicolumn(:id, :name, :startTime)
end

#do_historyObject



37
38
39
40
# File 'lib/wavefront-cli/display/alert.rb', line 37

def do_history
  drop_fields(:inTrash)
  long_output
end

#do_listObject



8
9
10
11
12
# File 'lib/wavefront-cli/display/alert.rb', line 8

def do_list
  long_output %i[id minutes target status tags hostsUsed
                 condition displayExpression severity
                 additionalInformation]
end

#do_list_briefObject



14
15
16
# File 'lib/wavefront-cli/display/alert.rb', line 14

def do_list_brief
  multicolumn(:id, :status, :name)
end

#do_snoozeObject



42
43
44
45
# File 'lib/wavefront-cli/display/alert.rb', line 42

def do_snooze
  w = options[:time] ? "for #{options[:time]} seconds" : 'indefinitely'
  puts "Snoozed alert '#{options[:'<id>']}' #{w}."
end

#do_snoozedObject



23
24
25
26
# File 'lib/wavefront-cli/display/alert.rb', line 23

def do_snoozed
  readable_time_arr(:startTime)
  multicolumn(:id, :name, :startTime)
end

#do_summaryObject



51
52
53
54
55
# File 'lib/wavefront-cli/display/alert.rb', line 51

def do_summary
  kw = data.keys.map(&:size).max + 2
  data.delete_if { |_k, v| v.zero? } unless options[:all]
  data.sort.each { |k, v| puts format("%-#{kw}s%s", k, v) }
end

#do_unsnoozeObject



47
48
49
# File 'lib/wavefront-cli/display/alert.rb', line 47

def do_unsnooze
  puts "Unsnoozed alert '#{options[:'<id>']}'."
end