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

[aws] 1 index indexed_param and remove extra argument

This commit is contained in:
geemus 2010-09-22 17:20:59 -07:00
parent e00e810a8e
commit 972c2792ea
6 changed files with 11 additions and 11 deletions

View file

@ -11,13 +11,13 @@ module Fog
service 'simpledb'
service 'storage'
def self.indexed_param(key, values, offset = 0)
def self.indexed_param(key, values)
params = {}
unless key.include?('%d')
key << '.%d'
end
[*values].each_with_index do |value, index|
params[format(key, index + offset)] = value
params[format(key, index + 1)] = value
end
params
end

View file

@ -12,8 +12,8 @@ module Fog
#
def modify_snapshot_attribute(snapshot_id, attribute, operation_type, options = {})
params = {}
params.merge!(AWS.indexed_param('UserId', options['UserId'], 1))
params.merge!(AWS.indexed_param('UserGroup', options['UserGroup'], 1))
params.merge!(AWS.indexed_param('UserId', options['UserId']))
params.merge!(AWS.indexed_param('UserGroup', options['UserGroup']))
request({
'Action' => 'ModifySnapshotAttribute',
'Attribute' => attribute,

View file

@ -22,7 +22,7 @@ module Fog
# * 'CreateLoadBalancerResult'<~Hash>:
# * 'DNSName'<~String> - DNS name for the newly created ELB
def create_load_balancer(availability_zones, lb_name, listeners)
params = ELB.indexed_param('AvailabilityZones.member', [*availability_zones], 1)
params = ELB.indexed_param('AvailabilityZones.member', [*availability_zones])
listener_protocol = []
listener_lb_port = []
@ -33,9 +33,9 @@ module Fog
listener_instance_port.push(listener['InstancePort'])
end
params.merge!(AWS.indexed_param('Listeners.member.%d.Protocol', listener_protocol, 1))
params.merge!(AWS.indexed_param('Listeners.member.%d.LoadBalancerPort', listener_lb_port, 1))
params.merge!(AWS.indexed_param('Listeners.member.%d.InstancePort', listener_instance_port, 1))
params.merge!(AWS.indexed_param('Listeners.member.%d.Protocol', listener_protocol))
params.merge!(AWS.indexed_param('Listeners.member.%d.LoadBalancerPort', listener_lb_port))
params.merge!(AWS.indexed_param('Listeners.member.%d.InstancePort', listener_instance_port))
request({
'Action' => 'CreateLoadBalancer',

View file

@ -20,7 +20,7 @@ module Fog
# * 'Instances'<~Array> - array of hashes describing instances currently enabled
# * 'InstanceId'<~String>
def deregister_instances_from_load_balancer(instance_ids, lb_name)
params = AWS.indexed_param('Instances.member.%d.InstanceId', [*instance_ids], 1)
params = AWS.indexed_param('Instances.member.%d.InstanceId', [*instance_ids])
request({
'Action' => 'DeregisterInstancesFromLoadBalancer',
'LoadBalancerName' => lb_name,

View file

@ -23,7 +23,7 @@ module Fog
# * 'InstanceId'<~String>
# * 'ReasonCode'<~String>
def describe_instance_health(lb_name, instance_ids = [])
params = AWS.indexed_param('Instances.member.%d.InstanceId', [*instance_ids], 1)
params = AWS.indexed_param('Instances.member.%d.InstanceId', [*instance_ids])
request({
'Action' => 'DescribeInstanceHealth',
'LoadBalancerName' => lb_name,

View file

@ -38,7 +38,7 @@ module Fog
# * 'AvailabilityZones'<~Array> - list of availability zones covered by this load balancer
# * 'Instances'<~Array> - list of instances that the load balancer balances between
def describe_load_balancers(lb_name = [])
params = AWS.indexed_param('LoadBalancerNames.member', [*lb_name], 1)
params = AWS.indexed_param('LoadBalancerNames.member', [*lb_name])
request({
'Action' => 'DescribeLoadBalancers',
:parser => Fog::Parsers::AWS::ELB::DescribeLoadBalancers.new