2011-09-30 17:10:40 -04:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/aws/models/cloud_watch/alarm'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class CloudWatch
|
|
|
|
|
|
|
|
class Alarms < Fog::Collection
|
|
|
|
model Fog::AWS::CloudWatch::Alarm
|
2012-06-17 12:47:07 -04:00
|
|
|
|
|
|
|
def all
|
|
|
|
data = []
|
|
|
|
next_token = nil
|
|
|
|
loop do
|
2012-12-22 18:31:48 -05:00
|
|
|
result = service.describe_alarms('NextToken' => next_token).body['DescribeAlarmsResult']
|
2012-06-17 12:47:07 -04:00
|
|
|
data += result['MetricAlarms']
|
|
|
|
next_token = result['NextToken']
|
|
|
|
break if next_token.nil?
|
|
|
|
end
|
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(identity)
|
2012-12-22 18:31:48 -05:00
|
|
|
data = service.describe_alarms('AlarmNames' => identity).body['DescribeAlarmsResult']['MetricAlarms'].first
|
2012-06-17 12:47:07 -04:00
|
|
|
new(data) unless data.nil?
|
|
|
|
end
|
|
|
|
|
2011-10-03 19:12:45 -04:00
|
|
|
#alarm_names is an array of alarm names
|
2011-09-30 17:10:40 -04:00
|
|
|
def delete(alarm_names)
|
2012-12-22 18:31:48 -05:00
|
|
|
service.delete_alarms(alarm_names)
|
2011-09-30 17:10:40 -04:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def disable(alarm_names)
|
2012-12-22 18:31:48 -05:00
|
|
|
service.disable_alarm_actions(alarm_names)
|
2011-09-30 17:10:40 -04:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def enable(alarm_names)
|
2012-12-22 18:31:48 -05:00
|
|
|
service.enable_alarm_actions(alarm_names)
|
2011-09-30 17:10:40 -04:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|