2010-04-16 03:20:02 -04:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
|
|
|
module Terremark
|
|
|
|
module Shared
|
|
|
|
|
2013-02-12 07:52:46 -05:00
|
|
|
class GetCatalog < TerremarkParser
|
2010-04-16 03:20:02 -04:00
|
|
|
|
|
|
|
def reset
|
|
|
|
@response = { 'CatalogItems' => [] }
|
|
|
|
end
|
|
|
|
|
|
|
|
def start_element(name, attributes)
|
2010-05-05 16:39:41 -04:00
|
|
|
super
|
2010-04-16 03:20:02 -04:00
|
|
|
case name
|
|
|
|
when 'CatalogItem'
|
2013-02-12 07:52:46 -05:00
|
|
|
catalog_item = extract_attributes(attributes)
|
|
|
|
catalog_item["id"] = catalog_item["href"].split('/').last
|
2010-04-16 03:20:02 -04:00
|
|
|
@response['CatalogItems'] << catalog_item
|
2013-02-12 07:52:46 -05:00
|
|
|
|
2010-04-16 03:20:02 -04:00
|
|
|
when 'Catalog'
|
2013-02-12 07:52:46 -05:00
|
|
|
catalog = extract_attributes(attributes)
|
2010-04-16 03:20:02 -04:00
|
|
|
@response['name'] = catalog['name']
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def end_element(name)
|
|
|
|
if name == 'Description'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response[name] = value
|
2010-04-16 03:20:02 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|