Class: Awful::ElastiCache

Inherits:
Cli show all
Defined in:
lib/awful/elasticache.rb

Constant Summary collapse

COLORS =
{
  available: :green,
  deleted:   :red
}

Instance Method Summary collapse

Methods inherited from Cli

#initialize

Constructor Details

This class inherits a constructor from Awful::Cli

Instance Method Details

#dump(id = nil) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'lib/awful/elasticache.rb', line 51

def dump(id = nil)
  elasticache.describe_cache_clusters(
    cache_cluster_id:     id,
    show_cache_node_info: options[:nodes]
  ).cache_clusters.tap do |clusters|
    clusters.each do |cluster|
      puts YAML.dump(stringify_keys(cluster.to_hash))
    end
  end
end

#endpoint(id) ⇒ Object



65
66
67
68
69
70
71
72
# File 'lib/awful/elasticache.rb', line 65

def endpoint(id)
  elasticache.describe_cache_clusters(
    cache_cluster_id:     id,
    show_cache_node_info: true
  ).cache_clusters.first.cache_nodes.first.endpoint.tap do |ep|
    puts ep.address + ':' + ep.port.to_s
  end
end

#ls(id = nil) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/awful/elasticache.rb', line 28

def ls(id = nil)
  elasticache.describe_cache_clusters(cache_cluster_id: id).cache_clusters.tap do |clusters|
    if options[:long]
      print_table clusters.map { |c|
        [
          c.cache_cluster_id,
          c.engine,
          c.engine_version,
          c.num_cache_nodes,
          c.cache_node_type,
          c.preferred_availability_zone,
          color(c.cache_cluster_status),
          c.cache_cluster_create_time
        ]
      }
    else
      puts clusters.map(&:cache_cluster_id)
    end
  end
end