Modify A Fixed Cost Value - VMware VCENTER CHARGEBACK 1.5 - API Manual

Vcenter chargeback api programming guide
Hide thumbs Also See for VCENTER CHARGEBACK 1.5 - API:
Table of Contents

Advertisement

vCenter Chargeback API Programming Guide

Modify a Fixed Cost Value

Using the Modify Fixed Cost API, you can update the ID, value, and duration for a fixed cost.
To modify a fixed cost value
1
Call the API by using the following syntax.
<HTTP_request_method> <Base_URL>/fixedCost/{fixedCostId}/values
For example, you can define a call like this: 
PUT https://123.123.123.123/vCenter-CB/api/fixedCost/{fixedCostId}/values
2
In the request XML, specify a name and a description for the fixed cost. The following is an example 
request XML.
<?xml version="1.0" encoding="UTF-8"?>
<Request xmlns="http://www.vmware.com/vcenter/chargeback/1.5.0">
<FixedCosts>
<FixedCost id="1">
</FixedCost>
</FixedCosts>
</Request>
The response XML indicates whether the fixed cost value was successfully modified. 
The following is an example program that calls the API.
/**
* This method is to modify the values of an existing fixedCost
*
* @param requestFilePath
* @param baseURL
* @param startTime
* @param endTime
* @throws IOException
* @throws JDOMException
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
* @throws HttpException
*/
public static void sampleModifyFixedCostValues(String requestFilePath, String baseURL,
PutMethod put = null;
Document requestDocument = CommonUtil.getXMLDocument(requestFilePath);
String bodyString = CommonUtil.xmlAsString(requestDocument);
Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new
HttpClient client = new HttpClient();
String uri = "https://" + baseURL + "/vCenter-CB/api/fixedCost/" + fixedCostId +
System.out.println(uri);
NameValuePair[] parameters = {new NameValuePair("startTime",
try {
20
<Values>
<Value>
<Cost>3.1415</Cost>
<Duration id="1"/>
</Value>
</Values>
int fixedCostId, long startTime, long endTime) throws IOException,
JDOMException, NoSuchAlgorithmException, KeyManagementException, HttpException {
FakeSSLCertificateSocketFactory(), 443));
"/values";
String.valueOf(startTime)), new NameValuePair("endTime",
String.valueOf(endTime))};
put = new PutMethod(uri);
put.setRequestBody(bodyString);
put.setQueryString(parameters);
client.executeMethod(put);
System.out.println(put.getResponseBodyAsString());
VMware, Inc.

Advertisement

Table of Contents
loading

Table of Contents