1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00

Handle missing parameters in describe_spot_price_history request

This commit is contained in:
Miguel Landaeta 2015-04-04 20:03:50 -03:00
parent f591ac63a5
commit 2a5e9c85d5
3 changed files with 30 additions and 3 deletions

View file

@ -15,7 +15,7 @@ module Fog
when 'item'
@response['spotPriceHistorySet'] << @spot_price
@spot_price = {}
when 'requestId'
when 'requestId', 'nextToken'
@response[name] = value
when 'spotPrice'
@spot_price[name] = value.to_f

View file

@ -8,6 +8,14 @@ module Fog
#
# ==== Parameters
# * filters<~Hash> - List of filters to limit results with
# * filters and/or the following
# * 'AvailabilityZone'<~String> - availability zone of offering
# * 'InstanceType'<~Array> - instance types of offering
# * 'ProductDescription'<~Array> - basic product descriptions
# * 'StartTime'<~Time> - The date and time, up to the past 90 days, from which to start retrieving the price history data
# * 'EndTime'<~Time> - The date and time, up to the current date, from which to stop retrieving the price history data
# * 'MaxResults'<~Integer> - The maximum number of results to return for the request in a single page
# * 'NextToken'<~String> - The token to retrieve the next page of results
#
# ==== Returns
# * response<~Excon::Response>:
@ -19,10 +27,28 @@ module Fog
# * 'productDescription'<~String> - general description of AMI
# * 'spotPrice'<~Float> - maximum price to launch one or more instances
# * 'timestamp'<~Time> - date and time of request creation
# * 'nextToken'<~String> - token to retrieve the next page of results
#
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSpotPriceHistory.html]
def describe_spot_price_history(filters = {})
params = Fog::AWS.indexed_filters(filters)
params = {}
for key in %w(AvailabilityZone StartTime EndTime MaxResults NextToken)
if filters.is_a?(Hash) && filters.key?(key)
params[key] = filters.delete(key)
end
end
if instance_types = filters.delete('InstanceType')
params.merge!(Fog::AWS.indexed_param('InstanceType', [*instance_types]))
end
if product_descriptions = filters.delete('ProductDescription')
params.merge!(Fog::AWS.indexed_param('ProductDescription', [*product_descriptions]))
end
params.merge!(Fog::AWS.indexed_filters(filters))
request({
'Action' => 'DescribeSpotPriceHistory',
:idempotent => true,

View file

@ -8,7 +8,8 @@ Shindo.tests('Fog::Compute[:aws] | spot price history requests', ['aws']) do
'productDescription' => String,
'timestamp' => Time
}],
'requestId' => String
'requestId' => String,
'nextToken' => Fog::Nullable::String
}
tests('success') do