2009-07-11 16:41:21 -04:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
|
|
|
module AWS
|
2010-09-08 17:40:02 -04:00
|
|
|
module Compute
|
2009-07-11 16:41:21 -04:00
|
|
|
|
|
|
|
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
|
2009-07-11 16:41:21 -04:00
|
|
|
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
|
2009-07-11 16:41:21 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|