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_snapshots.rb

55 lines
1.4 KiB
Ruby
Raw Normal View History

module Fog
module Parsers
module AWS
2010-09-08 17:40:02 -04:00
module Compute
class DescribeSnapshots < Fog::Parsers::Base
def reset
2009-08-01 04:15:44 -04:00
@response = { 'snapshotSet' => [] }
2010-10-12 14:00:59 -04:00
@snapshot = { 'tagSet' => {} }
@tag = {}
end
def start_element(name, attrs = [])
super
if name == 'tagSet'
@in_tag_set = true
end
end
def end_element(name)
2010-10-12 14:00:59 -04:00
if @in_tag_set
case name
when 'item'
@snapshot['tagSet'][@tag['key']] = @tag['value']
@tag = {}
when 'key', 'value'
@tag[key] = value
when 'tagSet'
@in_tag_set = false
end
else
case name
when 'item'
@response['snapshotSet'] << @snapshot
@snapshot = { 'tagSet' => {} }
when 'description', 'ownerId', 'progress', 'snapshotId', 'status', 'volumeId'
@snapshot[name] ||= @value
when 'requestId'
@response[name] = @value
when 'startTime'
@snapshot[name] = Time.parse(@value)
when 'volumeSize'
@snapshot[name] = @value.to_i
end
end
end
end
end
end
end
end