Class: WavefrontCli::Alert
Overview
CLI coverage for the v2 ‘alert’ API.
Instance Attribute Summary
Attributes inherited from Base
#klass, #klass_word, #options, #wf
Instance Method Summary collapse
- #do_delete ⇒ Object
- #do_describe ⇒ Object
- #do_history ⇒ Object
- #do_snooze ⇒ Object
- #do_summary ⇒ Object
- #do_unsnooze ⇒ Object
-
#import_to_create(raw) ⇒ Object
Take a previously exported alert, and construct a hash which create() can use to re-create it.
Methods inherited from Base
#check_status, #dispatch, #display, #do_import, #do_list, #do_search, #do_tag_add, #do_tag_clear, #do_tag_delete, #do_tag_set, #do_tags, #do_undelete, #do_update, #format_var, #handle_error, #handle_response, #initialize, #load_display_class, #load_file, #mk_creds, #mk_opts, #run, #validate_id, #validate_input, #validate_opts, #validate_tags, #validator_exception, #validator_method
Constructor Details
This class inherits a constructor from WavefrontCli::Base
Instance Method Details
#do_delete ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/wavefront-cli/alert.rb', line 20 def do_delete word = if wf.describe([:'<id>']).status.code == 200 'Soft' else 'Permanently' end puts "#{word} deleting alert '#{options[:'<id>']}'." wf.delete([:'<id>']) end |
#do_describe ⇒ Object
8 9 10 |
# File 'lib/wavefront-cli/alert.rb', line 8 def do_describe wf.describe([:'<id>'], [:version]) end |
#do_history ⇒ Object
35 36 37 |
# File 'lib/wavefront-cli/alert.rb', line 35 def do_history wf.history([:'<id>'], [:offset], [:limit]) end |
#do_snooze ⇒ Object
12 13 14 |
# File 'lib/wavefront-cli/alert.rb', line 12 def do_snooze wf.snooze([:'<id>'], [:time]) end |
#do_summary ⇒ Object
31 32 33 |
# File 'lib/wavefront-cli/alert.rb', line 31 def do_summary wf.summary end |
#do_unsnooze ⇒ Object
16 17 18 |
# File 'lib/wavefront-cli/alert.rb', line 16 def do_unsnooze wf.unsnooze([:'<id>']) end |
#import_to_create(raw) ⇒ Object
Take a previously exported alert, and construct a hash which create() can use to re-create it.
rubocop:disable Metrics/MethodLength
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/wavefront-cli/alert.rb', line 45 def import_to_create(raw) ret = %w(name condition minutes target severity displayExpression additionalInformation).each_with_object({}) do |k, aggr| aggr[k.to_sym] = raw[k] end if raw.key?('resolveAfterMinutes') ret[:resolveMinutes] = raw['resolveAfterMinutes'] end if raw.key?('customerTagsWithCounts') ret[:sharedTags] = raw['customerTagsWithCounts'].keys end ret end |