Class: Fog::AWS::CloudWatch::Alarm

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/aws/models/cloud_watch/alarm.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Fog::Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one

Constructor Details

#initialize(attributes) ⇒ Alarm

Returns a new instance of Alarm.



30
31
32
33
34
# File 'lib/fog/aws/models/cloud_watch/alarm.rb', line 30

def initialize(attributes)
  attributes['EvaluationPeriods'] ||= 1
  attributes['Namespace']         ||= 'AWS/EC2'
  super
end

Instance Method Details

#destroyObject



53
54
55
56
# File 'lib/fog/aws/models/cloud_watch/alarm.rb', line 53

def destroy
  requires :id
  connection.delete_alarms(id)
end

#saveObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fog/aws/models/cloud_watch/alarm.rb', line 36

def save
  requires :id
  requires :comparison_operator
  requires :evaluation_periods
  requires :metric_name
  requires :namespace
  requires :period
  requires :statistic
  requires :threshold

  options = Hash[self.class.aliases.map { |key, value| [key, send(value)] }]
  options.delete_if { |key, value| value.nil? }

  connection.put_metric_alarm(options)
  reload
end