1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/aws/models/cloud_watch/alarm.rb

61 lines
2.1 KiB
Ruby
Raw Normal View History

require 'fog/core/model'
module Fog
module AWS
class CloudWatch
class Alarm < Fog::Model
2012-06-17 12:47:07 -04:00
identity :id, :aliases => 'AlarmName'
attribute :actions_enabled, :aliases => 'ActionsEnabled'
attribute :alarm_actions, :aliases => 'AlarmActions'
attribute :arn, :aliases => 'AlarmArn'
attribute :alarm_configuration_updated_timestamp, :aliases => 'AlarmConfigurationUpdatedTimestamp'
attribute :alarm_description, :aliases => 'AlarmDescription'
attribute :comparison_operator, :aliases => 'ComparisonOperator'
attribute :dimensions, :aliases => 'Dimensions'
attribute :evaluation_periods, :aliases => 'EvaluationPeriods'
attribute :insufficient_data_actions, :aliases => 'InsufficientDataActions'
attribute :metric_name, :aliases => 'MetricName'
attribute :namespace, :aliases => 'Namespace'
attribute :ok_actions, :aliases => 'OKActions'
2012-06-17 14:16:29 -04:00
attribute :period, :aliases => 'Period'
2012-06-17 12:47:07 -04:00
attribute :state_reason, :aliases => 'StateReason'
attribute :state_reason_data, :aliases => 'StateReasonData'
attribute :state_updated_timestamp, :aliases => 'StateUpdatedTimestamp'
attribute :state_value, :aliases => 'StateValue'
attribute :statistic, :aliases => 'Statistic'
attribute :threshold, :aliases => 'Threshold'
attribute :unit, :aliases => 'Unit'
2012-06-17 14:16:29 -04:00
def initialize(attributes)
attributes['EvaluationPeriods'] ||= 1
attributes['Namespace'] ||= 'AWS/EC2'
super
end
2012-06-17 12:47:07 -04:00
2012-06-17 14:16:29 -04:00
def save
requires :id
requires :comparison_operator
requires :evaluation_periods
requires :metric_name
requires :namespace
requires :period
requires :statistic
requires :threshold
2012-06-17 12:47:07 -04:00
2012-06-17 14:16:29 -04:00
options = Hash[self.class.aliases.map { |key, value| [key, send(value)] }]
options.delete_if { |key, value| value.nil? }
2012-06-17 12:47:07 -04:00
2012-06-17 14:16:29 -04:00
connection.put_metric_alarm(options)
reload
end
2012-06-17 12:47:07 -04:00
2012-06-17 14:16:29 -04:00
def destroy
requires :id
connection.delete_alarms(id)
end
end
end
end
2011-10-03 18:34:59 -04:00
end