mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Fix parser, adding links, and IsPublish attrs
This commit is contained in:
parent
a732a303d5
commit
1c587ce480
1 changed files with 25 additions and 3 deletions
|
@ -1,3 +1,19 @@
|
|||
#
|
||||
#<?xml version="1.0" encoding="UTF-8"?>
|
||||
#<Catalog xmlns="http://www.vmware.com/vcloud/v1.5" name="prueba" id="urn:vcloud:catalog:ea0c6acf-c9c0-46b7-b19f-4b2d3bf8aa33" type="application/vnd.vmware.vcloud.catalog+xml" href="https://devlab.mdsol.com/api/catalog/ea0c6acf-c9c0-46b7-b19f-4b2d3bf8aa33" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://10.194.1.65/api/v1.5/schema/master.xsd">
|
||||
# <Link rel="up" type="application/vnd.vmware.vcloud.org+xml" href="https://devlab.mdsol.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a"/>
|
||||
# <Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://devlab.mdsol.com/api/catalog/ea0c6acf-c9c0-46b7-b19f-4b2d3bf8aa33/metadata"/>
|
||||
# <Link rel="add" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://devlab.mdsol.com/api/catalog/ea0c6acf-c9c0-46b7-b19f-4b2d3bf8aa33/catalogItems"/>
|
||||
# <Description>this is a description</Description>
|
||||
# <CatalogItems>
|
||||
# <CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml" name="sprintdemo" href="https://devlab.mdsol.com/api/catalogItem/05211623-f94b-470e-a3ac-825d5752081c"/>
|
||||
# <CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml" name="sinred" href="https://devlab.mdsol.com/api/catalogItem/971f5364-304f-499a-a5ff-e89f629fc503"/>
|
||||
# <CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml" name="sprintdemocopy" href="https://devlab.mdsol.com/api/catalogItem/c4173ea2-90ca-4d1e-b6a3-7d3a7a3fba86"/>
|
||||
# </CatalogItems>
|
||||
# <IsPublished>false</IsPublished>
|
||||
#</Catalog>
|
||||
|
||||
|
||||
module Fog
|
||||
module Parsers
|
||||
module Vcloudng
|
||||
|
@ -6,7 +22,7 @@ module Fog
|
|||
class GetCatalog < VcloudngParser
|
||||
|
||||
def reset
|
||||
@response = { 'CatalogItems' => [] }
|
||||
@response = { 'CatalogItems' => [], 'Links' => [] }
|
||||
end
|
||||
|
||||
def start_element(name, attributes)
|
||||
|
@ -16,16 +32,22 @@ module Fog
|
|||
catalog_item = extract_attributes(attributes)
|
||||
catalog_item["id"] = catalog_item["href"].split('/').last
|
||||
@response['CatalogItems'] << catalog_item
|
||||
|
||||
when 'Catalog'
|
||||
catalog = extract_attributes(attributes)
|
||||
@response['name'] = catalog['name']
|
||||
when "Link"
|
||||
link = extract_attributes(attributes)
|
||||
@response["Links"] << link
|
||||
end
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
if name == 'Description'
|
||||
case name
|
||||
when 'Description'
|
||||
@response[name] = value
|
||||
when 'IsPublished'
|
||||
value_boolean = value == 'false' ? false : true
|
||||
@response[name] = value_boolean
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue