Class: Fog::Parsers::AWS::ELBV2::DescribeLoadBalancers

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

Instance Method Summary collapse

Instance Method Details

#end_element(name) ⇒ Object



37
38
39
40
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
# File 'lib/fog/aws/parsers/elbv2/describe_load_balancers.rb', line 37

def end_element(name)
  case name
  when 'member'
    if @in_availability_zones && @in_load_balancer_addresses
      @availability_zone['LoadBalancerAddresses'] << @load_balancer_addresses
    elsif @in_availability_zones
      @load_balancer['AvailabilityZones'] << @availability_zone
      reset_availability_zone
    elsif @in_security_groups
      @load_balancer['SecurityGroups'] << value
    else
      @results['LoadBalancers'] << @load_balancer
      reset_load_balancer
    end
  when 'SubnetId', 'ZoneName'
    @availability_zone[name] = value
  when 'IpAddress', 'AllocationId'
    @load_balancer_addresses[name] = value

  when 'CanonicalHostedZoneName', 'CanonicalHostedZoneNameID', 'LoadBalancerName', 'DNSName', 'Scheme', 'Type',
       'LoadBalancerArn', 'IpAddressType', 'CanonicalHostedZoneId', 'VpcId'
    @load_balancer[name] = value
  when 'CreatedTime'
    @load_balancer[name] = Time.parse(value)

  when 'LoadBalancerAddresses'
    @in_load_balancer_addresses = false
  when 'AvailabilityZones'
    @in_availability_zones = false
  when 'SecurityGroups'
    @in_security_groups = false
  when 'State'
    @in_state = false
    @load_balancer[name] = @state
    @state = {}
  when 'Code'
    @state[name] = value

  when 'RequestId'
    @response['ResponseMetadata'][name] = value

  when 'NextMarker'
    @results['NextMarker'] = value
  when 'DescribeLoadBalancersResponse'
    @response['DescribeLoadBalancersResult'] = @results
  end
end

#resetObject



6
7
8
9
10
11
12
13
# File 'lib/fog/aws/parsers/elbv2/describe_load_balancers.rb', line 6

def reset
  reset_load_balancer
  reset_availability_zone
  @load_balancer_addresses = {}
  @state = {}
  @results = { 'LoadBalancers' => [] }
  @response = { 'DescribeLoadBalancersResult' => {}, 'ResponseMetadata' => {} }
end

#reset_availability_zoneObject



19
20
21
# File 'lib/fog/aws/parsers/elbv2/describe_load_balancers.rb', line 19

def reset_availability_zone
  @availability_zone = { 'LoadBalancerAddresses' => [] }
end

#reset_load_balancerObject



15
16
17
# File 'lib/fog/aws/parsers/elbv2/describe_load_balancers.rb', line 15

def reset_load_balancer
  @load_balancer = { 'SecurityGroups' => [], 'AvailabilityZones' => [] }
end

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



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/aws/parsers/elbv2/describe_load_balancers.rb', line 23

def start_element(name, attrs = [])
  super
  case name
  when 'AvailabilityZones'
    @in_availability_zones = true
  when 'LoadBalancerAddresses'
    @in_load_balancer_addresses = true
  when 'SecurityGroups'
    @in_security_groups = true
  when 'State'
    @in_state = true
  end
end