Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 236436

Re: vCloud API - How to get only public catalogs or only organisation catalogs?

$
0
0

I know this is a few months old by now, but I am just now fumbling my way through the API via the (.NET) SDK and wow is it horribly documented!  I am running into a similar problem here, as you can see the catalogs via organization helper class, but there is no way to differentiate shared catalogs versus organization specific and additionally, there is no way to see how many vApp templates or media items are in each (note: you can see the items, but no way to differentiate the type).  So, turning to the query methods - seems to be a complete waste of time.  Using either the org/user API or the admin API it only seems to return published catalogs.  In my test setup I have 4 orgs, 3 have private catalogs, 1 has a published catalog.  What I am trying to do is write a simple app to help document the vCloud configuration by dumping a list of resources configured in the cloud.  I am logging into the system as a user with full cloud admin rights (sysadmin@System), and would like to retrieve information on all Organizations, vDCs, pvDCs, org networks, external networks, and so on.  I am stumped at my first task - retrieving all orgs and their associated catalogs/items (wow, that bodes well for the rest of this project).  Note that I have experience with the vSphere SDK and while I found it to be quite convoluted with a pretty steep learning curve, it actually is documented quite well, which is in stark contrast to this SDK. 

 

When retrieving each org and getting the catalog via the helper, I have noticed the following behavior:

  1. Each org returns the published catalog as if it belongs to that org, except one org which I purposely created a private catalog with the same name as the published catalog.  This shows the private catalog and not the published catalog.
  2. Each org returns its private catalog
  3. Each catalog returns all of its member items, but there is no way to get additional information on these items

 

When performing the query through either the user API or the admin API, the following happens:

  1. Only published catalogs are returned
  2. Shared catalogs are not returned (unless they are published)
  3. Private catalogs are not returned

 

Thus, a query using the following C# function

    

     public static RecordResult<QueryResultCatalogRecordType> GetAllCatalogRecords(com.vmware.vcloud.sdk.vCloudClient client)

        {

            com.vmware.vcloud.sdk.QueryService qService = client.GetQueryService();

            return qService.QueryCatalogRecords();

        }

 

or the following "admin" function

 

     public static RecordResult<QueryResultCatalogRecordType> GetAllCatalogRecords_Admin(com.vmware.vcloud.sdk.admin.VcloudAdmin admin)

        {

            com.vmware.vcloud.sdk.admin.AdminQueryService qService = admin.GetAdminQueryService();

            return qService.QueryCatalogRecords();

        }

 

Returns only records for published catalogs.  I can publish and unpublish the catalog it gets added or removed to/from the list returned by these functions accordingly.

 

HTTP exchange looks as follows.  Curiously, this is exactly the same for either "API", so I guess using the base client QueryService or the AdminQueryService translates to hitting the exact same REST API method.  Perhaps this is the root of the problem?  A bug in the SDK?  Am I trying to do something that can't be done in the API?  I would think anything you can do from the GUI should be a capability of the API... if I login as sysadmin@System, I can open each org and see the catalogs for each org regardless of whether they are shared or published within the GUI.  I should be able to accomplish the same thing from the API....

 

ClientAppTrace Information: 0 : GET URL - https://vCloud/api/catalogs/query?format=records

ClientAppTrace Information: 0 : GET URL - https://vCloud/api/catalogs/query?format=records

ClientAppTrace Information: 0 : Status Code - 200

ClientAppTrace Information: 0 : Status - OK

ClientAppTrace Information: 0 : Response - <?xml version="1.0" encoding="UTF-8"?>

<QueryResultRecords xmlns="http://www.vmware.com/vcloud/v1.5" total="1" pageSize="25" page="1" name="catalog" type="application/vnd.vmware.vcloud.query.records+xml" href="https://vCloud/api/catalogs/query?page=1&pageSize=25&format=records" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5http://vCloud/api/v1.5/schema/master.xsd">

    <Link rel="alternate" type="application/vnd.vmware.vcloud.query.references+xml" href="https://vCloud/api/catalogs/query?page=1&pageSize=25&format=references"/>

    <Link rel="alternate" type="application/vnd.vmware.vcloud.query.idrecords+xml" href="https://vCloud/api/catalogs/query?page=1&pageSize=25&format=idrecords"/>

    <CatalogRecord ownerName="system" owner="https://vCloud/api/admin/user/47c2c926-8b0a-495e-98ff-d1ac39279f56" orgName="Tenant1" numberOfVAppTemplates="2" numberOfMedia="2" name="Cross Organization Catalog" isShared="false" isPublished="true" creationDate="2013-03-20T09:08:39.630-04:00" href="https://vCloud/api/catalog/40dae580-aedc-4893-98ac-1fd61eceefc6"/>

</QueryResultRecords>


Viewing all articles
Browse latest Browse all 236436

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>