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/elb/modify_load_balancer_attributes.rb
Paul Thornthwaite 2e0b7e545a Standardise empty lines throughout codebase
Done with `rubocop --auto-correct --only EmptyLineBetweenDefs,EmptyLines,EmptyLinesAroundBody`
2014-05-26 14:20:02 +01:00

59 lines
2.1 KiB
Ruby

module Fog
module AWS
class ELB
class Real
require 'fog/aws/parsers/elb/empty'
# Sets attributes of the load balancer
#
# Currently the only attributes that can be set are whether CrossZoneLoadBalancing
# or ConnectionDraining are enabled. You can also set the Timeout for ConnectionDraining.
#
# http://docs.aws.amazon.com/ElasticLoadBalancing/latest/APIReference/API_ModifyLoadBalancerAttributes.html
# ==== Parameters
# * lb_name<~String> - Name of the ELB
# * options<~Hash>
# * 'ConnectionDraining'<~Hash>:
# * 'Enabled'<~Boolean> whether to enable connection draining
# * 'Timeout'<~Integer> max time to keep existing conns open before deregistering instances
# * 'CrossZoneLoadBalancing'<~Hash>:
# * 'Enabled'<~Boolean> whether to enable cross zone load balancing
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'ResponseMetadata'<~Hash>:
# * 'RequestId'<~String> - Id of request
def modify_load_balancer_attributes(lb_name, options)
attributes = Fog::AWS.serialize_keys 'LoadBalancerAttributes', options
request(attributes.merge(
'Action' => 'ModifyLoadBalancerAttributes',
'LoadBalancerName' => lb_name,
:parser => Fog::Parsers::AWS::ELB::Empty.new
))
end
end
class Mock
def modify_load_balancer_attributes(lb_name, attributes)
raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name]
if attributes['CrossZoneLoadBalancing'] || attributes['ConnectionDraining']
load_balancer['LoadBalancerAttributes'].merge! attributes
end
response = Excon::Response.new
response.status = 200
response.body = {
"ResponseMetadata" => {
"RequestId" => Fog::AWS::Mock.request_id
}
}
response
end
end
end
end
end