From 44decff5fb93e43c1a602d26ee81d777e6321ab3 Mon Sep 17 00:00:00 2001 From: Jens Braeuer Date: Tue, 4 Oct 2011 15:38:01 +0200 Subject: [PATCH] [aws|cloudwatch] Add mocked version of put_metric_alarm. --- .../requests/cloud_watch/put_metric_alarm.rb | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/fog/aws/requests/cloud_watch/put_metric_alarm.rb b/lib/fog/aws/requests/cloud_watch/put_metric_alarm.rb index 9792e6dea..5ea7e2075 100644 --- a/lib/fog/aws/requests/cloud_watch/put_metric_alarm.rb +++ b/lib/fog/aws/requests/cloud_watch/put_metric_alarm.rb @@ -57,20 +57,16 @@ module Fog # See: Fog::AWS::CloudWatch::Real.put_metric_alarm() # - def put_metric_alarm(alarm_name, actions, metric) - if alarm_name.nil? or alarm_name.empty? - raise Fog::Compute::AWS::Error.new("The request must contain the parameter 'alarm_name'") - end - - supported_actions = [ "InsufficientData", "OK", "Alarm" ] - found_actions = actions.keys.select {|key| supported_actions.include? key } + def put_metric_alarm(options) + supported_actions = [ "InsufficientDataActions", "OKActions", "AlarmActions" ] + found_actions = options.keys.select {|key| supported_actions.include? key } if found_actions.empty? - raise Fog::Compute::AWS::Error.new("The request must contain a supported action") + raise Fog::Compute::AWS::Error.new("The request must contain at least one of #{supported_actions.join(", ")}'") end - metric_requirements = [ "ComparisonOperator", "EvaluationPeriods", "Namespace", "Period", "Statistic", "Threshold" ] - metric_requirements.each do |req| - unless metric.has_key?(req) + requirements = [ "AlarmName", "ComparisonOperator", "EvaluationPeriods", "Namespace", "Period", "Statistic", "Threshold" ] + requirements.each do |req| + unless options.has_key?(req) raise Fog::Compute::AWS::Error.new("The request must contain a the parameter '%s'" % req) end end