Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #828 from fog/status_next_token

Status next token
Closes #800
  • Loading branch information...
commit efa6ee66cebd6c1888fb1dcca940f5cd0ef52638 2 parents fd36a78 + 4e6697d
@freeformz freeformz authored
View
8 lib/fog/aws.rb
@@ -60,6 +60,14 @@ def self.serialize_keys(key, value, options = {})
end
end
+ def self.indexed_request_param(name, values)
+ idx = -1
+ Array(values).inject({}) do |params, value|
+ params["#{name}.#{idx += 1}"] = value
+ params
+ end
+ end
+
def self.indexed_filters(filters)
params = {}
filters.keys.each_with_index do |key, key_index|
View
2  lib/fog/aws/parsers/compute/describe_instance_status.rb
@@ -86,7 +86,7 @@ def end_element(name)
@in_event = false
when 'instanceId', 'availabilityZone'
@instance[name] = value
- when 'requestId'
+ when 'nextToken', 'requestId'
@response[name] = value
end
end
View
12 lib/fog/aws/requests/compute/describe_instance_status.rb
@@ -5,10 +5,20 @@ class Real
require 'fog/aws/parsers/compute/describe_instance_status'
+ # http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInstanceStatus.html
+ #
def describe_instance_status(filters = {})
raise ArgumentError.new("Filters must be a hash, but is a #{filters.class}.") unless filters.is_a?(Hash)
+ next_token = filters.delete('nextToken') || filters.delete('NextToken')
+ max_results = filters.delete('maxResults') || filters.delete('MaxResults')
+
+ params = Fog::AWS.indexed_request_param('InstanceId', filters.delete('InstanceId'))
+
+ params.merge!(Fog::AWS.indexed_filters(filters))
+
+ params['NextToken'] = next_token if next_token
+ params['MaxResults'] = max_results if max_results
- params = Fog::AWS.indexed_filters(filters)
request({
'Action' => 'DescribeInstanceStatus',
:idempotent => true,
View
11 lib/fog/aws/requests/compute/describe_volume_status.rb
@@ -10,19 +10,14 @@ def describe_volume_status(filters = {})
raise ArgumentError.new("Filters must be a hash, but is a #{filters.class}.") unless filters.is_a?(Hash)
next_token = filters.delete('nextToken') || filters.delete('NextToken')
max_results = filters.delete('maxResults') || filters.delete('MaxResults')
- volume_ids = filters.delete('VolumeId')
- params = Fog::AWS.indexed_filters(filters)
+ params = Fog::AWS.indexed_request_param('VolumeId', filters.delete('VolumeId'))
+
+ params.merge!(Fog::AWS.indexed_filters(filters))
params['NextToken'] = next_token if next_token
params['MaxResults'] = max_results if max_results
- Array(volume_ids).inject(1) do |idx, vid|
- params["VolumeId.#{idx}"] = vid
- idx += 1
- end
-
- pp params
request({
'Action' => 'DescribeVolumeStatus',
:idempotent => true,
Please sign in to comment.
Something went wrong with that request. Please try again.