1.5
Table Of Contents
- vCenter Chargeback API Programming Guide
- Contents
- About This Book
- vCenter Chargeback APIs
- Understanding the Workflow
- Using vCenter Chargeback with a Billing System
- Index
vCenter Chargeback API Programming Guide
36 VMware, Inc.
ThefollowingisanexampleprogramthatcallstheAPI.ThisprogramassumesthattherequestXMLis
populatedwiththerequiredinformation.
/**
* This method Re-schedule report in vCenter-ChargeBack
*
* @param requestFilePath
* @param baseURL
* @param scheduleId
* @throws IOException
* @throws HttpException
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
* @throws JDOMException
*/
public static void sampleRescheduleReport(String requestFilePath, String baseURL, int
scheduleId) throws HttpException, IOException,
KeyManagementException, NoSuchAlgorithmException, JDOMException {
PutMethod put = 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/" + scheduleId;
try {
put = new PutMethod(uri);
put.setRequestBody(bodyString);
client.executeMethod(put);
System.out.println(put.getResponseBodyAsString());
} finally {
if (put != null) {
put.releaseConnection();
}
}
}
Delete Report Schedule
Currently,theRescheduleReportAPIupdatesonlythescheduleinformationandnottheentitytocostmodel
mapping.So,youneedtodeletethereportscheduleandcreateanewoneifyouwanttoadd,modify,ordelete
anyentitytocostmodelmappingsifanynewcustomerisgetting
added.
To delete a report schedule
1 CalltheDeleteScheduleAPIbyusingthefollowingURLinyourprogram.
DELETE <API base URL>/reportSchedule/{scheduleId}
Forexample,
DELETE https://123.123.123.123/vCenter-CB/api/reportSchedule/5
TheresponseXMLindicatesthatthedeleteoperationissuccessful.
ThefollowingisanexampleprogramthatcallstheAPI.ThisprogramassumesthattherequestXMLis
populatedwiththerequiredinformation.
/**
* This method is to delete report schedule in vCenter-ChargeBack
*
* @param baseURL
* @param scheduleId
* @throws IOException
* @throws HttpException
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
* @throws JDOMException
*/