mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|cloudwatch] Add mocked version of put_metric_alarm.
This commit is contained in:
parent
bbc2a8aa24
commit
44decff5fb
1 changed files with 7 additions and 11 deletions
|
@ -57,20 +57,16 @@ module Fog
|
||||||
|
|
||||||
# See: Fog::AWS::CloudWatch::Real.put_metric_alarm()
|
# See: Fog::AWS::CloudWatch::Real.put_metric_alarm()
|
||||||
#
|
#
|
||||||
def put_metric_alarm(alarm_name, actions, metric)
|
def put_metric_alarm(options)
|
||||||
if alarm_name.nil? or alarm_name.empty?
|
supported_actions = [ "InsufficientDataActions", "OKActions", "AlarmActions" ]
|
||||||
raise Fog::Compute::AWS::Error.new("The request must contain the parameter 'alarm_name'")
|
found_actions = options.keys.select {|key| supported_actions.include? key }
|
||||||
end
|
|
||||||
|
|
||||||
supported_actions = [ "InsufficientData", "OK", "Alarm" ]
|
|
||||||
found_actions = actions.keys.select {|key| supported_actions.include? key }
|
|
||||||
if found_actions.empty?
|
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
|
end
|
||||||
|
|
||||||
metric_requirements = [ "ComparisonOperator", "EvaluationPeriods", "Namespace", "Period", "Statistic", "Threshold" ]
|
requirements = [ "AlarmName", "ComparisonOperator", "EvaluationPeriods", "Namespace", "Period", "Statistic", "Threshold" ]
|
||||||
metric_requirements.each do |req|
|
requirements.each do |req|
|
||||||
unless metric.has_key?(req)
|
unless options.has_key?(req)
|
||||||
raise Fog::Compute::AWS::Error.new("The request must contain a the parameter '%s'" % req)
|
raise Fog::Compute::AWS::Error.new("The request must contain a the parameter '%s'" % req)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue