1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/aws/parsers/compute/describe_volumes.rb

74 lines
2.1 KiB
Ruby
Raw Normal View History

module Fog
module Parsers
module Compute
module AWS
class DescribeVolumes < Fog::Parsers::Base
def reset
@attachment = {}
@in_attachment_set = false
2009-08-01 04:15:44 -04:00
@response = { 'volumeSet' => [] }
@tag = {}
@volume = { 'attachmentSet' => [], 'tagSet' => {} }
end
def start_element(name, attrs = [])
super
2010-10-12 14:00:59 -04:00
case name
when 'attachmentSet'
@in_attachment_set = true
2010-10-12 14:00:59 -04:00
when 'tagSet'
@in_tag_set = true
end
end
def end_element(name)
if @in_attachment_set
case name
when 'attachmentSet'
@in_attachment_set = false
when 'attachTime'
@attachment[name] = Time.parse(value)
when 'deleteOnTermination'
@attachment[name] = value == 'true'
2009-08-01 04:15:44 -04:00
when 'device', 'instanceId', 'status', 'volumeId'
@attachment[name] = value
when 'item'
2009-08-01 04:15:44 -04:00
@volume['attachmentSet'] << @attachment
@attachment = {}
end
2010-10-12 14:00:59 -04:00
elsif @in_tag_set
case name
when 'key', 'value'
@tag[name] = value
2010-10-12 14:00:59 -04:00
when 'item'
@volume['tagSet'][@tag['key']] = @tag['value']
@tag = {}
2010-10-12 14:00:59 -04:00
when 'tagSet'
@in_tag_set = false
end
else
case name
2009-08-01 04:15:44 -04:00
when 'availabilityZone', 'snapshotId', 'status', 'volumeId'
@volume[name] = value
when 'createTime'
@volume[name] = Time.parse(value)
when 'item'
2009-08-01 04:15:44 -04:00
@response['volumeSet'] << @volume
@volume = { 'attachmentSet' => [], 'tagSet' => {} }
when 'requestId'
@response[name] = value
when 'size'
@volume[name] = value.to_i
end
end
end
end
end
end
end
end