Class: Radiosonde::Wrapper::Alarm
- Inherits:
-
Object
- Object
- Radiosonde::Wrapper::Alarm
- Extended by:
- Forwardable
- Includes:
- Logger::Helper
- Defined in:
- lib/radiosonde/wrapper/alarm.rb
Constant Summary collapse
- ATTRIBUTES_WITHOUT_NAME =
[ :alarm_description, :namespace, :metric_name, :dimensions, :period, :statistic, :threshold, :comparison_operator, :evaluation_periods, :actions_enabled, :unit, :alarm_actions, :ok_actions, :insufficient_data_actions, :actions_enabled, ]
- ATTRIBUTES =
[:alarm_name] + ATTRIBUTES_WITHOUT_NAME
- DEFAULT_VALUES =
{ :dimensions => [] }
Class Method Summary collapse
Instance Method Summary collapse
- #delete ⇒ Object
- #eql?(dsl) ⇒ Boolean
-
#initialize(cloud_watch, alarm, options = {}) ⇒ Alarm
constructor
of class methods.
- #update(dsl) ⇒ Object
Methods included from Logger::Helper
Constructor Details
#initialize(cloud_watch, alarm, options = {}) ⇒ Alarm
of class methods
47 48 49 50 51 |
# File 'lib/radiosonde/wrapper/alarm.rb', line 47 def initialize(cloud_watch, alarm, = {}) @cloud_watch = cloud_watch @alarm = alarm @options = end |
Class Method Details
.normalize_attrs(attrs) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/radiosonde/wrapper/alarm.rb', line 34 def normalize_attrs(attrs) normalized = {} Radiosonde::Wrapper::Alarm::ATTRIBUTES_WITHOUT_NAME.each do |name| unless (value = attrs[name]).nil? normalized[name] = value end end return normalized end |
Instance Method Details
#delete ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/radiosonde/wrapper/alarm.rb', line 71 def delete log(:info, 'Delete Alarm', :red, self.alarm_name) unless @options[:dry_run] @alarm.delete @cloud_watch.modify! end end |
#eql?(dsl) ⇒ Boolean
53 54 55 |
# File 'lib/radiosonde/wrapper/alarm.rb', line 53 def eql?(dsl) diff(dsl).empty? end |
#update(dsl) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/radiosonde/wrapper/alarm.rb', line 57 def update(dsl) delta = diff(dsl) old_attrs = Hash[delta.map {|k, v| [k, v[:old]] }] new_attrs = Hash[delta.map {|k, v| [k, v[:new]] }] log(:info, 'Update Alarm', :green) log(:info, " #{self.alarm_name}:\n".green + Radiosonde::Utils.diff(old_attrs, new_attrs, :color => @options[:color], :indent => ' '), false) unless @options[:dry_run] opts = self.class.normalize_attrs(dsl) @alarm.update(opts) @cloud_watch.modify! end end |