Retrieving Catalog
information
Catalogs on vCloud Director store vApp
templates and ISO images as Catalog items. Backup solutions can be asked to
back up the items in the Catalog for a given Organization. Catalogs can be
shared or private. A user can choose to back up all items or only selected
items in the given catalog. For this it is necessary to traverse the given
Catalog in an Organization to access the contents and extract the various
metadata associated with the vApp.
The following example shows inventory traversal to
access the Catalog items in a given Organization, and assumes you have logged
in to vCloud Director and obtained a map of Organizations, as in examples
above.
// List catalogs and catalog items for a given organization: Console.WriteLine(); if (organizationsMap != null && organizationsMap.Count > 0) { foreach (string organizationName in organizationsMap.Keys) { ReferenceType organizationReference = organizationsMap[organizationName]; Console.WriteLine(organizationName); Console.WriteLine(organizationReference.href); Organization organization = Organization.GetOrganizationByReference(client, organizationReference); List<ReferenceType> catalogLinks = organization.GetCatalogRefs(); if (catalogLinks != null && catalogLinks.Count > 0) { foreach (ReferenceType catalogLink in catalogLinks) { Catalog catalog = Catalog.GetCatalogByReference(client, catalogLink); CatalogType catalogType = catalog.Resource; Console.WriteLine(" " + catalogType.name); Console.WriteLine(“ " + catalogLink.href); List<ReferenceType> catalogItemReferences = catalog.GetCatalogItemReferences(); if (catalogItemReferences != null && catalogItemReferences.Count > 0) { foreach (ReferenceType catalogItemReference in catalogItemReferences) { Console.WriteLine(“ " + catalogItemReference.name); Console.WriteLine(" " + catalogItemReference.href); } Console.WriteLine(); } else { Console.WriteLine( "No CatalogItems Found"); } } Console.WriteLine(); } else { Console.WriteLine( "No Catalogs Found"); } } } else { Console.WriteLine("No Organizations"); }
The following example shows REST API calls that
accomplish some of the tasks shown in the example above. REST API calls to list
catalog items:
GET https://vCloud/api/catalog/id GET https://vCloud/api/catalog/id/catalogItems GET https://vCloud/api/catalogitem/id