usage_histories
Creates, updates, deletes, gets or lists a usage_histories resource.
Overview​
| Name | usage_histories |
| Type | Resource |
| Id | ovh.cloud.usage_histories |
Fields​
The following fields are returned by SELECT queries:
- get
- list
successful operation
| Name | Datatype | Description |
|---|---|---|
id | string | Usage id |
hourly_usage | object | Hourly usage (wire: hourlyUsage) |
last_update | string (date-time) | Entry last update (wire: lastUpdate) |
monthly_usage | object | Monthly usage (wire: monthlyUsage) |
period | object | Usage dates (from/to) |
resources_usage | array | Resource usage (billed per hour/minute/second/unit) (wire: resourcesUsage) |
total_price | object | Total price (wire: totalPrice) |
UsageHistory
| Name | Datatype | Description |
|---|---|---|
id | string | Usage id |
last_update | string (date-time) | Entry last update (wire: lastUpdate) |
period | object | Usage dates (from/to) |
Methods​
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | usage_id, service_name | Returns the usage and price of the project for one past period, by resource type. | |
list | select | service_name | from, to | Returns the past usage periods of the project. Filter them with the from and to dates, then get the details of one period with its ID. |
Parameters​
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
api_host | string | The OVHcloud API host. Selected by OVH_ENDPOINT (ovh-eu, ovh-ca or ovh-us; default ovh-eu). (default: api.eu.ovhcloud.com, x-stackQL-envVarSelector: {"envVar":"OVH_ENDPOINT","default":"ovh-eu","values":{"ovh-eu":"api.eu.ovhcloud.com","ovh-ca":"api.ca.ovhcloud.com","ovh-us":"api.us.ovhcloud.com"}}) |
service_name | string | The Public Cloud project ID. Resolved from OVH_CLOUD_PROJECT_SERVICE when set. |
usage_id | string | Usage ID (wire: usageId) |
from | string (date-time) | Filter results having date superior to from |
to | string (date-time) | Filter results having date inferior to |
SELECT examples​
- get
- list
Returns the usage and price of the project for one past period, by resource type.
SELECT
id,
hourly_usage,
last_update,
monthly_usage,
period,
resources_usage,
total_price
FROM ovh.cloud.usage_histories
WHERE usage_id = '{{ usage_id }}' -- required
AND service_name = '{{ service_name }}' -- required unless OVH_CLOUD_PROJECT_SERVICE is set
;
Returns the past usage periods of the project. Filter them with the from and to dates, then get the details of one period with its ID.
SELECT
id,
last_update,
period
FROM ovh.cloud.usage_histories
WHERE service_name = '{{ service_name }}' -- required unless OVH_CLOUD_PROJECT_SERVICE is set
AND from = '{{ from }}'
AND to = '{{ to }}'
;