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/compute/requests/aws/monitor_instances.rb

53 lines
1.8 KiB
Ruby
Raw Normal View History

2011-03-11 16:06:44 -05:00
module Fog
module AWS
class Compute
class Real
require 'fog/compute/parsers/aws/monitor_unmonitor_instances'
# Monitor specified instance
# http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-MonitorInstances.html
#
# ==== Parameters
# * instance_ids<~Array> - Arrays of instances Ids to monitor
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'requestId'<~String> - Id of request
# * 'instancesSet': http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-MonitorInstancesResponseSetItemType.html
def monitor_instances(instance_ids)
params = AWS.indexed_param('InstanceId', instance_ids)
request({
'Action' => 'MonitorInstances',
:idempotent => true,
:parser => Fog::Parsers::AWS::Compute::MonitorUnmonitorInstances.new
}.merge!(params))
end
end
class Mock
def monitor_instances(instance_ids)
response = Excon::Response.new
response.status = 200
[*instance_ids].each do |instance_id|
if instance = @data[:instances][instance_id]
instance['monitoring']['state'] = 'enabled'
else
raise Fog::AWS::Compute::NotFound.new("The instance ID '#{instance_ids}' does not exist")
end
end
instances_set = [*instance_ids].inject([]) { |memo, id| memo << {'instanceId' => id, 'monitoring' => 'enabled'} }
response.body = {'requestId' => 'some_request_id', 'instancesSet' => instances_set}
response
2011-03-11 16:06:44 -05:00
end
end
end
end
end