vCenter Chargeback API Programming Guide
<!-- Report configuration is an optional section, not particularly relavant for API
</Report>
</Reports>
</Request>
vCenter Chargeback queues this report request as a task and returns an XML that indicates the status of
the task. You can use the Get Queued Task Status API to track the progress of the task. For more
information on the Get Queued Task Status API, see the vCenter Chargeback API Reference Guide.
The following is an example program that calls the API.
/**
* This method is to generate report for a vCenter-ChargeBack hierarchy
* entity in vCenter-ChargeBack
*
* @param requestFilePath
* @param baseURL
* @throws IOException
* @throws JDOMException
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
* @throws HttpException
*/
public static void sampleGenerateReportMethod(String requestFilePath, String baseURL)
PostMethod post = null;
Document requestDocument = CommonUtil.getXMLDocument(requestFilePath);
String bodyString = CommonUtil.xmlAsString(requestDocument);
Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new
String uri = "https://" + baseURL + "/vCenter-CB/api/report";
HttpClient client = new HttpClient();
System.out.println(uri);
System.out.println(bodyString);
try {
} finally {
}
}
22
<ComputingResource id="9" />
<ComputingResource id="10" />
</ComputingResources>
</MetaData>
<Configuration>
users -->
</Configuration>
throws IOException, JDOMException, NoSuchAlgorithmException,
KeyManagementException, HttpException {
FakeSSLCertificateSocketFactory(), 443));
post = new PostMethod(uri);
post.setRequestBody(bodyString);
client.executeMethod(post);
System.out.println(post.getResponseBodyAsString());
if (post != null) {
post.releaseConnection();
}
VMware, Inc.