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
VMware, Inc. 37
Chapter 3 Using vCenter Chargeback with a Billing System
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();
}
}
}
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.