Skip to main content

credits

Creates, updates, deletes, gets or lists a credits resource.

Overview​

Namecredits
TypeResource
Idovh.cloud.credits

Fields​

The following fields are returned by SELECT queries:

successful operation

NameDatatypeDescription
idintegerCredit id
available_creditobjectAvailable credit
billstringCredit bill id
descriptionstringCredit description
productsarrayUse credits on following products
total_creditobjectTotal credit
used_creditobjectUsed credit
validityobjectCredit validity
voucherstringVoucher code

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectid, service_nameGet a project credit. Returns the total, used and available amounts of the credit, its validity period and the products it applies to.
listselectservice_namex_pagination_modeList project credits. Returns the IDs of the credits added to the project.
createinsertservice_name, codeAdd a voucher credit. Adds the credit of a voucher code to the project.

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.

NameDatatypeDescription
api_hoststringThe 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"}})
idintegerCredit id
service_namestringThe Public Cloud project ID. Resolved from OVH_CLOUD_PROJECT_SERVICE when set.
x_pagination_modestringSent as CachedObjectList-Pages by default so the list returns the full objects rather than their identifiers. (wire: X-Pagination-Mode)

SELECT examples​

Get a project credit. Returns the total, used and available amounts of the credit, its validity period and the products it applies to.

SELECT
id,
available_credit,
bill,
description,
products,
total_credit,
used_credit,
validity,
voucher
FROM ovh.cloud.credits
WHERE id = '{{ id }}' -- required
AND service_name = '{{ service_name }}' -- required unless OVH_CLOUD_PROJECT_SERVICE is set
;

INSERT examples​

Add a voucher credit. Adds the credit of a voucher code to the project.

INSERT INTO ovh.cloud.credits (
code,
service_name
)
SELECT
'{{ code }}' /* required */,
'{{ service_name }}'
;