Class: Fog::Parsers::Compute::AWS::NetworkAclParser

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

Direct Known Subclasses

CreateNetworkAcl, DescribeNetworkAcls

Instance Attribute Summary

Attributes inherited from Base

#response

Instance Method Summary collapse

Methods inherited from Base

#attr_value, #characters, #end_element_namespace, #initialize, #start_element_namespace, #value

Constructor Details

This class inherits a constructor from Fog::Parsers::Base

Instance Method Details

#end_element(name) ⇒ Object



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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/fog/aws/parsers/compute/network_acl_parser.rb', line 40

def end_element(name)
  if @in_entry_set
    if @in_port_range
      case name
      when 'portRange'
        @in_port_range = false
      when 'from', 'to'
        @entry['portRange'][name] = value.to_i
      end
    elsif @in_icmp_type_code
      case name
      when 'icmpTypeCode'
        @in_icmp_type_code = false
      when 'code', 'type'
        @entry['icmpTypeCode'][name] = value.to_i
      end
    else
      case name
      when 'entrySet'
        @in_entry_set = false
      when 'item'
        @network_acl['entrySet'] << @entry
        @entry = { 'icmpTypeCode' => {}, 'portRange' => {} }
      when 'ruleNumber', 'protocol'
        @entry[name] = value.to_i
      when 'ruleAction', 'cidrBlock'
        @entry[name] = value
      when 'egress'
        @entry[name] = value == 'true'
      end
    end
  elsif @in_association_set
    case name
    when 'associationSet'
      @in_association_set = false
    when 'item'
      @network_acl['associationSet'] << @association
      @association = {}
    when 'networkAclAssociationId', 'networkAclId', 'subnetId'
      @association[name] = value
    end
  elsif @in_tag_set
    case name
    when 'tagSet'
      @in_tag_set = false
    when 'item'
      @network_acl['tagSet'][@tag['key']] = @tag['value']
      @tag = {}
    when 'key', 'value'
      @tag[name] = value
    end
  else
    case name
    when 'networkAclId', 'vpcId'
      @network_acl[name] = value
    when 'default'
      @network_acl[name] = value == 'true'
    end
  end
end

#resetObject



20
21
22
# File 'lib/fog/aws/parsers/compute/network_acl_parser.rb', line 20

def reset
  reset_nacl
end

#reset_naclObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/aws/parsers/compute/network_acl_parser.rb', line 7

def reset_nacl
  @network_acl = { 'associationSet' => [], 'entrySet' => [], 'tagSet' => {} }
  @association = {}
  @entry = { 'icmpTypeCode' => {}, 'portRange' => {} }
  @tag = {}
  
  @in_entry_set       = false
  @in_association_set = false
  @in_tag_set         = false
  @in_port_range      = false
  @in_icmp_type_code  = false
end

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



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

def start_element(name, attrs = [])
  super
  case name
  when 'entrySet'
    @in_entry_set = true
  when 'associationSet'
    @in_association_set = true
  when 'tagSet'
    @in_tag_set = true
  when 'portRange'
    @in_port_range = true
  when 'icmpTypeCode'
    @in_icmp_type_code = true
  end
end