Updated on 2024-11-26 GMT+08:00

Querying the Price of a Pay-Per-Use Product

Function

Partners can query the price of a pay-per-use product by criteria on the sales 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 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 partner token. Before using the partner token to call this API, the partner needs to request authorization from the customer or ask the customer to create an agency for them.

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).

  • 0: The default precision of the query result. The result contains a maximum of six decimal places with the unit of USD, such as USD 0.000001.
  • 1: The result contains a maximum of 10 decimal places with the unit of USD, such as USD 1.0000000001.
NOTE:

Value 0 and value 1 make differences only when the query result contains at least six decimal places.

Table 1 DemandProductInfo

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:

  • ECS

    Add .win or .linux to the end of the ECS flavor ID based on the OS type, for example, s2.small.1.linux. Call the API for querying details about flavors and extended flavor information to obtain the flavor IDs.

  • Bandwidth
    • 12_bgp: dynamic BGP bandwidth billed by traffic
    • 12_sbgp: static BGP bandwidth billed by traffic
    • 19_bgp: dynamic BGP bandwidth billed by bandwidth
    • 19_sbgp: Static BGP bandwidth billed by bandwidth
    • 19_share: Shared bandwidth billed by bandwidth
  • IP address:
    • 5_bgp: dynamic BGP public IP address
    • 5_sbgp: static BGP public IP address
  • EVS
    • SATA: common I/O EVS disk
    • SAS: high I/O EVS disk
    • GPSSD: general-purpose SSD EVS disk
    • SSD: ultra-high I/O EVS disk
    • ESSD: Extreme SSD
    • GPSSD2.storage: General-purpose SSD V2 storage
    • GPSSD2.iops: General-purpose SSD V2 iops
    • GPSSD2.throughput: General-purpose SSD V2 throughput

region

Yes

String

A maximum of 64 characters

Cloud service region code, for example, eu_west_101.

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:

  • Cloud server: Duration
  • Cloud disk: Duration
  • EIP: Duration
  • Bandwidth: Duration or upflow
  • Marketplace image: Duration

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:

  • 15: Mbit/s (used when the bandwidth is subscribed)
  • 17: GB (used when an EVS disk is subscribed to)
  • 14: amount (times)

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.myhuaweicloud.eu/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": "eu-west-101",
            "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": "eu-west-101",
            "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": "eu-west-101",
            "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": "eu-west-101",
            "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.

Table 2 DemandProductRatingResult

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.

Table 3 DemandDiscountRatingResult

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.

  • Commercial discounts:
    • 605: Contract commercial discount in the HUAWEI CLOUD BE scenario
    • 606: Contract commercial discount in the reseller BE scenario
  • Partner discounts:

    607: Partner authorized discount

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.