1.0.1
Table Of Contents
VMware, Inc. 21
Chapter 2 Understanding the Workflow
<BillingScheduleType>NOW</BillingScheduleType>
<BillingPeriod>
<Now>
<StartDate>1211871400000</StartDate>
<EndDate>1232399800000</EndDate>
</Now>
</BillingPeriod>
<DataFilter>
<DataDepth>1</DataDepth>
<ExcludeFilters>
<Filter id="CategorizedCosts" />
<Filter id="CategorizedUsage" />
<Filter id="InformationMessages" />
<Filter id="CostDetails" />
</ExcludeFilters>
</DataFilter>
</ReportTemplate>
</ReportTemplates>
</Request>
ThefollowingisasampleprogramthatcallstheGenerateRawReportAPI.Makesurethatyou:
UpdatetherequestXMLforLoginAPIwithrequiredvaluesandrunthelogin.javasamplecode.
RunAddVCenterServer.javaandreadthevcIdfromtheresponse.
ReadthevcEntityId,whichyouneedtoaddundervCenter‐ChargeBackhierarchyentity,fromthe
responseofsampleGetVcHierarchyMethod()
AddavCenter‐ChargeBackHierarchyandfromtheresponse,readthehierarchyIdandCBEntityId
underwhichthevcEntityistobeadded.
UpdatetheHierarchyid,cbEntityid,VCenterServeridandvcEntityidin
AddVCenterEntity-request.xmlfile.
AddthevcEntityundervCenter‐ChargeBackhierarchyentitybycallingmethod
addNewVCenterServerEntity()
UpdatetheHierarchyid,Entityid(onwhichyouwanttogeneratereport),StartDateandEndDatein
GenerateRawReport-request.xml.
/**
* This method is to generate report for a vCenter-ChargeBack hierarchy
* entity in vCenter-ChargeBack
*
* @param requestFilePath
* @param baseURL
* @throws IOException
* @throws JDOMException
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
* @throws HttpException
*/
@SuppressWarnings("deprecation")
public static void sampleGenerateReportMethod(String requestFilePath, String
baseURL,String clientVersion) throws IOException, JDOMException,
NoSuchAlgorithmException,
KeyManagementException, HttpException {
PostMethod post = null;
NameValuePair[] parameters = {new NameValuePair("version", clientVersion)};
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/rawReport";
System.out.println(uri);
System.out.println(bodyString);