1.0.1
Table Of Contents
vCenter Chargeback API Programming Guide
20 VMware, Inc.
NoSuchAlgorithmException, KeyManagementException, HttpException {
PutMethod put = null;
Document requestDocument = CommonUtil.getXMLDocument(requestFilePath);
String bodyString = CommonUtil.xmlAsString(requestDocument);
Protocol.registerProtocol("https", new Protocol("https",
(ProtocolSocketFactory) new FakeSSLCertificateSocketFactory(),
443));
String uri = "https://" + baseURL + "/vCenter-CB/api/fixedCost/"
+ fixedCostId + "/values";
System.out.println(uri);
NameValuePair[] parameters = {
new NameValuePair("version", clientVersion),
new NameValuePair("startTime", String.valueOf(startTime)),
new NameValuePair("endTime", String.valueOf(endTime)) };
try {
put = new PutMethod(uri);
put.setRequestBody(bodyString);
put.setQueryString(parameters);
client.executeMethod(put);
System.out.println(put.getResponseBodyAsString());
}
finally {
if (put != null) {
put.releaseConnection();
}
}
}
}
Generate a Report
UsingtheGenerateaRawReportAPI,youcangenerateareportthatprovidesinformationoncostdetailsfor
thegivenentity.
TheURLforthisAPIis<HTTP_request_method> <Base_URL>/rawReport.Youcandefineacalllike
this:
POST https://123.123.123.123/vCenter-CB/api/rawReport
TheAPItakesarequestXMLfileinwhichyoucanspecifydetailsaboutthehierarchy,entity,resource
countersandthecostmodel.ThefollowingisasamplerequestXML.
<?xml version="1.0" encoding="UTF-8"?>
<Request xmlns="http://www.vmware.com/vcenter/chargeback/1.0.1">
<ReportTemplates>
<ReportTemplate>
<Name>Name</Name>
<Description>Description</Description>
<ReportType>COST_REPORT</ReportType>
<Hierarchies>
<Hierarchy id="1">
<Entities>
<Entity id="2" />
</Entities>
</Hierarchy>
</Hierarchies>
<CostModels>
<CostModel id="2" />
</CostModels>
<ComputingResources>
<ComputingResource id="2" />
</ComputingResources>