1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00
fog--fog-aws/lib/fog/aws/models/cloud_watch/alarms.rb
Paulo Henrique Lopes Ribeiro 722bbdfa45 Remove unecessary requires
2015-04-06 11:23:35 -03:00

44 lines
1.1 KiB
Ruby

require 'fog/aws/models/cloud_watch/alarm'
module Fog
module AWS
class CloudWatch
class Alarms < Fog::Collection
model Fog::AWS::CloudWatch::Alarm
def all
data = []
next_token = nil
loop do
body = service.describe_alarms('NextToken' => next_token).body
data += body['DescribeAlarmsResult']['MetricAlarms']
next_token = body['ResponseMetadata']['NextToken']
break if next_token.nil?
end
load(data)
end
def get(identity)
data = service.describe_alarms('AlarmNames' => identity).body['DescribeAlarmsResult']['MetricAlarms'].first
new(data) unless data.nil?
end
#alarm_names is an array of alarm names
def delete(alarm_names)
service.delete_alarms(alarm_names)
true
end
def disable(alarm_names)
service.disable_alarm_actions(alarm_names)
true
end
def enable(alarm_names)
service.enable_alarm_actions(alarm_names)
true
end
end
end
end
end