2.0
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. 37
Chapter 3 Using vCenter Chargeback Manager with a Billing System
}
}
}
Get List of Archived Reports for a Hierarchy
Foraspecifichierarchy,youcangetalistofarchivedreportsthatweregeneratedafteraspecifictime.Todo
this,youcanusetheSearchAPI.
To get list of archived reports for a hierarchy
1 CalltheSearchAPIbyusingthefollowingURLinyourprogram.
POST <API base URL>/search
2IntherequestXML,usethefollowingsectiontosearchforreportswiththespecifichierarchynameand
createdafterorequaltoatimepassedinmillisecondssinceJanuary1,1970.
<Criteria type="AND">
<Filter name="hierarchyName" type="EQUAL" value="TestHierarchy" />
<Filter name="createdOn" type="GT_EQUAL" value="1272639780140" />
</Criteria>
ThefollowingisanexamplerequestXML.
<?xml version="1.0" encoding="UTF-8"?>
<Request>
<SearchQueries>
<SearchQuery id="report">
<Criteria type="AND">
<Filter name="name" type="LIKE" value="%report1%" />
<Filter name="desc" type="LIKE" value="%reportDesc1%" />
<Filter name="costModelName" type="EQUAL" value="costModel1"/>
</Criteria>
<SortBy>
<Params>
<Param index="1" order="DESC">totalCost</Param>
</Params>
</SortBy>
<Pagination>
<FirstResultCount>0</FirstResultCount>
<MaxResultCount>100</MaxResultCount>
</Pagination>
</SearchQuery>
</SearchQueries>
</Request>
TheresponseXMLcontainsalistofreportsthatmatchthesearchcriteria.
ThefollowingisanexampleprogramthatcallstheAPI.ThisprogramassumesthattherequestXMLis
populatedwiththerequiredinformation.
/**
* This method gets archived reports from vCenter-ChargeBack
*
* @param requestFilePath
* @param baseURL
* @throws IOException
* @throws HttpException
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
* @throws JDOMException
*/
public static void sampleGetArchivedReports(String requestFilePath, String baseURL)
throws HttpException, IOException, KeyManagementException,
NoSuchAlgorithmException, JDOMException {
PostMethod post = null;
Document requestDocument = CommonUtil.getXMLDocument(requestFilePath);
String bodyString = CommonUtil.xmlAsString(requestDocument);