Querying the Price of a Pay-Per-Use Product
Function
Customers can query the price of a pay-per-use product by criteria on the self-built platform.
If the tenant who purchases the product enjoys a discount, the discount amount and the final price can be obtained from the query result.
If the tenant has enjoyed multiple types discounts, the system will return the commercial discount amount and the final price preferentially.
- Ensure that you provide the correct service type, region, resource type, and resource specification. Otherwise, an error may be reported.
- You can use the price calculator to determine product prices.
- You can also use the price calculator to get the value of the product_infos request parameter when you call the API for querying product prices. For more details, see price inquiry examples.
Constraints
This API can be called using the customer AK/SK or token.
Debugging
You can debug the API in API Explorer which supports automatic authentication. API Explorer can automatically generate and debug example SDK code.
URI
POST /v2/bills/ratings/on-demand-resources
Request
Request Parameters
Parameter |
Mandatory |
Type |
Value Range |
Description |
---|---|---|---|---|
project_id |
Yes |
String |
A maximum of 64 characters |
Project ID.
NOTE:
|
product_infos |
Yes |
List<DemandProductInfo> |
A maximum of 100 values |
Indicates the product information list. For details, see Table 1. |
inquiry_precision |
No |
Integer |
- |
Precision of the price query result. The default value of this parameter is 0 (default precision of the price query result).
NOTE:
Value 0 and value 1 make differences only when the query result contains at least six decimal places. |
Parameter |
Mandatory |
Type |
Value Range |
Description |
---|---|---|---|---|
id |
Yes |
String |
A maximum of 64 characters |
The ID is used to identify the mapping between the inquiry result and the request and must be unique in an inquiry. |
cloud_service_type |
Yes |
String |
A maximum of 400 characters |
Cloud service type code. For example, the cloud service type code of OBS is hws.service.type.obs. To obtain a specific service type, call the API in Querying Cloud Service Types. |
resource_type |
Yes |
String |
A maximum of 400 characters |
Resource type code. For example, the VM resource type code of ECS is hws.resource.type.vm. To obtain a specific resource type, call the API in Querying Resource Types. The relationship between ResourceType and CloudServiceType is as follows: A resource type represents a resource contained in the cloud service type, and the cloud service type is a combination of multiple resource types. |
resource_spec |
Yes |
String |
A maximum of 400 characters |
Resource specifications. For details, see related cloud service documentation. The following provides examples of services and resource specifications:
|
region |
Yes |
String |
A maximum of 64 characters |
Cloud service region code, for example, ap-southeast-1. Obtain the value from the Region column in Regions and Endpoints. |
usage_factor |
Yes |
String |
A maximum of 64 characters |
Usage factor. Usage factors are case-insensitive. The value is the same as the usage factor value in the SDR. The mapping between cloud services and usage factors is as follows:
You can call the API in Querying Usage Types to obtain the value of parameter code in Table 3. The value indicates the billing factor of each cloud service. |
usage_value |
Yes |
BigDecimal |
- |
Usage value. For example, if you want to inquire a product price by hour, set usageValue to 1 and usageMeasureID to 4 (hour). |
usage_measure_id |
Yes |
Integer |
A maximum of 4 characters |
Usage unit. You can call the API in Querying Measurement Units to obtain the value. For example, if you want to inquire a product price by hour, set usageValue to 1 and usageMeasureID to 4 (hour). |
subscription_num |
Yes |
Integer |
[1-10000] |
Number of subscriptions. |
available_zone |
No |
String |
A maximum of 64 characters |
Available zone ID. Available zone IDs are case-insensitive. If this parameter is not included in the request parameters, is set to "", or is set to null, it cannot be used as a filter criterion. |
resource_size |
No |
Integer |
[1-214783647] |
Resource capacity. It can be the subscribed volume size or bandwidth size. This parameter is mandatory for a linear product. Linear products are those whose size must be specified during a subscription, such as hard disks and bandwidth. For example, you can select 10 GB or 20 GB during a disk subscription. For non-linear products, if this parameter is not included in the request parameters or is set to null, it cannot be used as a filter criterion. |
size_measure_id |
No |
Integer |
A maximum of 4 characters |
Resource capacity measurement ID. The options are:
This field should be filled together with resource_size or left blank. Linear products are those whose size must be specified during a subscription, such as hard disks and bandwidth. For example, you can select 10 GB or 20 GB during a disk subscription. For non-linear products, if this parameter is not included in the request parameters or is set to null, it cannot be used as a filter criterion. |
Example Request
POST https://bss-intl.myhuaweicloud.com/v2/bills/ratings/on-demand-resources HTTP/1.1 Content-Type: application/json X-Auth-Token: MIIPAgYJKoZIhvcNAQcCo...ggg1BBIINPXsidG9rZ { "project_id": "06488a********832f55c016b0e337d7", "product_infos": [ { "id": "1", "cloud_service_type": "hws.service.type.ec2", "resource_type": "hws.resource.type.vm", "resource_spec": "c3.3xlarge.2.linux", "region": "ap-southeast-1", "usage_factor": "Duration", "usage_value": 2, "usage_measure_id": 4, "subscription_num": 1, "available_zone": null }, { "id": "2", "cloud_service_type": "hws.service.type.ebs", "resource_type": "hws.resource.type.volume", "resource_spec": "SSD", "region": "ap-southeast-1", "usage_factor": "Duration", "usage_value": 2, "usage_measure_id": 4, "subscription_num": 1, "resource_size": 10, "size_measure_id": 17 }, { "id": "3", "cloud_service_type": "hws.service.type.vpc", "resource_type": "hws.resource.type.ip", "resource_spec": "5_bgp", "region": "ap-southeast-1", "usage_factor": "Duration", "usage_value": 3, "usage_measure_id": 4, "subscription_num": 1, "available_zone": null }, { "id": "4", "cloud_service_type": "hws.service.type.vpc", "resource_type": "hws.resource.type.bandwidth", "resource_spec": "12_sbgp", "region": "ap-southeast-1", "usage_factor": "upflow", "usage_value": 4, "usage_measure_id": 10, "subscription_num": 1, "available_zone": "cn-north-1a", "resource_size": 1, "size_measure_id": 15 } ], "inquiry_precision": 1 }
Response
Response Parameters
Parameter |
Type |
Value Range |
Description |
---|---|---|---|
error_code |
String |
A maximum of 20 characters |
Status code. For details, see Returned Values. This parameter is returned only when the query failed. |
error_msg |
String |
A maximum of 1000 characters |
Error description. This parameter is returned only when the query failed. |
amount |
BigDecimal |
- |
Final price after discount |
discount_amount |
BigDecimal |
- |
Discount amount (difference between the list price and the final price). |
official_website_amount |
BigDecimal |
- |
List price of a pay-per-use product |
measure_id |
Integer |
A maximum of 4 characters |
Measurement unit ID. 1: USD |
currency |
String |
A maximum of 20 characters |
Currency. USD If the parameter is left blank, USD is used. |
product_rating_results |
List<DemandProductRatingResult> |
- |
Product price query result. For details, see Table 2. |
Parameter |
Type |
Value Range |
Description |
---|---|---|---|
id |
String |
A maximum of 64 characters |
The ID is used to identify the mapping between the inquiry result and the request and must be unique in an inquiry. |
product_id |
String |
A maximum of 64 characters |
Product ID. |
amount |
BigDecimal |
- |
Final price after discount |
discount_amount |
BigDecimal |
- |
Discount amount (difference between the list price and the final price). |
official_website_amount |
BigDecimal |
- |
List price of a pay-per-use product |
measure_id |
Integer |
A maximum of 4 characters |
Measurement unit ID. 1: USD |
discount_rating_results |
List<DemandDiscountRatingResult> |
- |
Discount details, including the product promotion information and commercial or partner discount information. For details, see Table 3.
NOTE:
If the user does not have the required permission, no information is returned. For details, see API Access Permission (Customer). |
Parameter |
Type |
Value Range |
Description |
---|---|---|---|
discount_id |
String |
A maximum of 64 characters |
Discount ID. |
discount_type |
Integer |
A maximum of 4 characters |
Discount type. |
amount |
BigDecimal |
- |
Discounted amount. |
measure_id |
Integer |
A maximum of 4 characters |
Measurement unit ID. 1: USD |
discount_name |
String |
A maximum of 256 characters |
Discount name. |
Example Response
HTTP/1.1 200 OK Content-Type: application/json;charset=UTF-8 Content-Length: length Date: response time { "amount": 8.128, "discount_amount": 0.0, "official_website_amount": 8.128, "measure_id": 1, "currency": "USD", "product_rating_results": [ { "id": "1", "product_id": "00301-243025-0--0_merge", "amount": 5.48, "discount_amount": 0.0, "official_website_amount": 5.48, "measure_id": 1, "discount_rating_results": [] }, { "id": "2", "product_id": "00301-290407774-0--1", "amount": 0.028, "discount_amount": 0.0, "official_website_amount": 0.028, "measure_id": 1, "discount_rating_results": [] }, { "id": "3", "product_id": "00301-238601-0--0_merge", "amount": 0.06, "discount_amount": 0.0, "official_website_amount": 0.06, "measure_id": 1, "discount_rating_results": [] }, { "id": "4", "product_id": "00301-290407706-0--1", "amount": 2.56, "discount_amount": 0.0, "official_website_amount": 2.56, "measure_id": 1, "discount_rating_results": [] } ] }
Returned Values
- 4xx: This class of HTTP status code is intended for situations in which the error seems to have been caused by the client, for example, the request contains bad syntax or incorrect parameters. You must ensure the request is correct.
- 5xx: This class of HTTP status code is intended for cases in which the Huawei Cloud server is aware that it has encountered an error or is otherwise incapable of performing the request. In this case, contact Huawei Cloud customer service.
HTTP Value |
Error Code |
Description |
---|---|---|
400 |
CBC.0100 |
Parameter error. |
400 |
CBC.99006006 |
Product not found. |
400 |
CBC.99006050 |
Incorrect usage unit. |
400 |
CBC.99006055 |
The queried amount exceeds the upper limit. |
400 |
CBC.99006074 |
The billing item does not exist. |
403 |
CBC.0151 |
Access denied. |
500 |
CBC.0999 |
Other errors. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot