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

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

Instance Method Summary collapse

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
  service.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? }

  service.put_metric_alarm(options)
  reload
end