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/compute/describe_reserved_instances.rb

61 lines
2.4 KiB
Ruby
Raw Normal View History

2010-03-16 18:46:21 -04:00
module Fog
module Compute
class AWS
2010-03-16 18:46:21 -04:00
class Real
require 'fog/aws/parsers/compute/describe_reserved_instances'
2010-06-12 18:31:17 -04:00
# Describe all or specified reserved instances
#
# ==== Parameters
# * filters<~Hash> - List of filters to limit results with
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'requestId'<~String> - Id of request
# * 'reservedInstancesSet'<~Array>:
# * 'availabilityZone'<~String> - availability zone of the instance
# * 'duration'<~Integer> - duration of reservation, in seconds
# * 'fixedPrice'<~Float> - purchase price of reserved instance
# * 'instanceType'<~String> - type of instance
# * 'instanceCount'<~Integer> - number of reserved instances
# * 'productDescription'<~String> - reserved instance description
# * 'reservedInstancesId'<~String> - id of the instance
# * 'start'<~Time> - start time for reservation
# * 'state'<~String> - state of reserved instance purchase, in .[pending-payment, active, payment-failed, retired]
# * 'usagePrice"<~Float> - usage price of reserved instances, per hour
#
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeReservedInstances.html]
def describe_reserved_instances(filters = {})
unless filters.is_a?(Hash)
Fog::Logger.warning("describe_reserved_instances with #{filters.class} param is deprecated, use describe_reserved_instances('reserved-instances-id' => []) instead [light_black](#{caller.first})[/]")
filters = {'reserved-instances-id' => [*filters]}
end
params = Fog::AWS.indexed_filters(filters)
request({
'Action' => 'DescribeReservedInstances',
:idempotent => true,
:parser => Fog::Parsers::Compute::AWS::DescribeReservedInstances.new
}.merge!(params))
end
end
class Mock
def describe_reserved_instances(filters = {})
response = Excon::Response.new
response.status = 200
response.body = {
'reservedInstancesSet' => self.data[:reserved_instances].values,
'requestId' => Fog::AWS::Mock.request_id
}
response
end
end
end
end
end