Class: Awsrm::AutoscallingGroup
Defined Under Namespace
Classes: AutoscallingGroupReader
Constant Summary
collapse
- FILTER_MAP =
{
name: ->(value) { [value] },
tags: ->(value) { AutoscallingGroup.tags2names(value) }
}.freeze
Constants inherited
from Resource
Resource::CLIENTS, Resource::CLIENT_OPTIONS
Class Method Summary
collapse
Methods inherited from Resource
check_one
Class Method Details
.all(params) ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/awsrm/autoscaling_group.rb', line 15
def all(params)
res = autoscaling_client.describe_auto_scaling_groups(
auto_scaling_group_names: filters(params)
)
res.auto_scaling_groups.map do |as|
AutoscallingGroupReader.new(as)
end
end
|
.filters(params) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/awsrm/autoscaling_group.rb', line 24
def filters(params)
params.map do |key, value|
raise UndefinedFilterParamError, key unless self::FILTER_MAP.key?(key)
next self::FILTER_MAP[key].call(value) if self::FILTER_MAP[key].is_a?(Proc)
end.flatten.uniq
end
|
.one(params) ⇒ Object
8
9
10
11
12
13
|
# File 'lib/awsrm/autoscaling_group.rb', line 8
def one(params)
res = autoscaling_client.describe_auto_scaling_groups(
auto_scaling_group_names: filters(params)
)
AutoscallingGroupReader.new(res.auto_scaling_groups.first) if check_one(res.auto_scaling_groups)
end
|
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/awsrm/autoscaling_group.rb', line 31
def tags2names(tag_hash)
tags = autoscaling_client.describe_tags.tags.flatten
maps = tag_hash.map do |key, value|
tags.map do |tag|
tag.resource_id if tag.key == key.to_s && tag.value == value.to_s
end.compact
end
maps.reduce do |memo, item|
memo & item
end
end
|