You are here: Usage Information > getCustomerUsageLog

Retrieve Customer Usage Log

Description

Returns the usage log details for a given customer. It obtains details of the entitlements that are deployed on the Sentinel Cloud Connect.

Default Protocol Method Type URI
HTTPS GET getCustomerUsageLog.xml

Query Parameters

Parameter Description Valid Values Optional
customerId The unique record ID of the customer in EMS database. Integer No
startDate

Start date from when the usage log is to be obtained.

The startDate should be earlier than or same as the enddate.

String (yyyy-mm-dd) No
endDate End date till when the usage bill is to be obtained. String (yyyy-mm-dd) No
pageIndex Index of the currently displayed page. Integer (>0) Default Value: 1 Yes
pageSize

Number of records to be displayed on a page.

Its default value can be configured from EMS Admin Console by using the Max Records Per Response (Web Services) property.

Integer (>0) Yes
status

Specifies whether or not to include revoked entitlements in the response. Possible values are:

  • 3 : Include revoked entitlements in the response. This is the default value.
  • 4: Do not include revoked entitlements in the response.
Integer Yes

Sample Code

import java.io.IOException;
import java.net.URLDecoder;

//..............................
//..............................
//..............................
import org.apache.http.params.HttpParams;
public class EMSSample {
	private static DefaultHttpClient httpclient = new DefaultHttpClient();
	private static Principal principal = null;
	private static StringBuffer query;
	//..............................
	//..............................
	//..............................
	public static String getCustomerUsageLog.xml()throws Exception  {
		if(!verifyLogin()){
			return "login failed";
		}
		HttpContext context = new BasicHttpContext();
		context.setAttribute(ClientContext.USER_TOKEN, principal);
		HttpGet get = new HttpGet("https://localhost:8443/ems/3.6/getCustomerUsageLog.xml");
		query = new StringBuffer();
		setParameter("startDate", "");
		setParameter("customerId", "");
		setParameter("pageSize", "");
		setParameter("endDate", "");
		setParameter("pageIndex", "");
		setParameter("status", "1");
		get.setURI(new URI(URLDecoder.decode(get.getURI() + query.toString(),"UTF-8")));
		HttpResponse response = httpclient.execute(get, context);
		HttpEntity entity = response.getEntity();
		byte[] b = null;
		if (entity != null) {
			long l = entity.getContentLength();
			b = new byte[(int) l];
			entity.getContent().read(b);
			entity.consumeContent();
		}
		return new String(b);
	}
	static void setParameter(String key, String value) {
		if (query.toString().equals("")) {
			query.append("?" + key + "=" + value + "&");
		} else {
			query.append(key + "=" + value + "&");
		}
	}
}

   

Sample Response

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<emsResponse>
  <stat>ok</stat>
  <total>4</total>
  <customer>
    <customerName>Cus209</customerName>
    <entitlements>
      <entitlement>
        <entId>9</entId>
        <lineItems>
          <lineItem>
            <itemProduct>
              <product>
                <productName>Pro_1</productName>
                <productVersion>209_1</productVersion>
              </product>
            </itemProduct>
            <usageRecords>
              <usageRecord>
                <featureName>F3</featureName>
                <userID>vikas2</userID>
                <startDate>02/01/2012</startDate>
                <endDate>02/29/2012</endDate>
                <totalConsumption>23</totalConsumption>
                <usageType>TimeBased</usageType>
                <recordCount>1</recordCount>
              </usageRecord>
            </usageRecords>
          </lineItem>
        </lineItems>
      </entitlement>
      <entitlement>
        <entId>5</entId>
        <lineItems>
          <lineItem>
            <itemProduct>
              <product>
                <productName>Pro_1</productName>
                <productVersion>209_1</productVersion>
              </product>
            </itemProduct>
            <usageRecords>
              <usageRecord>
                <featureName>F1</featureName>
                <userID>vikas</userID>
                <startDate>02/01/2012</startDate>
                <endDate>02/29/2012</endDate>
                <totalConsumption>15</totalConsumption>
                <usageType>TimeBased</usageType>
                <recordCount>1</recordCount>
              </usageRecord>
              <usageRecord>
                <featureName>F2</featureName>
                <userID>vikas1</userID>
                <startDate>02/01/2012</startDate>
                <endDate>02/29/2012</endDate>
                <totalConsumption>0</totalConsumption>
                <usageType>CountBased</usageType>
                <recordCount>1</recordCount>
              </usageRecord>
            </usageRecords>
          </lineItem>
        </lineItems>
      </entitlement>
      <entitlement>
        <entId>4</entId>
        <lineItems>
          <lineItem>
            <itemProduct>
              <product>
                <productName>Pro_2</productName>
                <productVersion>209_2</productVersion>
              </product>
            </itemProduct>
            <usageRecords />
          </lineItem>
        </lineItems>
      </entitlement>
      <entitlement>
        <entId>1</entId>
        <lineItems>
          <lineItem>
            <itemProduct>
              <product>
                <productName>Pro_1</productName>
                <productVersion>209_1</productVersion>
              </product>
            </itemProduct>
            <usageRecords>
              <usageRecord>
                <featureName>F2</featureName>
                <userID>identity</userID>
                <startDate>02/01/2012</startDate>
                <endDate>02/29/2012</endDate>
                <totalConsumption>0</totalConsumption>
                <usageType>TimeBased</usageType>
                <recordCount>2</recordCount>
              </usageRecord>
            </usageRecords>
          </lineItem>
        </lineItems>
      </entitlement>
    </entitlements>
  </customer>
</emsResponse>
See Also:

Output Format for Failure

Error Codes

Error Code Description
101 You are not authorized to use this service.
107 An internal error occurred! Please report the error to System administrator.
118 {field} should be of data type integer. [Note: This error code is applicable for the fields - featureId, License modelId, entId, ftrId, customerId, lmId, templateType, lineItemId, CustomerId, stationCount, status, and granularity.]
122 {field} is a required field and should have a not null value. [Note: This error code is applicable for the fields - Eid, namespaceName, featureName, startDate, endDate, userIds, featureId, productName, productVersion, detailsLM, lmId, templateType, customAttribute, lineItemId, customerRefId, granularity, loginId, oldPassword, and newPassword.]
123 endDate should be of dataType Date in the format yyyy-mm-dd startDate should be of dataType Date in the format yyyy-mm-dd.
128 You should log on first.
512 The customer does not exist.
617 Start date cannot be greater than end date.
1081 Invalid Web service version provided
1082 No entitlement exists for the given customer.
1084 No Web service version provided
1088 The EMS system is running on HTTPS. Please provide the correct Web service URL.
1102 Maximum pageIndex allowed for specified size is 1.
1176 Invalid {field}. Note: This error code is applicable for the following fields: formatType, outputMode, vendorData, and status.