This API enables you to populate usage data by using a CSV file for a custom computing resource added to vCenter Chargeback Manager. Custom computing resources are also referred to as custom counters.
The syntax for calling this method is:
POST <Base_Url>/customComputingResourceStats/populate
A sample API call is as follows:
POST https://123.123.123.123/vCenter-CB/api/customComputingResourceStats/populate
You must have the Super User role.
Each record in the CSV file must be in the following format:
<entity_id>, <resource_id>, <sample_time_milli>, <sample_interval_milli>, <value_big_decimal>
Where,
entity_id
: Entity ID for which usage data is being addedresource_id
: Computing resource ID for which usage data is being addedsample_time_milli
: End time of the usage stat record in milliseconds since epochsample_interval_milli
: Time interval of the usage stat record in millisecondsvalue_big_decimal
: Java BigDecimal value of the usage stat recordA sample CSV body content is as follows:
#version 2.0
501, 101, 1312188135000, 1800, 19.1345
502, 101, 1312188135000, 3600, 4.645
501, 102, 1312188135000, 3600, 99999.1345
502, 102, 1312188135000, 1800, 44444.645
Lines beginning with a hash (#) are treated as comments. However, the line beginning with #version is treated as the version field of the csv file. This field is of the following format:
#version <version>
where <version> is 2.0 for the vCenter Chargeback Manager 2.0 release.
If the CSV file has even a single invalid entry, then the entire file is ignored and an error response with error code is sent.
If the operation is successful, the API returns an XML stating the same.
A sample response is provided here.
The following table explains the error codes displayed by the API.
Error Code |
Description |
INVALID_CUSTOM_COUNTER_PERF_STAT_RECORD_VERSION |
CVS version is not in the specified format or invalid version is specified. |
INVALID_CUSTOM_COUNTER_PERF_STAT_RECORD |
CSV record has invalid number of fields. |
INVALID_CUSTOM_COUNTER_PERF_STAT_RECORD_FIELD |
CSV record has invalid value (unable to parse the value) for one of the fields. |
NON_POSITIVE_CUSTOM_COUNTER_PERF_STAT_RECORD_FIELD |
CSV record has non-positive value for <sample_time_milli> or <sample_interval_milli> fields. |
INVALID_CUSTOM_COUNTER_PERF_STAT_RECORD_TIME_INTERVAL |
CSV record has <sample_interval_milli> value higher than <sample_time_milli>. |
INVALID_OVERLAPPING_CUSTOM_COUNTER_PERF_STAT_RECORDS |
CSV content has at least two records with overlapping record time interval. |
INVALID_OVERLAPPING_CUSTOM_COUNTER_PERF_STAT_DB_ENTRIES |
CSV content has atleast one record overlapping with an existing record for that entity and resource in the database. |