Get Details Of A Hierarchy - VMware VCENTER CHARGEBACK 1.5 - API Manual

Vcenter chargeback api programming guide
Hide thumbs Also See for VCENTER CHARGEBACK 1.5 - API:
Table of Contents

Advertisement

The following is an example program that calls the API. This program assumes that the request XML is 
populated with the required information.
/**
* This method get list of hierarchies from vCenter-ChargeBack
*
* @param requestFilePath
* @param baseURL
* @throws IOException
* @throws HttpException
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
* @throws JDOMException
*/
public static void sampleGetHierarchies(String requestFilePath, String baseURL) throws
PostMethod post = null;
Document requestDocument = CommonUtil.getXMLDocument(requestFilePath);
String bodyString = CommonUtil.xmlAsString(requestDocument);
HttpClient client = new HttpClient();
Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new
String uri = "https://" + baseURL + "/vCenter-CB/api/search";
try {
} finally {
}
}

Get Details of a Hierarchy

After the Search API retrieves the new hierarchies, you can get more details about a specific hierarchy by 
calling the Get Hierarchy API. 
To get details of a hierarchy
1
Call the Get Hierarchy API by using the following URL in your program.
GET <API base URL>/hierarchy/{hierarchyId}
If the operation is successful, the response XML contains details of the hierarchy. 
The following is an example program that calls the API. This program assumes that the request XML is 
populated with the required information.
/**
* This method get hierarchy from vCenter-ChargeBack
*
* @param hierarchyId
* @param baseURL
* @throws IOException
* @throws HttpException
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
* @throws JDOMException
*/
public static void sampleGetHierarchy(int hierarchyId, String baseURL) throws
GetMethod get = null;
HttpClient client = new HttpClient();
VMware, Inc.
HttpException, IOException, KeyManagementException,
NoSuchAlgorithmException, JDOMException {
FakeSSLCertificateSocketFactory(), 443));
post = new PostMethod(uri);
post.setRequestBody(bodyString);
client.executeMethod(post);
System.out.println(post.getResponseBodyAsString());
if (post != null) {
post.releaseConnection();
}
HttpException, IOException, KeyManagementException, NoSuchAlgorithmException,
JDOMException {
Chapter 3 Using vCenter Chargeback with a Billing System
29

Advertisement

Table of Contents
loading

Table of Contents