Updated on 2023-12-13 GMT+08:00

Querying the Package Usage

Function

A customer can query the package usage on the self-built platform.

This API will be taken offline. For details about the API for querying the usage in a package, see Querying Resource Packages and Querying the Package Usage.

Constraints

This API can be invoked only using the AK/SK or token of the customer.

URI

POST /v2/payments/free-resources/usages/query

Table 1 Header parameter

Parameter

Mandatory

Value Range

Description

X-Language

No

A maximum of 8 characters

Language.

  • zh_CN: Chinese
  • en_US: English

Default value: zh_CN

If this parameter is not included in the request parameters or is left empty, the value zh_CN is used. This parameter cannot be set to "" or null.

Request

Request Parameters

N/A

Example Request

POST https://bss-intl.myhuaweicloud.com/v2/payments/free-resources/usages/query HTTP/1.1
Content-Type: application/json
X-Auth-Token: MIIPAgYJKoZIhvcNAQcCo...ggg1BBIINPXsidG9rZ 

Response

Response Parameters

Parameter

Type

Value Range

Description

error_code

String

A maximum of 20 characters

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

package_usage_infos

list<PackageUsageInfo>

-

Package usage. For details, see Table 2.

Table 2 Package usage information

Parameter

Type

Value Range

Description

order_instance_id

String

A maximum of 255 characters

Identifier of a subscribed resource package.

resource_type_name

String

A maximum of 255 characters

Resource type.

quota_reuse_mode

Integer

-

Use model. The options are as follows:

  • 1: Resettable

    Indicates that the usage of the purchased pay-per-use resource package can be restored based on a specified period. For example, if you purchase a 1-year 40 GB pay-per-use resource package with quota_reuse_mode set to 1 and quota_reuse_cycle to 4, then the resource package will be reset each month (you will get 40 GB resource each month) within the year.

  • 2: Not resettable

    Indicates that the usage of the purchased pay-per-use package will not be restored. For example, if you purchase a 1-year 40 GB pay-per-use resource package with quota_reuse_mode set to 2, the resource package will not be reset, and you will get 40 GB resource within the year.

quota_reuse_cycle

Integer

-

Reset period. This parameter is valid only when quota_reuse_mode is set to 1 (Resettable).

  • 1: Hour
  • 2: Day
  • 3: Week
  • 4: Month
  • 5: Year

quota_reuse_cycle_type

Integer

-

Reset period type. This field is valid only when quota_reuse_mode is set to 1 (Resettable).

If quota_reuse_mode is set to resetable and the value of quota_reuse_cycle_type is null, the quota is reset by calendar period by default.

  • 1: Reset by calendar period

    Indicates that the resource package is reset by calendar month or calendar year. For example, if you set quota_reuse_cycle to 4 (month) and quota_reuse_cycle_type to 1, the resource package is reset on the first day of each month.

  • 2: Reset by order period

    Indicates that the resource package is reset by order period. For example, if you set quota_reuse_cycle to 4 (month), and quota_reuse_cycle_type to 2, and you purchase this resource package on the 15th day of the month, then the resource package will be reset on the 15th day of each month.

start_time

String

A maximum of 64 characters

Start time. The value is in UTC format.

  • If quota_reuse_mode is set to 1, the value is the start time of the reset period for the current time.
  • If quota_reuse_mode is set to 2, the value is the time when the purchased instance takes effect.

end_time

String

A maximum of 64 characters

End time. The value is in UTC format.

  • If quota_reuse_mode is set to 1, the value is the end time of the reset period for the current time.
  • If quota_reuse_mode is set to 2, the value is the time when the purchased instance becomes invalid.

balance

Number

-

Remaining resources in a package.

total

Number

-

Total number of resources in a package.

measurement_name

String

A maximum of 255 characters

Measurement unit name of a package resource.

region_code

String

A maximum of 255 characters

Cloud service region code, for example, ap-southeast-1. Obtain the value from the Region column in Regions and Endpoints.

Example Response

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: length
Date: response time 
{
    "package_usage_infos": [
        {
            "order_instance_id": "01154-119701448-0",
            "resource_type_name": "cdn.cdn.flow",
            "quota_reuse_mode": 1,
            "quota_reuse_cycle": 1,
            "quota_reuse_cycle_type": 1,
            "start_time": "2019-12-26T02:00:00Z",
            "end_time": "2019-12-26T02:24:11Z",
            "balance": 100,
            "total": 100,
            "measurement_name": "Byte",
            "region_code": "global-cbc-1"
        }   ]
}

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 Status Code

Error Code

Description

500

CBC.0999

Other errors.