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
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
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/fog/aws/parsers/compute/describe_security_groups.rb', line 35
def end_element(name)
if @in_tag_set
case name
when 'item'
@security_group['tagSet'][@tag['key']] = @tag['value']
@tag = {}
when 'key', 'value'
@tag[name] = value
when 'tagSet'
@in_tag_set = false
end
else
case name
when 'cidrIp'
@ip_range[name] = value
when 'cidrIpv6'
@ipv6_range[name] = value
when 'fromPort', 'toPort'
if @in_ip_permissions_egress
@ip_permission_egress[name] = value.to_i
else
@ip_permission[name] = value.to_i
end
when 'groups'
@in_groups = false
when 'groupDescription', 'ownerId', 'vpcId'
@security_group[name] = value
when 'groupId','groupName'
if @in_groups
@group[name] = value
else
@security_group[name] = value
end
when 'ipPermissions'
@in_ip_permissions = false
when 'ipPermissionsEgress'
@in_ip_permissions_egress = false
when 'ipProtocol'
if @in_ip_permissions_egress
@ip_permission_egress[name] = value
else
@ip_permission[name] = value
end
when 'ipRanges'
@in_ip_ranges = false
when 'ipv6Ranges'
@in_ipv6_ranges = false
when 'item'
if @in_groups
if @in_ip_permissions_egress
@ip_permission_egress['groups'] << @group
else
@ip_permission['groups'] << @group
end
@group = {}
elsif @in_ip_ranges
if @in_ip_permissions_egress
@ip_permission_egress['ipRanges'] << @ip_range
else
@ip_permission['ipRanges'] << @ip_range
end
@ip_range = {}
elsif @in_ipv6_ranges
if @in_ip_permissions_egress
@ip_permission_egress['ipv6Ranges'] << @ipv6_range
else
@ip_permission['ipv6Ranges'] << @ipv6_range
end
@ipv6_range = {}
elsif @in_ip_permissions
@security_group['ipPermissions'] << @ip_permission
@ip_permission = { 'groups' => [], 'ipRanges' => [], 'ipv6Ranges' => []}
elsif @in_ip_permissions_egress
@security_group['ipPermissionsEgress'] << @ip_permission_egress
@ip_permission_egress = { 'groups' => [], 'ipRanges' => [], 'ipv6Ranges' => []}
else
@response['securityGroupInfo'] << @security_group
@security_group = { 'ipPermissions' => [], 'ipPermissionsEgress' => [], 'tagSet' => {} }
end
when 'requestId', 'nextToken'
@response[name] = value
when 'userId'
@group[name] = value
end
end
end
|