This API enables you to get the hierarchy of a vCenter server from the vCenter Chargeback Manager database. Because the hierarchy is retrieved from the vCenter Chargeback Manager database and not the from vCenter server database, the hierarchy might not be the latest.
Note: The vCenter server of which the hierarchy should be retrieved, must be added to the application. Also, the data collector should have retrieved the hierarchy from the vCenter server and replicated the same in the vCenter Chargeback Manager database.
The syntax for calling this API is:
GET <Base_URL>/vcHierarchy/{vCenterServerId}
A sample API call is as follows:
GET https://123.123.123.123/vCenter-CB/api/vcHierarchy/11
You must have a role with the Read privilege on the vCenter Server and on the hierarchy you specify as a URL parameter.
You can provide the following URL parameters with the API call.
Name |
Data Type |
Required/Optional |
Description |
Sample Value |
---|---|---|---|---|
vcViewId |
Integer |
Required |
Specify the vCenter inventory view ID. A value of 1 indicates the Hosts and Clusters view. A value of 2 indicates the Virtual Machines and templates view. |
1 (Hosts & Clusters) |
hierarachyId |
Integer |
Optional |
ID of the Chargeback hierarchy that you want to compare with the vCenter server hierarchy.
|
1 |
If the operation is successful, the API returns an XML response with the following details.
XPath |
Type |
Min Occurs |
Max Occurs |
Description |
---|---|---|---|---|
VCenterServers/VCenterServer |
|
1 |
1 |
Represents the vCenter Server from which you want to retrieve the hierarchy. |
VCenterServers/VCenterServer/@id |
xs:int |
1 |
1 |
ID of the vCenter Server. |
VCenterServers/VCenterServer/Name |
xs:string |
1 |
1 |
Name of the vCenter Server. |
VCenterServers/VCenterServer/Entities/Entity |
|
0 |
unbounded |
Represents each entity in the vCenter hierarchy. |
VCenterServers/VCenterServer/Entities/Entity/@id |
xs:int |
1 |
1 |
ID of the vCenter Server entity. |
VCenterServers/VCenterServer/Entities/Entity/Name |
xs:string |
1 |
1 |
Name of the entity. |
VCenterServers/VCenterServer/Entities/Entity/MoId |
xs:string |
1 |
1 |
MoID (managed object ID) of the entity as defined in the vCenter Server. |
VCenterServers/VCenterServer/Entities/Entity/Type |
xs:int |
1 |
1 |
Type of the entity. For more information, see Chargeback Entity Types. |
VCenterServers/VCenterServer/Entities/Entity/Parent/@id |
xs:int |
1 |
1 |
ID of this entity's parent. If this is a root entity, it will not not have a parent and hence, the value is always -1. |
VCenterServers/VCenterServer/Entities/Entity/StateInCbHierarchy |
xs:boolean |
0 |
1 |
Indicates if the vCenter Server entity is present in the hierarchy specified by the hierarachyId parameter. A value of 0 - indicates that the entity is not present in vCenter Chargeback Manager. 1 - indicates that some of the child entities of the entity are present in vCenter Chargeback Manager. 2 - indicates that the entity and all its children are present in vCenter Chargeback Manager. |
A sample response is provided here.
The following table explains the error codes displayed by the API.
Error Code |
Description |
VCB_ERR_INVALID_VCENTER_SERVER_ID |
The specified vCenter server ID is invalid. |
VCB_ERR_INVALID_VC_VIEW_TYPE |
vCenter server view type is invalid. |
VCB_ERR_INVALID_HIERARCHY_ID |
The specified Chargeback hierarchy ID is invalid. |