Billing Management Operations
CreateResourcePrice
API Request
POST zstack/v1/billings/pricesAuthorization: OAuth the-session-uuid{
"params": {
"resourceName": "cpu",
"timeUnit": "s",
"price": 100.0,
"dateInLong": 0.0
},
"systemTags": [],
"userTags": []
}
Note: In the preceding sample, both systemTags and userTags are
optional. These two fields can be included in the body structure.curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth cc882c434d65428091449452ab5eb2e3" \
-X POST -d '{"params":{"resourceName":"cpu","timeUnit":"s","price":100.0,"dateInLong":0.0}}' \
http://localhost:8080/zstack/v1/billings/prices| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| resourceName | String | body (contained in the params structure) | The resource name. |
|
0.6 |
| resourceUnit | String | body (contained in the params structure) | Optional. The billing unit of the resource. | This parameter can be decided according to resourceName. | 0.6 |
| timeUnit | String | body (contained in the params structure) | The billing time unit. | 0.6 | |
| price | double | body (contained in the params structure) | The unit price. | 0.6 | |
| accountUuid | String | body (contained in the params structure) | Optional. The account UUID. | 0.6 | |
| dateInLong | Long | body (contained in the params structure) | Optional. The long-integer time. | 0.6 | |
| tableUuid | String | body (contained in the params structure) | Optional. The price table UUID. | 3.7.2 | |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 |
Note:
- When you create a resource price in ZStack Cloud,
you can specify a PCI device by adding the PCI device option to
SystemTags.
- Format of the PCI device option:
gpuOfferingUuid::UUID - Example:
gpuOfferingUuid::634b48a7bca139d9944a0f95b0c2dddf
- Format of the PCI device option:
- When you create a resource price in ZStack Cloud,
you can define the resource billing type by adding the
priceUserConfig option to SystemTags.
- Format of the priceUserConfig option:
priceUserConfig::xxx. Here, xxx must be a JSON string.
- Format of the priceUserConfig option:
API Response
{
"inventory": {
"uuid": "437ade61b17e4c658844fdacfb0fc6de",
"resourceName": "Volume",
"resourceUnit": "1",
"timeUnit": "s",
"price": 2.0
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| resourceName | String | The resource name. | 0.6 |
| resourceUnit | String | The billing unit of the resource. | 0.6 |
| timeUnit | String | The billing time unit. | 0.6 |
| price | Double | The unit price. | 0.6 |
| dateInLong | Long | The long-integer time. | 0.6 |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
| tableUuid | String | The price table UUID. | 3.7.1 |
| pciDeviceOfferings | List | See pciDeviceOfferings. | 2.4 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| priceUuid | String | 2.4 | |
| pciDeviceOfferingUuid | String | 2.4 | |
| createDate | Timestamp | The creation date. | 2.4 |
| lastOpDate | Timestamp | The last operation date. | 2.4 |
SDK Sample
CreateResourcePriceAction action = new CreateResourcePriceAction();
action.resourceName = "cpu";
action.timeUnit = "s";
action.price = 100.0;
action.dateInLong = 0.0;
action.sessionId = "1360cf066fd547b9ae2d8f32beba717f";
CreateResourcePriceAction.Result res = action.call();CreateResourcePriceAction action = CreateResourcePriceAction()
action.resourceName = "cpu"
action.timeUnit = "s"
action.price = 100.0
action.dateInLong = 0.0
action.sessionId = "47ca95d22d8645ef8aef8dd0110cbd92"
CreateResourcePriceAction.Result res = action.call()DeleteResourcePrice
API Request
DELETE zstack/v1/billings/prices/{uuid}?deleteMode={deleteMode}OAuth: the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "OAuth: 5332b02080a141cc961457ad3b090fe4" \
-X DELETE http://localhost:8080/zstack/v1/billings/prices/a5c5bd6198824d89894cdd10969843ffdeleteMode=Permissive| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 0.6 | |
| deleteMode | String | url | Optional. The delete mode. | 0.6 | |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 |
API Response
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Sample
DeleteResourcePriceAction action = new DeleteResourcePriceAction();
action.uuid = "6a7c1ad952894d5aa2cc6b1add3062ca";
action.deleteMode = "Permissive";
action.sessionId = "e3ffecc95a5b4bcca5ce212826a14ee0";
DeleteResourcePriceAction.Result res = action.call();DeleteResourcePriceAction action = DeleteResourcePriceAction()
action.uuid = "14c4eef2f36e4716a279777e503ab772"
action.deleteMode = "Permissive"
action.sessionId = "fcbca45ec9454200b1d080b0268c17d9"
DeleteResourcePriceAction.Result res = action.call()UpdateResourcePrice
API Request
PUT zstack/v1/billings/prices/{uuid}/actionsAuthorization: OAuth the-session-uuid{
"updateResourcePrice": {
"setEndDateInLongBaseOnCurrentTime": false
},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateResourcePrice":{"setEndDateInLongBaseOnCurrentTime":false}}' http://localhost:8080/zstack/v1/billings/prices/bed31eb3ba76325ba6a1cef1a64c97a3/actions| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource price UUID. | 3.7.2 | |
| endDateInLong | Long | body (contained in the updateResourcePrice structure) | Optional. The resource price expiration date. | 3.7.2 | |
| setEndDateInLongBaseOnCurrentTime | boolean | body (contained in the updateResourcePrice structure) | Optional. Sets the resource price expiration date to the current time. | 3.7.2 | |
| systemTags | List | body | Optional. The system tags. | 3.7.2 | |
| userTags | List | body | Optional. The user tags. | 3.7.2 |
API Response
{
"inventory": {
"uuid": "d7d2b639707c3e158f9f94cdfff8dc88",
"resourceName": "Volume",
"resourceUnit": "1",
"timeUnit": "s",
"price": 2.0,
"dateInLong": 1.510669257141E12,
"endDateInLong": 1.511029257141E12
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 3.7.2 |
| inventory | PriceInventory | See inventory. | 3.7.2 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| resourceName | String | The resource name. | 0.6 |
| resourceUnit | String | The billing unit of the resource. | 0.6 |
| timeUnit | String | The billing time unit. | 0.6 |
| price | Double | The unit price. | 0.6 |
| dateInLong | Long | The long-integer time. | 0.6 |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
| tableUuid | String | The price table UUID. | 3.7.2 |
| pciDeviceOfferings | List | See pciDeviceOfferings. | 2.4 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| priceUuid | String | 2.4 | |
| pciDeviceOfferingUuid | String | 2.4 | |
| createDate | Timestamp | The creation date. | 2.4 |
| lastOpDate | Timestamp | The last operation date. | 2.4 |
SDK Sample
UpdateResourcePriceAction action = new UpdateResourcePriceAction();
action.uuid = "bed31eb3ba76325ba6a1cef1a64c97a3";
action.setEndDateInLongBaseOnCurrentTime = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateResourcePriceAction.Result res = action.call();UpdateResourcePriceAction action = UpdateResourcePriceAction()
action.uuid = "bed31eb3ba76325ba6a1cef1a64c97a3"
action.setEndDateInLongBaseOnCurrentTime = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateResourcePriceAction.Result res = action.call()QueryResourcePrice
API Request
GET zstack/v1/billings/prices
GET zstack/v1/billing/prices/{uuid}OAuth: the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "OAuth: 0898d6895f274f83bc9d7fe85c629fc2" \
-X GET http://localhost:8080/zstack/v1/billings/prices?q=uuid=e7a8c15058f2450dbae8a52bc3a53163curl -H "Content-Type: application/json;charset=UTF-8" \
-H "OAuth: 1e19b0c2877343e8b5cc27ba801cea5b" \
-X GET http://localhost:8080/zstack/v1/billing/prices/9b1cb8fcb98a4a77b8d1b8f5c71f3ea0Queryable Fields
You can check all queryable fields and resource names that can be queried across
tables by using zstack-cli, entering
QueryResourcePrice, and pressing the Tab key.
API Response
{
"inventories": [
{
"uuid": "127da3fe2612443187bdb5cc1c0a1b93",
"resourceName": "Volume",
"resourceUnit": "1",
"timeUnit": "s",
"price": 2.0
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 0.6 |
| inventories | List | See inventories. | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| resourceName | String | The resource name. | 0.6 |
| resourceUnit | String | The billing unit of the resource. | 0.6 |
| timeUnit | String | The billing time unit. | 0.6 |
| price | Double | The unit price. | 0.6 |
| dateInLong | Long | The long-integer time. | 0.6 |
| tableuuid | String | The the price table UUID. | 3.7.2 |
| pciDeviceOfferings | List | See pciDeviceOfferings. | 2.4 |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| priceUuid | String | 2.4 | |
| pciDeviceOfferingUuid | String | 2.4 | |
| createDate | Timestamp | The creation date. | 2.4 |
| lastOpDate | Timestamp | The last operation date. | 2.4 |
SDK Sample
QueryResourcePriceAction action = new QueryResourcePriceAction();
action.conditions = asList("uuid=9f754355ea3147fe9e132e9e387565fc");
action.sessionId = "487ff79fdb52498ba0ebaf0825d09277";
QueryResourcePriceAction.Result res = action.call();QueryResourcePriceAction action = QueryResourcePriceAction()
action.conditions = ["uuid=1c26229f970f4fe599c34d56bc78b578"]
action.sessionId = "30759bcfee93462eb88cf7fc88f3a364"
QueryResourcePriceAction.Result res = action.call()CalculateAccountSpending
API Request
PUT zstack/v1/billings/accounts/{accountUuid}/actionsAuthorization: OAuth the-session-uuid{
"calculateAccountSpending": {
"dateStart": 0.0,
"dateEnd": 1.49448017929E12
},
"systemTags": [],
"userTags": []
}
Note: In the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b0422700ba91425aa234b7ad4d70e8ce" \
-X PUT -d '{"calculateAccountSpending":{"dateStart":0.0,"dateEnd":1.510669257141E12}}' \
http://localhost:8080/zstack/v1/billings/accounts/64df7cc87c583f069400e5184175d025/actions| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| accountUuid | String | body (contained in the calculateAccountSpending structure) | The account UUID. | 0.6 | |
| dateStart | Long | body (contained in the calculateAccountSpending structure) | Optional. The start date. | 0.6 | |
| dateEnd | Long | body (contained in the calculateAccountSpending structure) | Optional. The end date. | 0.6 | |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 |
API Response
{
"total": 200.0,
"spending": [
{
"spending": 0.0,
"details": []
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| total | double | The total amount. | 0.6 |
| success | boolean | Whether the API succeeds. | 0.6 |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 0.6 |
| spending | List | See spending. | 0.6 |
| error | ErrorCode | See error. | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| spendingType | String | The spending type. | 0.6 |
| spending | double | The total spending. | 0.6 |
| dateStart | Long | The billing start date. | 0.6 |
| dateEnd | Long | The billing end date. | 0.6 |
| details | List | See details. | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| resourceUuid | String | The resource UUID. | 0.6 |
| resourceName | String | The resource name. | 0.6 |
| spending | double | The spending. | 0.6 |
| type | String | The type. | 0.6 |
SDK Sample
CalculateAccountSpendingAction action = new CalculateAccountSpendingAction();
action.accountUuid = "b9578ee43e1745aaaddf96b2286d8055";
action.dateStart = 0.0;
action.dateEnd = 1.494480179344E12;
action.sessionId = "21b88c2399054090b13ac0b9fe067f75";
CalculateAccountSpendingAction.Result res = action.call();CalculateAccountSpendingAction action = CalculateAccountSpendingAction()
action.accountUuid = "881b1c4a85bf43f39acc29d42a9c6cd6"
action.dateStart = 0.0
action.dateEnd = 1.494480179344E12
action.sessionId = "a5ae231847c14c26b62bed6e878d6c60"
CalculateAccountSpendingAction.Result res = action.call()QueryAccountBilling
API Request
GET zstack/v1/billing/billings
GET zstack/v1/billing/billings/{id}Authorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/billing/billings?q=accountUuid=3897826bada53c65bab2298c3adf69eacurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/billing/billings/{id}?q=accountUuid=e0936c43a701362189fa71031084d9ddQueryable Fields
You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryAccountBilling, and pressing the Tab key.
API Response
{
"inventories": [
{
"id": 1.0,
"billingType": "DataVolume",
"accountUuid": "9d0795db99e93ed49f8bc433dd54cf0e",
"resourceUuid": "5fd7d24b821139eeaec591fc351ffd51",
"spending": 100.0,
"startTime": 1.559017175886E12,
"endTime": 1.559017375886E12,
"hypervisorType": "kvm",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 3.7.0 |
| inventories | List | See inventories. | 3.7.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| id | long | The billing ID. | 3.7.0 |
| billingType | String | The billing type. | 3.7.0 |
| accountUuid | String | The account UUID. | 3.7.0 |
| resourceUuid | String | The resource UUID. | 3.7.0 |
| resourceName | String | The resource name. | 3.7.0 |
| spending | double | The spending. | 3.7.0 |
| startTime | long | The billing start time. | 3.7.0 |
| endTime | long | The billing end time. | 3.7.0 |
| hypervisorType | String | The hypervisor type. | 3.7.0 |
| createDate | Timestamp | The creation date. | 3.7.0 |
| lastOpDate | Timestamp | The last operation date. | 3.7.0 |
SDK Sample
QueryAccountBillingAction action = new QueryAccountBillingAction();
action.conditions = asList("accountUuid=e2ce4c1abea43ac68927e62c31039a81");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryAccountBillingAction.Result res = action.call();QueryAccountBillingAction action = QueryAccountBillingAction()
action.conditions = ["accountUuid=9cbd77ea314a3308bfabed7f7b9c1d1c"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryAccountBillingAction.Result res = action.call()CreatePriceTable
API Request
POST zstack/v1/billings/price-tablesAuthorization: OAuth the-session-uuid{
"params": {
"name": "table_1",
"prices": [
{
"resourceName": "cpu",
"timeUnit": "s",
"price": 10.0
}
]
},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"table_1","prices":[{"resourceName":"cpu","timeUnit":"s","price":10.0}]}}' http://localhost:8080/zstack/v1/billings/price-tables| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| name | String | body (contained in the params structure) | The name of the price table. | 3.7.2 | |
| description | String | body (contained in the params structure) | Optional. The detailed description of the price table. | 3.7.2 | |
| prices | List | body (contained in the params structure) | 3.7.2 | ||
| resourceUuid | String | body (contained in the params structure) | Optional. The price table UUID. | 3.7.2 | |
| tagUuids | List | body (contained in the params structure) | Optional. The tag UUID list. | 3.7.2 | |
| systemTags | List | body | Optional. The system tags. | 3.7.2 | |
| userTags | List | body | Optional. The user tags. | 3.7.2 |
API Response
{
"inventory": {
"uuid": "5a30b2b4c9283fb5ab1971e883d1f315",
"name": "price table",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 3.7.2 |
| inventory | PriceTableInventory | See inventory. | 3.7.2 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 3.7.2 |
| description | String | The brief description of the error. | 3.7.2 |
| details | String | The details about the error. | 3.7.2 |
| elaboration | String | The reserved field. Default value: null. | 3.7.2 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 3.7.2 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 3.7.2 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 3.7.2 |
| name | String | The name of the price table. | 3.7.2 |
| description | String | The detailed description of the price table. | 3.7.2 |
| createDate | Timestamp | The creation date. | 3.7.2 |
| lastOpDate | Timestamp | The last operation date. | 3.7.2 |
SDK Sample
CreatePriceTableAction action = new CreatePriceTableAction();
action.name = "table_1";
action.prices = asList([resourceName:cpu, timeUnit:s, price:10.0]);
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreatePriceTableAction.Result res = action.call();CreatePriceTableAction action = CreatePriceTableAction()
action.name = "table_1"
action.prices = [[resourceName:cpu, timeUnit:s, price:10.0]]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreatePriceTableAction.Result res = action.call()DeletePriceTable
API Request
DELETE zstack/v1/billings/price-tables/{uuid}Authorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/billings/price-tables/81bd5aa16d203ca39bc5e79e2bbc6de2| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The price table UUID. | 3.7.2 | |
| systemTags | List | body | Optional. The system tags. | 3.7.2 | |
| userTags | List | body | Optional. The user tags. | 3.7.2 |
API Response
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Sample
DeletePriceTableAction action = new DeletePriceTableAction();
action.uuid = "81bd5aa16d203ca39bc5e79e2bbc6de2";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeletePriceTableAction.Result res = action.call();DeletePriceTableAction action = DeletePriceTableAction()
action.uuid = "81bd5aa16d203ca39bc5e79e2bbc6de2"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeletePriceTableAction.Result res = action.call()UpdatePriceTable
API Request
PUT zstack/v1/billings/price-tables/{uuid}/actionsAuthorization: OAuth the-session-uuid{
"updatePriceTable": {
"name": "table_1"
},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updatePriceTable":{"name":"table_1","prices":[{"resourceName":"cpu","timeUnit":"s","price":10.0}]}}' http://localhost:8080/zstack/v1/billings/price-tables/f1bb8cafaf1c34608582027ee823ea96/actions| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The price table UUID. | 3.7.2 | |
| name | String | body (contained in the updatePriceTable structure) | Optional. The name of the price table. | 3.7.2 | |
| description | String | body (contained in the updatePriceTable structure) | Optional. The detailed description of the price table. | 3.7.2 | |
| systemTags | List | body | Optional. The system tags. | 3.7.2 | |
| userTags | List | body | Optional. The user tags. | 3.7.2 |
API Response
{
"inventory": {
"uuid": "c52a6ec9d6a033daa5305a19f13448ac",
"name": "price table",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 3.7.2 |
| inventory | PriceTableInventory | See inventory. | 3.7.2 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 3.7.2 |
| description | String | The brief description of the error. | 3.7.2 |
| details | String | The details about the error. | 3.7.2 |
| elaboration | String | The reserved field. Default value: null. | 3.7.2 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 3.7.2 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 3.7.2 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 3.7.2 |
| name | String | The name of the price table. | 3.7.2 |
| description | String | The detailed description of the price table. | 3.7.2 |
| createDate | Timestamp | The creation date. | 3.7.2 |
| lastOpDate | Timestamp | The last operation date. | 3.7.2 |
SDK Sample
UpdatePriceTableAction action = new UpdatePriceTableAction();
action.uuid = "f1bb8cafaf1c34608582027ee823ea96";
action.name = "table_1";
action.prices = asList([resourceName:cpu, timeUnit:s, price:10.0]);
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdatePriceTableAction.Result res = action.call();UpdatePriceTableAction action = UpdatePriceTableAction()
action.uuid = "f1bb8cafaf1c34608582027ee823ea96"
action.name = "table_1"
action.prices = [[resourceName:cpu, timeUnit:s, price:10.0]]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdatePriceTableAction.Result res = action.call()QueryPriceTable
API Request
GET zstack/v1/billings/price-tablesAuthorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/billings/price-tables?q=uuid=2cc88ae55ad13572a5ab9022a204a7afQueryable Fields
You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryPriceTable, and pressing the Tab key.
API Response
{
"inventories": [
{
"uuid": "3e78d076698438a6a68aa2eabdde8adf",
"name": "price table",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 3.7.2 |
| inventories | List | See inventories. | 3.7.2 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 3.7.2 |
| description | String | The brief description of the error. | 3.7.2 |
| details | String | The details about the error. | 3.7.2 |
| elaboration | String | The reserved field. Default value: null. | 3.7.2 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 3.7.2 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 3.7.2 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 3.7.2 |
| name | String | The name of the price table. | 3.7.2 |
| description | String | The detailed description of the price table. | 3.7.2 |
| createDate | Timestamp | The creation date. | 3.7.2 |
| lastOpDate | Timestamp | The last operation date. | 3.7.2 |
SDK Sample
QueryPriceTableAction action = new QueryPriceTableAction();
action.conditions = asList("uuid=86b5cece6d0f3534a0a995ab8e60289f");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryPriceTableAction.Result res = action.call();QueryPriceTableAction action = QueryPriceTableAction()
action.conditions = ["uuid=ab7f7715bdeb3a04964790c3fdfac20d"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryPriceTableAction.Result res = action.call()AttachPriceTableToAccount
API Request
POST zstack/v1/billings/price-tables/{tableUuid}/accounts/{accountUuid}Authorization: OAuth the-session-uuid{
"params": {},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{}}' http://localhost:8080/zstack/v1/billings/price-tables/e32698fcb57d34d68bbf1c4963af95a0/accounts/f354e135276d3e77a46f47c5c0e47b1a| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| accountUuid | String | url | The account UUID. | 3.7.2 | |
| tableUuid | String | url | The price table UUID. | 3.7.2 | |
| tagUuids | List | body | Optional. The tag UUID list. | 3.7.2 | |
| systemTags | List | body | Optional. The system tags. | 3.7.2 | |
| userTags | List | body | Optional. The user tags. | 3.7.2 |
API Response
{
"inventory": {
"uuid": "8d73a258e3973399a8bcfa2164604705"
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 4.7.0 | |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 3.7.2 |
| inventory | PriceTableInventory | See inventory. | 3.7.2 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 3.7.2 |
| description | String | The brief description of the error. | 3.7.2 |
| details | String | The details about the error. | 3.7.2 |
| elaboration | String | The reserved field. Default value: null. | 3.7.2 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 3.7.2 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 3.7.2 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 3.7.2 |
| name | String | The name of the price table. | 3.7.2 |
| description | String | The detailed description of the price table. | 3.7.2 |
| createDate | Timestamp | The creation date. | 3.7.2 |
| lastOpDate | Timestamp | The last operation date. | 3.7.2 |
SDK Sample
AttachPriceTableToAccountAction action = new AttachPriceTableToAccountAction();
action.accountUuid = "f354e135276d3e77a46f47c5c0e47b1a";
action.tableUuid = "e32698fcb57d34d68bbf1c4963af95a0";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachPriceTableToAccountAction.Result res = action.call();AttachPriceTableToAccountAction action = AttachPriceTableToAccountAction()
action.accountUuid = "f354e135276d3e77a46f47c5c0e47b1a"
action.tableUuid = "e32698fcb57d34d68bbf1c4963af95a0"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AttachPriceTableToAccountAction.Result res = action.call()DetachPriceTableFromAccount
API Request
DELETE zstack/v1/billings/price-tables/{tableUuid}/accounts/{accountUuid}Authorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/billings/price-tables/c27d5d1d46ce3b548ec0755d0b354084/accounts/5b81c2a13b2f319ea97a4568575b0266| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| accountUuid | String | url | The account UUID. | 3.7.2 | |
| tableUuid | String | url | The table price UUID. | 3.7.2 | |
| tagUuids | List | body | Optional. The tag UUID list. | 3.7.2 | |
| systemTags | List | body | Optional. The system tags. | 3.7.2 | |
| userTags | List | body | Optional. The user tags. | 3.7.2 |
API Response
{
"inventory": {
"uuid": "34cefcfb3c8e3b97ae94d71558361b25"
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 3.7.2 |
| inventory | PriceTableInventory | See inventory. | 3.7.2 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 3.7.2 |
| description | String | The brief description of the error. | 3.7.2 |
| details | String | The details about the error. | 3.7.2 |
| elaboration | String | The reserved field. Default value: null. | 3.7.2 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 3.7.2 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 3.7.2 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 3.7.2 |
| name | String | The name of the price table. | 3.7.2 |
| description | String | The detailed description of the price table. | 3.7.2 |
| createDate | Timestamp | The creation date. | 3.7.2 |
| lastOpDate | Timestamp | The last operation date. | 3.7.2 |
SDK Sample
DetachPriceTableFromAccountAction action = new DetachPriceTableFromAccountAction();
action.accountUuid = "5b81c2a13b2f319ea97a4568575b0266";
action.tableUuid = "c27d5d1d46ce3b548ec0755d0b354084";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DetachPriceTableFromAccountAction.Result res = action.call();DetachPriceTableFromAccountAction action = DetachPriceTableFromAccountAction()
action.accountUuid = "5b81c2a13b2f319ea97a4568575b0266"
action.tableUuid = "c27d5d1d46ce3b548ec0755d0b354084"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DetachPriceTableFromAccountAction.Result res = action.call()ChangeAccountPriceTableBinding
API Request
PUT zstack/v1/billings/price-tables/{tableUuid}/accounts/{accountUuid}Authorization: OAuth the-session-uuid{
"changeAccountPriceTableBinding": {},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"changeAccountPriceTableBinding":{}}' http://localhost:8080/zstack/v1/billings/price-tables/ca0f8310310e351f8590e4d9f03106bc/accounts/082289755ebe363daa52eb2aa10cbb01| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| accountUuid | String | url | The account UUID. | 3.7.2 | |
| tableUuid | String | url | The price table UUID. | 3.7.2 | |
| resourceUuid | String | body (contained in the changeAccountPriceTableBinding structure) | Optional. | 3.7.2 | |
| tagUuids | List | body (contained in the changeAccountPriceTableBinding structure) | Optional. The tag UUID list. | 3.7.2 | |
| systemTags | List | body | Optional. The system tags. | 3.7.2 | |
| userTags | List | body | Optional. The user tags. | 3.7.2 |
API Response
{
"inventory": {
"uuid": "5e642eb0820b312086f0b084d656c0cf"
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 3.7.2 |
| inventory | PriceTableInventory | See inventory. | 3.7.2 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 3.7.2 |
| description | String | The brief description of the error. | 3.7.2 |
| details | String | The details about the error. | 3.7.2 |
| elaboration | String | The reserved field. Default value: null. | 3.7.2 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 3.7.2 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 3.7.2 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 3.7.2 |
| name | String | The name of the price table. | 3.7.2 |
| description | String | The detailed description of the price table. | 3.7.2 |
| createDate | Timestamp | The creation date. | 3.7.2 |
| lastOpDate | Timestamp | The last operation date. | 3.7.2 |
SDK Sample
ChangeAccountPriceTableBindingAction action = new ChangeAccountPriceTableBindingAction();
action.accountUuid = "082289755ebe363daa52eb2aa10cbb01";
action.tableUuid = "ca0f8310310e351f8590e4d9f03106bc";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeAccountPriceTableBindingAction.Result res = action.call();ChangeAccountPriceTableBindingAction action = ChangeAccountPriceTableBindingAction()
action.accountUuid = "082289755ebe363daa52eb2aa10cbb01"
action.tableUuid = "ca0f8310310e351f8590e4d9f03106bc"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ChangeAccountPriceTableBindingAction.Result res = action.call()GetAccountPriceTableRef
API Request
GET zstack/v1/billings/price-tables/refsAuthorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/billings/price-tables/refs?tableUuid=691136f22ea733b8ae6e90dfe42bf38c| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| tableUuid | String | query | Optional. The price table UUID. | 3.7.2 | |
| accountUuid | String | query | Optional. The account UUID. | 3.7.2 | |
| systemTags | List | query | Optional. The system tags. | 3.7.2 | |
| userTags | List | query | Optional. The user tags. | 3.7.2 |
API Response
{
"accountUuids": [
"67fcb4c5fa0c36adba411d7258d4557e",
"7a9c5437f5393002a8c8c44bd218e41a",
"b11fc0267dbf3c5486accb86c79aca01"
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| accountUuids | List | The account UUID list. | 3.7.2 |
| tableUuid | String | The price table UUID. | 3.7.2 |
| success | boolean | 3.7.2 | |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 3.7.2 |
| error | ErrorCode | See error. | 3.7.2 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 3.7.2 |
| description | String | The brief description of the error. | 3.7.2 |
| details | String | The details about the error. | 3.7.2 |
| elaboration | String | The reserved field. Default value: null. | 3.7.2 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 3.7.2 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 3.7.2 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 3.7.2 |
| description | String | The brief description of the error. | 3.7.2 |
| details | String | The details about the error. | 3.7.2 |
| elaboration | String | The reserved field. Default value: null. | 3.7.2 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 3.7.2 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 3.7.2 |
SDK Sample
GetAccountPriceTableRefAction action = new GetAccountPriceTableRefAction();
action.tableUuid = "691136f22ea733b8ae6e90dfe42bf38c";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetAccountPriceTableRefAction.Result res = action.call();GetAccountPriceTableRefAction action = GetAccountPriceTableRefAction()
action.tableUuid = "691136f22ea733b8ae6e90dfe42bf38c"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetAccountPriceTableRefAction.Result res = action.call()QueryAccountPriceTableRef
API Request
GET zstack/v1/accounts/price-tables/refsAuthorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/accounts/price-tables/refs?q=uuid=491c8b047d073a42ab44213f726fddbfQueryable Fields
You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryAccountPriceTableRef, and pressing the Tab key.
API Response
{
"inventories": [
{
"accountUuid": "3dd9565ef61137c2a8615c26da6ddd4c",
"tableUuid": "b0c83f78e0323aea8969e5b879ffbe5f",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 3.7.2 |
| inventories | List | See inventories. | 3.7.2 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 3.7.2 |
| description | String | The brief description of the error. | 3.7.2 |
| details | String | The details about the error. | 3.7.2 |
| elaboration | String | The reserved field. Default value: null. | 3.7.2 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 3.7.2 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 3.7.2 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| accountUuid | String | The account UUID. | 3.7.2 |
| tableUuid | String | The price table UUID. | 3.7.2 |
| createDate | Timestamp | The creation date. | 3.7.2 |
| lastOpDate | Timestamp | The last operation date. | 3.7.2 |
SDK Sample
QueryAccountPriceTableRefAction action = new QueryAccountPriceTableRefAction();
action.conditions = asList("uuid=36ee3e78b96a32179ffeefc28f4c6cf0");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryAccountPriceTableRefAction.Result res = action.call();QueryAccountPriceTableRefAction action = QueryAccountPriceTableRefAction()
action.conditions = ["uuid=c5a7e0e081583016a4a316245ff6d525"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryAccountPriceTableRefAction.Result res = action.call()GenerateAccountBilling
API Request
PUT zstack/v1/billings/accounts/{accountUuid}/actionsAuthorization: OAuth the-session-uuid{
"generateAccountBilling": {},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"generateAccountBilling":{}}' http://localhost:8080/zstack/v1/billings/accounts/54caddf06e1e3b7c995df5e99d8ca9d9/actions| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| accountUuid | String | url | The account UUID. | 3.7.2 | |
| systemTags | List | body | Optional. The system tags. | 3.7.2 | |
| userTags | List | body | Optional. The user tags. | 3.7.2 |
API Response
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Sample
GenerateAccountBillingAction action = new GenerateAccountBillingAction();
action.accountUuid = "54caddf06e1e3b7c995df5e99d8ca9d9";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GenerateAccountBillingAction.Result res = action.call();GenerateAccountBillingAction action = GenerateAccountBillingAction()
action.accountUuid = "54caddf06e1e3b7c995df5e99d8ca9d9"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GenerateAccountBillingAction.Result res = action.call()