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 Method Summary collapse

Instance Method Details

#end_element(name) ⇒ Object



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

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



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

def reset
  reset_nacl
end

#reset_naclObject



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

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



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

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