fog-aws 3.5.2 → 3.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +16 -3
- data/LICENSE.md +1 -1
- data/README.md +39 -6
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/fog-aws.gemspec +2 -2
- data/lib/fog/aws.rb +4 -0
- data/lib/fog/aws/elasticache.rb +4 -2
- data/lib/fog/aws/elb.rb +1 -1
- data/lib/fog/aws/elbv2.rb +72 -0
- data/lib/fog/aws/models/compute/flavors.rb +1544 -122
- data/lib/fog/aws/models/compute/snapshot.rb +7 -6
- data/lib/fog/aws/models/compute/vpc.rb +7 -1
- data/lib/fog/aws/models/storage/directory.rb +0 -1
- data/lib/fog/aws/models/storage/file.rb +3 -0
- data/lib/fog/aws/parsers/compute/create_snapshot.rb +1 -1
- data/lib/fog/aws/parsers/compute/create_subnet.rb +33 -6
- data/lib/fog/aws/parsers/compute/describe_subnets.rb +33 -6
- data/lib/fog/aws/parsers/dns/create_hosted_zone.rb +1 -1
- data/lib/fog/aws/parsers/dns/get_hosted_zone.rb +3 -3
- data/lib/fog/aws/parsers/dns/list_hosted_zones.rb +3 -1
- data/lib/fog/aws/parsers/elbv2/create_load_balancer.rb +88 -0
- data/lib/fog/aws/parsers/elbv2/describe_listeners.rb +110 -0
- data/lib/fog/aws/parsers/elbv2/describe_load_balancers.rb +88 -0
- data/lib/fog/aws/parsers/elbv2/describe_tags.rb +53 -0
- data/lib/fog/aws/parsers/elbv2/empty.rb +10 -0
- data/lib/fog/aws/parsers/storage/get_object_tagging.rb +33 -0
- data/lib/fog/aws/parsers/sts/assume_role_with_web_identity.rb +1 -1
- data/lib/fog/aws/requests/compute/create_vpc.rb +2 -2
- data/lib/fog/aws/requests/elbv2/add_tags.rb +45 -0
- data/lib/fog/aws/requests/elbv2/create_load_balancer.rb +160 -0
- data/lib/fog/aws/requests/elbv2/describe_listeners.rb +38 -0
- data/lib/fog/aws/requests/elbv2/describe_load_balancers.rb +100 -0
- data/lib/fog/aws/requests/elbv2/describe_tags.rb +50 -0
- data/lib/fog/aws/requests/elbv2/remove_tags.rb +45 -0
- data/lib/fog/aws/requests/storage/get_object_tagging.rb +41 -0
- data/lib/fog/aws/requests/storage/put_object_tagging.rb +42 -0
- data/lib/fog/aws/requests/sts/assume_role_with_web_identity.rb +7 -6
- data/lib/fog/aws/storage.rb +2 -0
- data/lib/fog/aws/version.rb +1 -1
- data/tests/parsers/elbv2/create_load_balancer_tests.rb +48 -0
- data/tests/parsers/elbv2/describe_listeners_tests.rb +76 -0
- data/tests/parsers/elbv2/describe_load_balancers_tests.rb +54 -0
- data/tests/parsers/elbv2/describe_tags_tests.rb +35 -0
- data/tests/requests/compute/vpc_tests.rb +6 -0
- data/tests/requests/elbv2/helper.rb +66 -0
- data/tests/requests/elbv2/load_balancer_tests.rb +50 -0
- metadata +35 -10
@@ -0,0 +1,53 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module AWS
|
4
|
+
module ELBV2
|
5
|
+
class DescribeTags < Fog::Parsers::Base
|
6
|
+
def reset
|
7
|
+
@this_key = nil
|
8
|
+
@this_value = nil
|
9
|
+
@tags = Hash.new
|
10
|
+
@response = { 'DescribeTagsResult' => { 'TagDescriptions' => [] }, 'ResponseMetadata' => {} }
|
11
|
+
@in_tags = false
|
12
|
+
end
|
13
|
+
|
14
|
+
def start_element(name, attrs = [])
|
15
|
+
super
|
16
|
+
case name
|
17
|
+
when 'member'
|
18
|
+
unless @in_tags
|
19
|
+
@resource_arn = nil
|
20
|
+
@tags = {}
|
21
|
+
end
|
22
|
+
when 'Tags'
|
23
|
+
@in_tags = true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def end_element(name)
|
28
|
+
super
|
29
|
+
case name
|
30
|
+
when 'member'
|
31
|
+
if @in_tags
|
32
|
+
@tags[@this_key] = @this_value
|
33
|
+
@this_key, @this_value = nil, nil
|
34
|
+
else
|
35
|
+
@response['DescribeTagsResult']['TagDescriptions'] << { 'Tags' => @tags, 'ResourceArn' => @resource_arn }
|
36
|
+
end
|
37
|
+
when 'Key'
|
38
|
+
@this_key = value
|
39
|
+
when 'Value'
|
40
|
+
@this_value = value
|
41
|
+
when 'ResourceArn'
|
42
|
+
@resource_arn = value
|
43
|
+
when 'RequestId'
|
44
|
+
@response['ResponseMetadata'][name] = value
|
45
|
+
when 'Tags'
|
46
|
+
@in_tags = false
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module AWS
|
4
|
+
module Storage
|
5
|
+
class GetObjectTagging < Fog::Parsers::Base
|
6
|
+
def reset
|
7
|
+
@in_tag = {}
|
8
|
+
@response = {'ObjectTagging' => {}}
|
9
|
+
end
|
10
|
+
|
11
|
+
def start_element(name, *args)
|
12
|
+
super
|
13
|
+
if name == 'Tag'
|
14
|
+
@in_tag = {}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def end_element(name)
|
19
|
+
case name
|
20
|
+
when 'Tag'
|
21
|
+
@response['ObjectTagging'].merge!(@in_tag)
|
22
|
+
@in_tag = {}
|
23
|
+
when 'Key'
|
24
|
+
@in_tag[value] = nil
|
25
|
+
when 'Value'
|
26
|
+
@in_tag = {@in_tag.keys.first => value}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -11,7 +11,6 @@ module Fog
|
|
11
11
|
# * options<~Hash>:
|
12
12
|
# * InstanceTenancy<~String> - The allowed tenancy of instances launched into the VPC. A value of default
|
13
13
|
# means instances can be launched with any tenancy; a value of dedicated means instances must be launched with tenancy as dedicated.
|
14
|
-
# please not that the documentation is incorrect instanceTenancy will not work while InstanceTenancy will
|
15
14
|
#
|
16
15
|
# === Returns
|
17
16
|
# * response<~Excon::Response>:
|
@@ -54,7 +53,8 @@ module Fog
|
|
54
53
|
'classicLinkEnabled' => false,
|
55
54
|
'classicLinkDnsSupport' => false,
|
56
55
|
'cidrBlockAssociationSet' => [{ 'cidrBlock' => cidrBlock, 'state' => 'associated', 'associationId' => "vpc-cidr-assoc-#{vpc_id}" }],
|
57
|
-
'ipv6CidrBlockAssociationSet' => []
|
56
|
+
'ipv6CidrBlockAssociationSet' => [],
|
57
|
+
'instanceTenancy' => options['InstanceTenancy'] || 'default'
|
58
58
|
}
|
59
59
|
self.data[:vpcs].push(vpc)
|
60
60
|
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class ELBV2
|
4
|
+
class Real
|
5
|
+
require 'fog/aws/parsers/elbv2/empty'
|
6
|
+
|
7
|
+
# adds tags to a load balancer instance
|
8
|
+
# http://docs.aws.amazon.com/ElasticLoadBalancing/latest/APIReference/API_AddTags.html
|
9
|
+
# ==== Parameters
|
10
|
+
# * resource_arn <~String> - The Amazon Resource Name (ARN) of the resource
|
11
|
+
# * tags <~Hash> A Hash of (String) key-value pairs
|
12
|
+
# ==== Returns
|
13
|
+
# * response<~Excon::Response>:
|
14
|
+
# * body<~Hash>:
|
15
|
+
def add_tags(resource_arn, tags)
|
16
|
+
keys = tags.keys.sort
|
17
|
+
values = keys.map {|key| tags[key]}
|
18
|
+
request({
|
19
|
+
'Action' => 'AddTags',
|
20
|
+
'ResourceArns.member.1' => resource_arn,
|
21
|
+
:parser => Fog::Parsers::AWS::ELBV2::Empty.new,
|
22
|
+
}.merge(Fog::AWS.indexed_param('Tags.member.%d.Key', keys))
|
23
|
+
.merge(Fog::AWS.indexed_param('Tags.member.%d.Value', values)))
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
class Mock
|
29
|
+
def add_tags(resource_arn, tags)
|
30
|
+
response = Excon::Response.new
|
31
|
+
if self.data[:load_balancers_v2][resource_arn]
|
32
|
+
self.data[:tags][resource_arn].merge! tags
|
33
|
+
response.status = 200
|
34
|
+
response.body = {
|
35
|
+
"ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id }
|
36
|
+
}
|
37
|
+
response
|
38
|
+
else
|
39
|
+
raise Fog::AWS::ELBV2::NotFound.new("Elastic load balancer #{resource_arn} not found")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class ELBV2
|
4
|
+
class Real
|
5
|
+
require 'fog/aws/parsers/elbv2/create_load_balancer'
|
6
|
+
|
7
|
+
# Create a new Elastic Load Balancer
|
8
|
+
#
|
9
|
+
# ==== Parameters
|
10
|
+
# * name<~String> - The name of the load balancer.
|
11
|
+
# This name must be unique per region per account, can have a maximum of 32 characters, must contain only alphanumeric characters or hyphens,
|
12
|
+
# must not begin or end with a hyphen, and must not begin with "internal-".
|
13
|
+
# - Required: Yes
|
14
|
+
# * options<~Hash>:
|
15
|
+
# * ip_address_type<~String> - [Application Load Balancers] The type of IP addresses used by the subnets for your load balancer.
|
16
|
+
# The possible values are ipv4 (for IPv4 addresses) and dualstack (for IPv4 and IPv6 addresses).
|
17
|
+
# Internal load balancers must use ipv4.
|
18
|
+
# - Required: No
|
19
|
+
# * scheme<~String> - The default is an Internet-facing load balancer. Valid Values: internet-facing | internal
|
20
|
+
# - Required: No
|
21
|
+
# * security_groups<~Array> - The IDs of the security groups for the load balancer.
|
22
|
+
# - Required: No
|
23
|
+
# * subnet_mappings<~Array> - The IDs of the public subnets. You can specify only one subnet per Availability Zone. You must specify either subnets or subnet mappings.
|
24
|
+
# - [Application Load Balancers] You must specify subnets from at least two Availability Zones.
|
25
|
+
# You cannot specify Elastic IP addresses for your subnets.
|
26
|
+
# - [Network Load Balancers] You can specify subnets from one or more Availability Zones.
|
27
|
+
# You can specify one Elastic IP address per subnet if you need static IP addresses for your internet-facing load balancer.
|
28
|
+
# For internal load balancers, you can specify one private IP address per subnet from the IPv4 range of the subnet.
|
29
|
+
# - Required: No
|
30
|
+
# * subnets<~Array> - The IDs of the public subnets. You can specify only one subnet per Availability Zone. You must specify either subnets or subnet mappings.
|
31
|
+
# - [Application Load Balancers] You must specify subnets from at least two Availability Zones.
|
32
|
+
# - [Network Load Balancers] You can specify subnets from one or more Availability Zones.
|
33
|
+
# - Required: No
|
34
|
+
# * tags<~Hash> - One or more tags to assign to the load balancer.
|
35
|
+
# - Required: No
|
36
|
+
# * type<~String> - The type of load balancer. The default is application. Valid Values: application | network
|
37
|
+
# - Required: No
|
38
|
+
# ==== Returns
|
39
|
+
# * response<~Excon::Response>:
|
40
|
+
# * body<~Hash>:
|
41
|
+
# * 'ResponseMetadata'<~Hash>:
|
42
|
+
# * 'RequestId'<~String> - Id of request
|
43
|
+
# * 'CreateLoadBalancerResult'<~Hash>:
|
44
|
+
# * 'LoadBalancers'<~Array>
|
45
|
+
# * 'AvailabilityZones'<~Array>:
|
46
|
+
# * 'SubnetId'<~String> - ID of the subnet
|
47
|
+
# * 'ZoneName'<~String> - Name of the Availability Zone
|
48
|
+
# * 'LoadBalancerAddresses'<~Array>:
|
49
|
+
# * 'IpAddress'<~String> - IP address
|
50
|
+
# * 'AllocationId'<~String> - ID of the AWS allocation
|
51
|
+
# * 'CanonicalHostedZoneName'<~String> - name of the Route 53 hosted zone associated with the load balancer
|
52
|
+
# * 'CanonicalHostedZoneNameID'<~String> - ID of the Route 53 hosted zone associated with the load balancer
|
53
|
+
# * 'CreatedTime'<~Time> - time load balancer was created
|
54
|
+
# * 'DNSName'<~String> - external DNS name of load balancer
|
55
|
+
# * 'LoadBalancerName'<~String> - name of load balancer
|
56
|
+
# * 'SecurityGroups'<~Array> - array of security group id
|
57
|
+
def create_load_balancer(name, options = {})
|
58
|
+
params = {}
|
59
|
+
params.merge!(Fog::AWS.indexed_param('Subnets.member.%d', options[:subnets]))
|
60
|
+
params.merge!(Fog::AWS.indexed_param('SecurityGroups.member.%d', options[:security_groups]))
|
61
|
+
params.merge!(Fog::AWS.serialize_keys('Scheme', options[:scheme]))
|
62
|
+
params.merge!(Fog::AWS.serialize_keys('Type', options[:type]))
|
63
|
+
params.merge!(Fog::AWS.serialize_keys('IpAddressType', options[:ip_address_type]))
|
64
|
+
|
65
|
+
|
66
|
+
unless options[:tags].nil?
|
67
|
+
tag_keys = options[:tags].keys.sort
|
68
|
+
tag_values = tag_keys.map { |key| options[:tags][key] }
|
69
|
+
params.merge!(Fog::AWS.indexed_param('Tags.member.%d.Key', tag_keys))
|
70
|
+
params.merge!(Fog::AWS.indexed_param('Tags.member.%d.Value', tag_values))
|
71
|
+
end
|
72
|
+
|
73
|
+
unless options[:subnet_mappings].nil?
|
74
|
+
subnet_ids = []
|
75
|
+
allocation_ids = []
|
76
|
+
private_ipv4_address = []
|
77
|
+
options[:subnet_mappings].each do |subnet_mapping|
|
78
|
+
subnet_ids.push(subnet_mapping[:subnet_id])
|
79
|
+
allocation_ids.push(subnet_mapping[:allocation_id])
|
80
|
+
private_ipv4_address.push(subnet_mapping[:private_ipv4_address])
|
81
|
+
end
|
82
|
+
params.merge!(Fog::AWS.indexed_param('SubnetMappings.member.%d.SubnetId', subnet_ids))
|
83
|
+
params.merge!(Fog::AWS.indexed_param('SubnetMappings.member.%d.AllocationId', allocation_ids))
|
84
|
+
params.merge!(Fog::AWS.indexed_param('SubnetMappings.member.%d.PrivateIPv4Address', private_ipv4_address))
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
request({
|
89
|
+
'Action' => 'CreateLoadBalancer',
|
90
|
+
'Name' => name,
|
91
|
+
:parser => Fog::Parsers::AWS::ELBV2::CreateLoadBalancer.new
|
92
|
+
}.merge!(params))
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
class Mock
|
97
|
+
def create_load_balancer(name, options = {})
|
98
|
+
response = Excon::Response.new
|
99
|
+
response.status = 200
|
100
|
+
|
101
|
+
raise Fog::AWS::ELBV2::IdentifierTaken if self.data[:load_balancers_v2].key? name
|
102
|
+
|
103
|
+
dns_name = Fog::AWS::ELBV2::Mock.dns_name(name, @region)
|
104
|
+
type = options[:type] || 'application'
|
105
|
+
load_balancer_arn = Fog::AWS::Mock.arn('elasticloadbalancing', self.data[:owner_id], "loadbalancer/#{type[0..2]}/#{name}/#{Fog::AWS::Mock.key_id}")
|
106
|
+
|
107
|
+
subnet_ids = options[:subnets] || []
|
108
|
+
region = if subnet_ids.any?
|
109
|
+
# using Hash here for Rubt 1.8.7 support.
|
110
|
+
Hash[
|
111
|
+
Fog::AWS::Compute::Mock.data.select do |_, region_data|
|
112
|
+
unless region_data[@aws_access_key_id].nil?
|
113
|
+
region_data[@aws_access_key_id][:subnets].any? do |region_subnets|
|
114
|
+
subnet_ids.include? region_subnets['subnetId']
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
].keys[0]
|
119
|
+
else
|
120
|
+
'us-east-1'
|
121
|
+
end
|
122
|
+
|
123
|
+
subnets = Fog::AWS::Compute::Mock.data[region][@aws_access_key_id][:subnets].select {|e| subnet_ids.include?(e["subnetId"]) }
|
124
|
+
availability_zones = subnets.map do |subnet|
|
125
|
+
{ "LoadBalancerAddresses"=>[], "SubnetId"=>subnet["subnetId"], "ZoneName"=>subnet["availabilityZone"]}
|
126
|
+
end
|
127
|
+
vpc_id = subnets.first['vpcId']
|
128
|
+
|
129
|
+
self.data[:tags] ||= {}
|
130
|
+
self.data[:tags][load_balancer_arn] = options[:tags] || {}
|
131
|
+
|
132
|
+
load_balancer = {
|
133
|
+
'AvailabilityZones' => availability_zones || [],
|
134
|
+
'Scheme' => options[:scheme] || 'internet-facing',
|
135
|
+
'SecurityGroups' => options[:security_groups] || [],
|
136
|
+
'CanonicalHostedZoneId' => '',
|
137
|
+
'CreatedTime' => Time.now,
|
138
|
+
'DNSName' => dns_name,
|
139
|
+
'VpcId' => vpc_id,
|
140
|
+
'Type' => type,
|
141
|
+
'State' => {'Code' => 'provisioning'},
|
142
|
+
'LoadBalancerArn' => load_balancer_arn,
|
143
|
+
'LoadBalancerName' => name
|
144
|
+
}
|
145
|
+
self.data[:load_balancers_v2][load_balancer_arn] = load_balancer
|
146
|
+
response.body = {
|
147
|
+
'ResponseMetadata' => {
|
148
|
+
'RequestId' => Fog::AWS::Mock.request_id
|
149
|
+
},
|
150
|
+
'CreateLoadBalancerResult' => {
|
151
|
+
'LoadBalancers' => [load_balancer]
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
response
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class ELBV2
|
4
|
+
class Real
|
5
|
+
require 'fog/aws/parsers/elbv2/describe_listeners'
|
6
|
+
|
7
|
+
# Describe all or specified load balancers
|
8
|
+
#
|
9
|
+
# ==== Parameters
|
10
|
+
# * 'LoadBalancerArn'<~String> - The Amazon Resource Name (ARN) of the load balancer
|
11
|
+
# * options<~Hash>
|
12
|
+
# * 'Marker'<String> - Indicates where to begin in your list of load balancers
|
13
|
+
#
|
14
|
+
# ==== Returns
|
15
|
+
# * response<~Excon::Response>:
|
16
|
+
# * body<~Hash>:
|
17
|
+
# * 'ResponseMetadata'<~Hash>:
|
18
|
+
# * 'RequestId'<~String> - Id of request
|
19
|
+
# * 'DescribeListenersResult'<~Hash>:
|
20
|
+
# * 'Listeners'<~Array>
|
21
|
+
# * 'LoadBalancerArn'<~String> - The Amazon Resource Name (ARN) of the load balancer
|
22
|
+
# * 'Protocol'<~String> - The protocol for connections from clients to the load balancer
|
23
|
+
# * 'Port'<~String> - The port on which the load balancer is listening
|
24
|
+
# * 'DefaultActions'<~Array> - The default actions for the listener
|
25
|
+
# * 'Type'<~String> - The type of action
|
26
|
+
# * 'TargetGroupArn'<~String> - The Amazon Resource Name (ARN) of the target group. Specify only when Type is forward
|
27
|
+
# * 'NextMarker'<~String> - Marker to specify for next page
|
28
|
+
def describe_listeners(load_balancer_arn, options = {})
|
29
|
+
request({
|
30
|
+
'Action' => 'DescribeListeners',
|
31
|
+
'LoadBalancerArn' => load_balancer_arn,
|
32
|
+
:parser => Fog::Parsers::AWS::ELBV2::DescribeListeners.new
|
33
|
+
}.merge!(options))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class ELBV2
|
4
|
+
class Real
|
5
|
+
require 'fog/aws/parsers/elbv2/describe_load_balancers'
|
6
|
+
|
7
|
+
# Describe all or specified load balancers
|
8
|
+
#
|
9
|
+
# ==== Parameters
|
10
|
+
# * options<~Hash>
|
11
|
+
# * 'LoadBalancerNames'<~Array> - List of load balancer names to describe, defaults to all
|
12
|
+
# * 'Marker'<String> - Indicates where to begin in your list of load balancers
|
13
|
+
#
|
14
|
+
# ==== Returns
|
15
|
+
# * response<~Excon::Response>:
|
16
|
+
# * body<~Hash>:
|
17
|
+
# * 'ResponseMetadata'<~Hash>:
|
18
|
+
# * 'RequestId'<~String> - Id of request
|
19
|
+
# * 'DescribeLoadBalancersResult'<~Hash>:
|
20
|
+
# * 'LoadBalancers'<~Array>
|
21
|
+
# * 'AvailabilityZones'<~Array>:
|
22
|
+
# * 'SubnetId'<~String> - ID of the subnet
|
23
|
+
# * 'ZoneName'<~String> - Name of the Availability Zone
|
24
|
+
# * 'LoadBalancerAddresses'<~Array>:
|
25
|
+
# * 'IpAddress'<~String> - IP address
|
26
|
+
# * 'AllocationId'<~String> - ID of the AWS allocation
|
27
|
+
# * 'CanonicalHostedZoneName'<~String> - name of the Route 53 hosted zone associated with the load balancer
|
28
|
+
# * 'CanonicalHostedZoneNameID'<~String> - ID of the Route 53 hosted zone associated with the load balancer
|
29
|
+
# * 'CreatedTime'<~Time> - time load balancer was created
|
30
|
+
# * 'DNSName'<~String> - external DNS name of load balancer
|
31
|
+
# * 'LoadBalancerName'<~String> - name of load balancer
|
32
|
+
# * 'SecurityGroups'<~Array> - array of security group id
|
33
|
+
# * 'NextMarker'<~String> - Marker to specify for next page
|
34
|
+
def describe_load_balancers(options = {})
|
35
|
+
unless options.is_a?(Hash)
|
36
|
+
Fog::Logger.deprecation("describe_load_balancers with #{options.class} is deprecated, use all('LoadBalancerNames' => []) instead [light_black](#{caller.first})[/]")
|
37
|
+
options = { 'LoadBalancerNames' => [options].flatten }
|
38
|
+
end
|
39
|
+
|
40
|
+
if names = options.delete('LoadBalancerNames')
|
41
|
+
options.update(Fog::AWS.indexed_param('LoadBalancerNames.member', [*names]))
|
42
|
+
end
|
43
|
+
|
44
|
+
request({
|
45
|
+
'Action' => 'DescribeLoadBalancers',
|
46
|
+
:parser => Fog::Parsers::AWS::ELBV2::DescribeLoadBalancers.new
|
47
|
+
}.merge!(options))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class Mock
|
52
|
+
def describe_load_balancers(options = {})
|
53
|
+
unless options.is_a?(Hash)
|
54
|
+
Fog::Logger.deprecation("describe_load_balancers with #{options.class} is deprecated, use all('LoadBalancerNames' => []) instead [light_black](#{caller.first})[/]")
|
55
|
+
options = { 'LoadBalancerNames' => [options].flatten }
|
56
|
+
end
|
57
|
+
|
58
|
+
lb_names = options['LoadBalancerNames'] || []
|
59
|
+
|
60
|
+
lb_names = [*lb_names]
|
61
|
+
load_balancers = if lb_names.any?
|
62
|
+
lb_names.map do |lb_name|
|
63
|
+
lb = self.data[:load_balancers_v2].find { |name, data| name == lb_name }
|
64
|
+
raise Fog::AWS::ELBV2::NotFound unless lb
|
65
|
+
lb[1].dup
|
66
|
+
end.compact
|
67
|
+
else
|
68
|
+
self.data[:load_balancers_v2].map { |lb, values| values.dup }
|
69
|
+
end
|
70
|
+
|
71
|
+
marker = options.fetch('Marker', 0).to_i
|
72
|
+
if load_balancers.count - marker > 400
|
73
|
+
next_marker = marker + 400
|
74
|
+
load_balancers = load_balancers[marker...next_marker]
|
75
|
+
else
|
76
|
+
next_marker = nil
|
77
|
+
end
|
78
|
+
|
79
|
+
response = Excon::Response.new
|
80
|
+
response.status = 200
|
81
|
+
|
82
|
+
response.body = {
|
83
|
+
'ResponseMetadata' => {
|
84
|
+
'RequestId' => Fog::AWS::Mock.request_id
|
85
|
+
},
|
86
|
+
'DescribeLoadBalancersResult' => {
|
87
|
+
'LoadBalancers' => load_balancers
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
if next_marker
|
92
|
+
response.body['DescribeLoadBalancersResult']['NextMarker'] = next_marker.to_s
|
93
|
+
end
|
94
|
+
|
95
|
+
response
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|