Class: Fog::AWS::CloudWatch::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/rackspace-fog/aws/cloud_watch.rb,
lib/rackspace-fog/aws/requests/cloud_watch/put_metric_alarm.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



39
40
# File 'lib/rackspace-fog/aws/cloud_watch.rb', line 39

def initialize(options={})
end

Instance Method Details

#put_metric_alarm(options) ⇒ Object

See: Fog::AWS::CloudWatch::Real.put_metric_alarm()



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/rackspace-fog/aws/requests/cloud_watch/put_metric_alarm.rb', line 60

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 at least one of #{supported_actions.join(", ")}'")
  end

  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

  response = Excon::Response.new
  response.status = 200
  response.body = {
    'requestId' => Fog::AWS::Mock.request_id
  }
  response
end