Packaged queries have well-known URLs and can accept most of the parameters used with typed queries.
Packaged queries have the following syntax:
API-URL/query-url[?param][¶m ... ][&filter]
■
|
API-URL is a URL of the form https://vcloud.example.com/api. |
■
| |
■
|
param is an optional query parameter. Zero or more parameters are allowed. See Query Parameters. |
■
|
filter is an optional filter expression. At most one filter expression is allowed. See Filter Expressions. |
The response is a QueryList element that contains a Link for every query. The href value of each Link is a URL you can GET to run the query specifying the default format.
Each query type returns its result set as an XML document in which objects are represented as elements and object properties are represented as attributes, pairing the name of the property with its value at the time the request was made. By default, result sets are returned in the records format, which shows all database records for each object. Most queries also support the references format, which returns a set of object references, including name, type, and href attributes. All queries that support the records format also support the idrecords format. For more information about the format parameter, see Query Parameters.
Packaged queries are divided into the following categories:
Simple packaged query using the records format, which is the default.
GET https://vcloud.example.com/api/catalogs/query
<QueryResultRecords xmlns="http://www.vmware.com/vcloud/v1.5" total="15" pageSize="25" page="1" name="catalog" type="application/vnd.vmware.vcloud.query.records+xml" href="https://vcloud.example.com/api/catalogs/query?page=1&pageSize=25&format=records" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ... > <Link rel="alternate" type="application/vnd.vmware.vcloud.query.references+xml" href="https://vcloud.example.com/api/catalogs/query?type=catalog&page=1&pageSize=25&format=references" /> <CatalogRecord ownerName="system" organizationName="VMware" numberOfTemplates="30" numberOfMedia="3" name="VAM" isShared="true" isPublished="true" description="" createdOn="2011-03-21T14:28:09.273-07:00" href="https://vcloud.example.com/api/catalog/150" /> <CatalogRecord ownerName="system" organizationName="QA" numberOfTemplates="0" numberOfMedia="1" name="QA-Cat" isShared="false" isPublished="true" description="" createdOn="2011-03-24T16:37:11.130-07:00" href="https://vcloud.example.com/api/catalog/78" /> <CatalogRecord ownerName="system" organizationName="Org-d5443f6b-85e" numberOfTemplates="0" numberOfMedia="1" name="Catalog-3f79780c-6b0" isShared="true" isPublished="true" description="" createdOn="2011-03-25T11:27:56.063-07:00" href="https://vcloud.example.com/api/catalog/99" /> <CatalogRecord ownerName="system" organizationName="Engineering" numberOfTemplates="2" numberOfMedia="4" name="TestCat" isShared="true" isPublished="true" description="New Catalog" createdOn="2011-03-22T17:10:10.067-07:00" href="https://vcloud.example.com/api/catalog/43" /> <CatalogRecord ownerName="system" organizationName="Engineering" numberOfTemplates="8" numberOfMedia="1" name="catalog1" isShared="true" isPublished="true" description="" createdOn="2011-03-22T16:14:06.360-07:00" href="https://vcloud.example.com/api/catalog/91" /> </QueryResultRecords>
Packaged query using references format.
GET https://vcloud.example.com/api/catalogs/query?format=references
<CatalogReferences xmlns="http://www.vmware.com/vcloud/v1.5" total="15" pageSize="25" page="1" name="catalog" type="application/vnd.vmware.vcloud.query.references+xml" href="https://vcloud.example.com/api/catalogs/query?page=1&pageSize=25&format=references" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ... > <Link rel="alternate" type="application/vnd.vmware.vcloud.query.records+xml" href="https://vcloud.example.com/api/catalogs/query?type=catalog&page=1&pageSize=25&format=records" /> <CatalogReference type="application/vnd.vmware.vcloud.catalog+xml" name="VAM" href="https://vcloud.example.com/api/catalog/150" /> <CatalogReference type="application/vnd.vmware.vcloud.catalog+xml" name="QA-Cat" href="https://vcloud.example.com/api/catalog/78" /> <CatalogReference type="application/vnd.vmware.vcloud.catalog+xml" name="Catalog-3f79780c-6b0" href="https://vcloud.example.com/api/catalog/99" /> <CatalogReference type="application/vnd.vmware.vcloud.catalog+xml" name="TestCat" href="https://vcloud.example.com/api/catalog/43" /> <CatalogReference type="application/vnd.vmware.vcloud.catalog+xml" name="catalog1" href="https://vcloud.example.com/api/catalog/91" /> </CatalogReferences>
Packaged query with sorting and filtering. This query adds parameters and a filter expression to produce a list of catalogs that contain one or more vApp templates. The query sorts the result set in ascending order by number of vApp templates:
GET https://vcloud.example.com/api/catalogs/query?format=records&sortAsc=numberOfTemplates&filter=numberOfTemplates!=0
<QueryResultRecords xmlns="http://www.vmware.com/vcloud/v1.5" total="3" pageSize="25" page="1" name="catalog" type="application/vnd.vmware.vcloud.query.records+xml" href="https://vcloud.example.com/api/catalogs/query?page=1&pageSize=25&format=records&filter=numberOfTemplates!=0&sortAsc=numberOfTemplates" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ... > <Link rel="alternate" type="application/vnd.vmware.vcloud.query.references+xml" href="https://vcloud.example.com/api/catalogs/query?type=catalog&page=1&pageSize=25&format=references&filter=numberOfTemplates!=0&sortAsc=numberOfTemplates" /> <CatalogRecord ownerName="system" organizationName="Engineering" numberOfTemplates="2" numberOfMedia="4" name="TestCatalog" isShared="true" isPublished="true" description="New Catalog" createdOn="2011-03-22T17:10:10.067-07:00" href="https://vcloud.example.com/api/catalog/43" /> <CatalogRecord ownerName="system" organizationName="Engineering" numberOfTemplates="8" numberOfMedia="1" name="catalog1" isShared="true" isPublished="true" description="" createdOn="2011-03-22T16:14:06.360-07:00" href="https://vcloud.example.com/api/catalog/91" /> <CatalogRecord ownerName="system" organizationName="VMware" numberOfTemplates="30" numberOfMedia="3" name="VAM" isShared="true" isPublished="true" description="" createdOn="2011-03-21T14:28:09.273-07:00" href="https://vcloud.example.com/api/catalog/150" /> </QueryResultRecords>