Class: Fog::Parsers::AWS::Elasticache::CacheClusterParser

Inherits:
Base
  • Object
show all
Defined in:
lib/fog/aws/parsers/elasticache/cache_cluster_parser.rb

Direct Known Subclasses

DescribeCacheClusters, SingleCacheCluster

Instance Method Summary collapse

Instance Method Details

#end_element(name) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/fog/aws/parsers/elasticache/cache_cluster_parser.rb', line 41

def end_element(name)
  case name
  when 'AutoMinorVersionUpgrade', 'CacheClusterId',
    'CacheClusterStatus', 'CacheNodeType', 'Engine',
    'PreferredAvailabilityZone', 'PreferredMaintenanceWindow'
    @cache_cluster[name] = value
  when 'EngineVersion', 'CacheNodeIdsToRemoves'
    if @pending_values
      @pending_values[name] = value ? value.strip : name
    else
      @cache_cluster[name] = value
    end
  when 'NumCacheNodes'
    if @pending_values
      @pending_values[name] = value.to_i
    else
      @cache_cluster[name] = value.to_i
    end
  when 'CacheClusterCreateTime'
    @cache_cluster[name] = DateTime.parse(value)
  when 'CacheSecurityGroup'
    @cache_cluster["#{name}s"] << @cache_security_group unless @cache_security_group.empty?
  when 'ConfigurationEndpoint'
    @cache_cluster['ConfigurationEndpoint'] = @configuration_endpoint
  when 'CacheSecurityGroupName', 'CacheSubnetGroupName'
    @cache_cluster[name] = value
  when 'Status'
    if @in_security_group_member
      @security_group_member[name] = value
    else
      @cache_cluster[name] = value
    end
  when 'CacheNode'
    @cache_cluster["#{name}s"] << @cache_node unless @cache_node.empty?
    @cache_node = nil
  when'PendingModifiedValues'
    @cache_cluster[name] = @pending_values
    @pending_values = nil
  when 'Port', 'Address'
    if @cache_node
      @cache_node[name] = value ? value.strip : name                
    elsif @pending_values
      @pending_values[name] = value ? value.strip : name
    elsif @configuration_endpoint
      @configuration_endpoint[name] = value ? value.strip : name
    end
  when 'CacheNodeCreateTime', 'CacheNodeStatus',
    'ParameterGroupStatus', 'CacheNodeId'
    if @cache_node
      @cache_node[name] = value ? value.strip : name
    elsif @pending_values
      @pending_values[name] = value ? value.strip : name
    end
  when 'CacheNodeIdsToReboots', 'CacheParameterGroupName', 'ParameterApplyStatus'
    @cache_cluster['CacheParameterGroup'][name] = value
  when 'SecurityGroups'
    @in_security_groups = false
    @cache_cluster['SecurityGroups'] = @security_group_members
  when 'SecurityGroupId'
    @security_group_member[name] = value if @in_security_group_member
  when 'member'
    if @in_security_groups
      @in_security_group_member = false
      @security_group_members << @security_group_member
    end
  else
    super
  end
end

#resetObject



8
9
10
11
# File 'lib/fog/aws/parsers/elasticache/cache_cluster_parser.rb', line 8

def reset
  super
  reset_cache_cluster
end

#reset_cache_clusterObject



13
14
15
16
17
18
19
20
21
# File 'lib/fog/aws/parsers/elasticache/cache_cluster_parser.rb', line 13

def reset_cache_cluster
  @cache_cluster = {
    'CacheSecurityGroups' => [],
    'CacheNodes' => [],
    'CacheParameterGroup' => {},
    'ConfigurationEndpoint' => {},
    'SecurityGroups' => []
  }
end

#start_element(name, attrs = []) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/aws/parsers/elasticache/cache_cluster_parser.rb', line 23

def start_element(name, attrs = [])
  super
  case name
  when 'CacheSecurityGroup'; then @cache_security_group = {}
  when 'CacheNode'; then @cache_node = {}
  when 'PendingModifiedValues'; then @pending_values = {}
  when 'ConfigurationEndpoint'; then @configuration_endpoint = {} 
  when 'SecurityGroups'
    @in_security_groups = true
    @security_group_members = []
  when 'member'
    if @in_security_groups
      @in_security_group_member = true
      @security_group_member = {}
    end
  end
end