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
API Programming Guide
36 VMware, Inc.
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,theRescheduleReportAPIupdatesonlythescheduleinformationandnottheentitytopricing
modelmapping.So,youneedtodeletethereportscheduleandcreateanewoneifyouwanttoadd,modify,
ordeleteanyentitytopricingmodelmappingsifanynewcustomerisgetting
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
*/
public static void sampleDeleteReportSchedule(String baseURL, int scheduleId) throws
HttpException, IOException, KeyManagementException,
NoSuchAlgorithmException, JDOMException {
DeleteMethod delete = null;
HttpClient client = new HttpClient();
Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new
FakeSSLCertificateSocketFactory(), 443));
String uri = "https://" + baseURL + "/vCenter-CB/api/reportSchedule/" + scheduleId;
try {
delete = new DeleteMethod(uri);
client.executeMethod(delete);
System.out.println(delete.getResponseBodyAsString());
} finally {
if (delete != null) {
delete.releaseConnection();