class Awsrm::AutoscalingGroup

Constants

FILTER_MAP

Public Class Methods

all(params) click to toggle source
# File lib/awsrm/resources/autoscaling_group.rb, line 10
def all(params)
  res = autoscaling_client.describe_auto_scaling_groups(
    auto_scaling_group_names: filters(params)
  )
  res.auto_scaling_groups.map do |as|
    AutoscalingGroupReader.new(as)
  end
end
filters(params) click to toggle source
# File lib/awsrm/resources/autoscaling_group.rb, line 19
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
tags2names(tag_hash) click to toggle source
# File lib/awsrm/resources/autoscaling_group.rb, line 26
def tags2names(tag_hash)
  tags = autoscaling_client.describe_tags.flat_map { |page| page.tags }
  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