Class: EC2::DescribeSecurityGroupsResponse
- Defined in:
- lib/EC2/responses.rb
Constant Summary collapse
- ELEMENT_XPATH =
"DescribeSecurityGroupsResponse/securityGroupInfo/item"
Constants inherited from Response
Instance Attribute Summary
Attributes inherited from Response
#http_response, #http_xml, #structure
Instance Method Summary collapse
Methods inherited from Response
#initialize, #is_error?, #parse_error, #to_s
Constructor Details
This class inherits a constructor from EC2::Response
Instance Method Details
#parse ⇒ Object
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/EC2/responses.rb', line 237 def parse doc = REXML::Document.new(@http_xml) lines = [] doc.elements.each(ELEMENT_XPATH) do |rootelement| groupName = REXML::XPath.first(rootelement, "groupName").text ownerId = REXML::XPath.first(rootelement, "ownerId").text groupDescription = REXML::XPath.first(rootelement, "groupDescription").text lines << ["GROUP", ownerId, groupName, groupDescription] rootelement.elements.each("ipPermissions/item") do |element| ipProtocol = REXML::XPath.first(element, "ipProtocol").text fromPort = REXML::XPath.first(element, "fromPort").text toPort = REXML::XPath.first(element, "toPort").text permArr = [ "PERMISSION", ownerId, groupName, "ALLOWS", ipProtocol, fromPort, toPort, "FROM" ] element.elements.each("groups/item") do |subelement| userId = REXML::XPath.first(subelement, "userId").text targetGroupName = REXML::XPath.first(subelement, "groupName").text lines << permArr + ["USER", userId, "GRPNAME", targetGroupName] end element.elements.each("ipRanges/item") do |subelement| cidrIp = REXML::XPath.first(subelement, "cidrIp").text lines << permArr + ["CIDR", cidrIp] end end end lines end |