1.0.1

VMware, Inc. 19
Chapter 2 Understanding the Workflow
try {
post = new PostMethod(uri);
post.setQueryString(parameters);
post.setRequestBody(bodyString);
client.executeMethod(post);
System.out.println(post.getResponseBodyAsString());
}
finally {
if (post != null) {
post.releaseConnection();
}
}
}
}
Ifthetaskissuccessful,theAPIreturnsanXMLfilethatreturnstheidentifierofthenewfixedcost.
Modify a Fixed Cost Value
UsingtheModifyFixedCostAPI,youcanupdatefixedcostid,valueanddurationforafixedcost.
TheURLforthisAPIis<HTTP_request_method> <Base_URL>/fixedCost/{fixedCostId}/values.
Youcandefineacalllikethis:
PUT https://123.123.123.123/vCenter-CB/api/fixedCost/{fixedCostId}/values
TheAPItakesarequestXMLfileinwhichyoucanspecifythefixedcostnameanditsdescription.
The followingisasamplerequestXML.
<?xml version="1.0" encoding="UTF-8"?>
<Request xmlns="http://www.vmware.com/vcenter/chargeback/1.0.1">
<FixedCosts>
<FixedCost id="1">
<Values>
<Value>
<Cost>3.1415</Cost>
<Duration id="1"/>
</Value>
</Values>
</FixedCost>
</FixedCosts>
</Request>
ThefollowingisasampleprogramthatcallstheAddanFixedCostAPI.Makesurethatyou:
UpdatetheLogin-request.xmlwithrequiredvaluesandrunthelogin.javasamplecode.
RuntheAddFixedCostAPIandreadthefixedCostIdfromtheresponse.
UpdatethefixedCostId,thecostanddurationidinmodifyFixedCostValues-request.xmlfile.
/**
* This method is to modify the values of an existing fixedCost
*
* @param requestFilePath
* @param baseURL
* @param startTime
* @param endTime
* @param clientVersion
* @throws IOException
* @throws JDOMException
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
* @throws HttpException
*/
@SuppressWarnings("deprecation")
public static void sampleModifyFixedCostValues(String requestFilePath,
String baseURL, int fixedCostId, long startTime, long endTime,
String clientVersion) throws IOException, JDOMException,