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/requests/cloud_watch/delete_alarms.rb

49 lines
1.4 KiB
Ruby
Raw Normal View History

2011-09-29 17:55:48 -04:00
module Fog
module AWS
class CloudWatch
class Real
2011-09-30 14:49:10 -04:00
2011-09-29 17:55:48 -04:00
require 'fog/aws/parsers/cloud_watch/delete_alarms'
2011-09-30 14:49:10 -04:00
2011-09-29 17:55:48 -04:00
# Delete a list of alarms
# ==== Options
2011-09-30 14:49:10 -04:00
# * AlarmNames<~Array>: A list of alarms to be deleted
2011-09-29 17:55:48 -04:00
#
# ==== Returns
# * response<~Excon::Response>:
#
# ==== See Also
# http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/index.html?API_DeleteAlarms.html
#
2011-09-30 14:49:10 -04:00
def delete_alarms(alarm_names)
2011-10-03 19:12:45 -04:00
options = {}
2011-09-30 14:49:10 -04:00
options.merge!(AWS.indexed_param('AlarmNames.member.%d', [*alarm_names]))
2011-09-29 17:55:48 -04:00
request({
'Action' => 'DeleteAlarms',
:parser => Fog::Parsers::AWS::CloudWatch::DeleteAlarms.new
}.merge(options))
end
2012-06-17 14:16:29 -04:00
end
class Mock
def delete_alarms(alarm_names)
[*alarm_names].each do |alarm_name|
unless data[:metric_alarms].has_key?(alarm_name)
raise Fog::AWS::AutoScaling::NotFound, "The alarm '#{alarm_name}' does not exist."
end
end
[*alarm_names].each { |alarm_name| data[:metric_alarms].delete(alarm_name) }
response = Excon::Response.new
response.status = 200
response.body = {
'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }
}
response
end
end
2011-09-29 17:55:48 -04:00
end
end
2011-10-03 18:34:59 -04:00
end