1.5

VMware, Inc. 33
Chapter 3 Using vCenter Chargeback with a Billing System
</Email>
</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
costmodels.YoucancalltheSearchAPItogetthereportscheduleforthehierarchyandverifytheentityto
costmodelmappings.
To get schedule by hierarchy name
1 CalltheSearchAPIbyusingthefollowingURLin
yourprogram.
POST <API base URL>/search
2IntherequestXML,specifythefollowingparameterstosearchschedules.Youcanuseanyofthese
parametersaloneorincombinationwiththeothers.
name
desc
hierarchyName
costModelName
3YoucanusesearchoperatorssuchasEQUAL, NOT_EQUAL, BETWEEN, GT, LT, GT_EQUAL, LT_EQUAL,
NULL, NOT_NULL, LIKE, NOT_LIKEtofilteryoursearch.