Class: Fog::Parsers::AWS::EC2::DescribeSecurityGroups

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

Instance Attribute Summary

Attributes inherited from Base

#response

Instance Method Summary collapse

Methods inherited from Base

#characters, #initialize

Constructor Details

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

Instance Method Details

#end_element(name) ⇒ Object



27
28
29
30
31
32
33
34
35
36
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
# File 'lib/fog/aws/parsers/ec2/describe_security_groups.rb', line 27

def end_element(name)
  case name
  when 'cidrIp'
    @ip_range[name] = @value
  when 'fromPort', 'toPort'
    @ip_permission[name] = @value.to_i
  when 'groups'
    @in_groups = false
  when 'groupDescription', 'ownerId'
    @security_group[name] = @value
  when 'groupName'
    if @in_groups
      @group[name] = @value
    else
      @security_group[name] = @value
    end
  when 'ipPermissions'
    @in_ip_permissions = false
  when 'ipProtocol'
    @ip_permission[name] = @value
  when 'ipRanges'
    @in_ip_ranges = false
  when 'item'
    if @in_groups
      @ip_permission['groups'] << @group
      @group = {}
    elsif @in_ip_permissions
      @security_group['ipPermissions'] << @ip_permission
      @ip_permission = { 'groups' => [], 'ipRanges' => []}
    elsif @in_ip_ranges
      @ip_permission['ipRanges'] << @ip_range
      @ip_range = {}
    else
      @response['securityGroupInfo'] << @security_group
      @security_group = { 'ipPermissions' => [] }
    end
  when 'requestId'
    @response[name] = @value
  when 'userId'
    @group[name] = @value
  end
end

#resetObject



8
9
10
11
12
13
14
# File 'lib/fog/aws/parsers/ec2/describe_security_groups.rb', line 8

def reset
  @group = {}
  @ip_permission = { 'groups' => [], 'ipRanges' => []}
  @ip_range = {}
  @security_group = { 'ipPermissions' => [] }
  @response = { 'securityGroupInfo' => [] }
end

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



16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/aws/parsers/ec2/describe_security_groups.rb', line 16

def start_element(name, attrs = [])
  if name == 'groups'
    @in_groups = true
  elsif name == 'ipPermissions'
    @in_ip_permissions = true
  elsif name == 'ipRanges'
    @in_ip_ranges = true
  end
  @value = ''
end