1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
module Fog
module AWS
class ELB
class Real
require 'fog/aws/parsers/elb/describe_load_balancer_policies'
# Describe all or specified load balancer policies
#
# ==== Parameters
# * lb_name<~String> - The mnemonic name associated with the LoadBalancer. If no name is specified, the operation returns the attributes of either all the sample policies pre-defined by Elastic Load Balancing or the specified sample polices.
# * names<~Array> - The names of LoadBalancer policies you've created or Elastic Load Balancing sample policy names.
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'ResponseMetadata'<~Hash>:
# * 'RequestId'<~String> - Id of request
# * 'DescribeLoadBalancerPoliciesResult'<~Hash>:
# * 'PolicyDescriptions'<~Array>
# * 'PolicyAttributeDescriptions'<~Array>
# * 'AttributeName'<~String> - The name of the attribute associated with the policy.
# * 'AttributeValue'<~String> - The value of the attribute associated with the policy.
# * 'PolicyName'<~String> - The name mof the policy associated with the LoadBalancer.
# * 'PolicyTypeName'<~String> - The name of the policy type.
def describe_load_balancer_policies(lb_name = nil, names = [])
params = Fog::AWS.indexed_param('PolicyNames.member', [*names])
request({
'Action' => 'DescribeLoadBalancerPolicies',
'LoadBalancerName' => lb_name,
:parser => Fog::Parsers::AWS::ELB::DescribeLoadBalancerPolicies.new
}.merge!(params))
end
end
class Mock
def describe_load_balancer_policies(lb_name = nil, names = [])
if lb_name
raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name]
names = [*names]
policies = if names.any?
names.map do |name|
raise Fog::AWS::ELB::PolicyNotFound unless policy = load_balancer['Policies']['Proper'].find { |p| p['PolicyName'] == name }
policy.dup
end.compact
else
load_balancer['Policies']['Proper']
end
else
policies = []
end
response = Excon::Response.new
response.status = 200
response.body = {
'ResponseMetadata' => {
'RequestId' => Fog::AWS::Mock.request_id
},
'DescribeLoadBalancerPoliciesResult' => {
'PolicyDescriptions' => policies
}
}
response
end
end
end
end
end
|