mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
consolidate the params with index building code
This commit is contained in:
parent
68209cb97b
commit
42dd49ad06
1 changed files with 13 additions and 15 deletions
|
@ -99,11 +99,7 @@ module Fog
|
||||||
# :instance_id<~String>:: instance for ip address
|
# :instance_id<~String>:: instance for ip address
|
||||||
# :public_ip<~String>:: ip address for instance
|
# :public_ip<~String>:: ip address for instance
|
||||||
def describe_addresses(public_ips = [])
|
def describe_addresses(public_ips = [])
|
||||||
params, index = {}, 1
|
params = indexed_params('PublicIp', public_ips)
|
||||||
for public_ip in [*public_ips]
|
|
||||||
params["PublicIp.#{index}"] = public_ip
|
|
||||||
index += 1
|
|
||||||
end
|
|
||||||
request({
|
request({
|
||||||
'Action' => 'DescribeAddresses'
|
'Action' => 'DescribeAddresses'
|
||||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeAddresses.new)
|
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeAddresses.new)
|
||||||
|
@ -120,12 +116,9 @@ module Fog
|
||||||
#
|
#
|
||||||
# ==== Returns
|
# ==== Returns
|
||||||
def describe_images(options = {})
|
def describe_images(options = {})
|
||||||
params, index = {}, 1
|
params = {}
|
||||||
if options[:image_id]
|
if options[:image_id]
|
||||||
for image in [*options[:image_id]]
|
params = indexed_params('ImageId', options[:image_id])
|
||||||
params["ImageId.#{index}"] = image
|
|
||||||
image += 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
request({
|
request({
|
||||||
'Action' => 'DescribeImages',
|
'Action' => 'DescribeImages',
|
||||||
|
@ -156,11 +149,7 @@ module Fog
|
||||||
# :status<~String>:: Attachment state
|
# :status<~String>:: Attachment state
|
||||||
# :volume_id<~String>:: Reference to volume
|
# :volume_id<~String>:: Reference to volume
|
||||||
def describe_volumes(volume_ids = [])
|
def describe_volumes(volume_ids = [])
|
||||||
params, index = {}, 1
|
params = indexed_params('VolumeId', volume_ids)
|
||||||
for volume_id in [*volume_ids]
|
|
||||||
params["VolumeId.#{index}"] = volume_id
|
|
||||||
index += 1
|
|
||||||
end
|
|
||||||
request({
|
request({
|
||||||
'Action' => 'DescribeVolumes'
|
'Action' => 'DescribeVolumes'
|
||||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeVolumes.new)
|
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeVolumes.new)
|
||||||
|
@ -181,6 +170,15 @@ module Fog
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def indexed_params(name, params)
|
||||||
|
indexed, index = {}, 1
|
||||||
|
for param in [*params]
|
||||||
|
indexed["#{name}.#{index}"] = param
|
||||||
|
index += 1
|
||||||
|
end
|
||||||
|
indexed
|
||||||
|
end
|
||||||
|
|
||||||
def request(params, parser)
|
def request(params, parser)
|
||||||
params.merge!({
|
params.merge!({
|
||||||
'AWSAccessKeyId' => @aws_access_key_id,
|
'AWSAccessKeyId' => @aws_access_key_id,
|
||||||
|
|
Loading…
Add table
Reference in a new issue