Class: Awsrm::Elb
Constant Summary
collapse
- FILTER_MAP =
{
id: 'load_balancer_name',
name: 'load_balancer_name',
dns_name: 'dns_name',
tags: ->(lb, value) { Elb.has_tags?(lb.load_balancer_name, value) },
vpc: ->(lb, value) { lb.vpc_id == Awsrm::Vpc.one(name: value).id }
}.freeze
Constants inherited
from Resource
Resource::CLIENTS, Resource::CLIENT_OPTIONS
Class Method Summary
collapse
Methods inherited from Resource
check_one, one
Class Method Details
.all(params) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/awsrm/resources/elb.rb', line 12
def all(params)
elbs = elb_client.describe_load_balancers.map do |responce|
responce.load_balancer_descriptions
end.flatten
elbs.map do |lb|
ret = params.all? do |key, value|
raise UndefinedFilterParamError, key unless self::FILTER_MAP.key?(key)
next self::FILTER_MAP[key].call(lb, value) if self::FILTER_MAP[key].is_a?(Proc)
lb[self::FILTER_MAP[key]] == value
end
ElbReader.new(lb) if ret
end.compact
end
|
.filters(_params) ⇒ Object
26
27
28
|
# File 'lib/awsrm/resources/elb.rb', line 26
def filters(_params)
raise NoMethodError
end
|
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/awsrm/resources/elb.rb', line 30
def has_tags?(name, tag_hash)
tag_descriptions = elb_client.describe_tags(load_balancer_names: [name]).tag_descriptions.flatten
ret = tag_descriptions.find do |desc|
desc.load_balancer_name == name
end
return false if ret.nil?
tag_hash.all? do |key, value|
ret.tags.any? do |tag|
tag.key == key.to_s && tag.value == value.to_s
end
end
end
|