2.5
Table Of Contents
- API Programming Guide
- Contents
- About This Book
- vCenter Chargeback Manager APIs
- Understanding the Workflow
- Using vCenter Chargeback Manager with a Billing System
- Index
VMware, Inc. 33
Chapter 3 Using vCenter Chargeback Manager with a Billing System
<Computation>
<Settings type="costVariance">
<Property name="enabled" value="true" />
<Property name="granularity" value="DAILY" />
</Settings>
</Computation>
</Configuration>
<ScheduleDetail>
<FireTime>
<Hour>13</Hour>
<Minute>59</Minute>
</FireTime>
<Recurrence type="WEEKLY">
<DayOfWeek>2</DayOfWeek>
</Recurrence>
<Range>
<StartDate>1321295400000</StartDate>
<Count>-1</Count>
</Range>
</ScheduleDetail>
</ReportSchedule>
</ReportSchedules>
</Request>
Iftheoperationissuccessful,theresponseXMLprovidesdetailsofthereportschedule.
ThefollowingisanexampleprogramthatcallstheAPI.ThisprogramassumesthattherequestXMLis
populatedwiththerequiredinformation.
/**
* This method schedules report in vCenter-ChargeBack
*
* @param requestFilePath
* @param baseURL
* @throws IOException
* @throws HttpException
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
* @throws JDOMException
*/
public static void sampleScheduleReport(String requestFilePath, String baseURL) throws
HttpException, IOException, KeyManagementException,
NoSuchAlgorithmException, JDOMException {
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
FakeSSLCertificateSocketFactory(), 443));
String uri = "https://" + baseURL + "/vCenter-CB/api/reportSchedule";
try {
post = new PostMethod(uri);
post.setRequestBody(bodyString);
client.executeMethod(post);
System.out.println(post.getResponseBodyAsString());
} finally {
if (post != null) {
post.releaseConnection();
}
}
}
Get Report Schedule by Hierarchy Name
Dependingonhowyouchargeeachcustomer,youmighthavemappedentitiesinthehierarchytoappropriate
pricingmodels.YoucancalltheSearchAPItogetthereportscheduleforthehierarchyandverifytheentity
topricingmodelmappings.