Updated on 2024-10-29 GMT+08:00

Querying Customer's Yearly/Monthly Resources

Function

A customer can query one or all yearly/monthly resources on the self-built platform.

If you need to renew resources that already take effect after you successfully invoke this API, you can invoke the API described in Querying the Price of a Yearly/Monthly Product to query the price for the yearly/monthly resources and then invoke the API described in Renewing Subscription to Yearly/Monthly Resources to renew the subscription.

Constraints

  • This API can be invoked only by the customer AK/SK or token.
  • This API queries resources successfully provisioned only.
  • If a parameter is set to null, is set to an empty JSON array, or is set to "", the specified number of resources of the current account will be returned. The number of resources is specified by the limit parameter, and the default value is 10.

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/orders/suscriptions/resources/query

Request

Request Parameters

Table 1 Request parameters

Parameter

Mandatory

Type

Value Range

Description

resource_ids

No

list<String>

[0-50]

Resource IDs.

Queries resources with the specified resource IDs. When only_main_resource is 0, the system queries the specified resources and their auxiliary resources. A maximum of 50 IDs can be used at the same time.

If this parameter is not included in the request parameters, is left empty, or is set to null, it cannot be used as a filter criterion. Records that meet other search criteria are returned.

NOTE:

A resource ID is allocated by a cloud service after the resource is provisioned, such as server_id for ECS.

order_id

No

String

A maximum of 64 characters

Order ID. This parameter can be used for querying the resources in a specified order.

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. Records that meet other search criteria are returned.

NOTE:

When special characters are used for query, perform the URL code conversion. For example, % should be converted to %25.

only_main_resource

No

Integer

0, 1

Whether to query only the primary resources. This parameter is invalid when resource_ids are IDs of attached resources. In this case, the system queries the attached resources.

  • 0: Queries both the primary resources and attached resources.
  • 1: Queries only the primary resources.

The default value is 0.

If this parameter is not included in the request parameters or is set to null, the default value 0 is used.

NOTE:

A primary resource takes the primary position in the associated resources.

  • For ECS, ECS is the primary resource, and EVS is the attached resource.
  • For VPC, if the shared bandwidth is used, the bandwidth is the primary resource, and EIPs are the attached resource. If the exclusive bandwidth is used, EIPs are the primary resources, and the bandwidth is the attached resource.

status_list

No

list<Integer>

[0-10]

Resource status.

Queries resources in a specified status. If there are multiple statuses, separate them using commas (,).

  • 2: Provisioned
  • 3: Closed
  • 4: Frozen
  • 5: Expired

If this parameter is not included in the request parameters, is left empty, or is set to null, it cannot be used as a filter criterion. Resources in all statuses are returned.

offset

No

Integer

0 to 2147483646

Offset, starting from 0. The default value is 0.

NOTE:

This parameter is used for pagination. Retain its default value 0 if pagination is not required. offset indicates the offset relative to the first data record among all that meets the conditions configured. If you set offset to 1, the second and subsequent data records are returned.

For example, if there are 10 records that meet query conditions, when you set limit to 10 and offset to 1, the second to the tenth records are returned.

If there are 20 records that meet query conditions, when you set offset to 0 and limit to 10 for the first page and set offset to 10 and limit to 10 for the second page, then each page will respectively have 10 records.

limit

No

Integer

1 to 500

Number of records queried each time. The default value is 10.

expire_time_begin

No

String

20

Start time of a period during which there are expired resources. The time is in the UTC format yyyy-MM-dd'T'HH:mm:ss'Z', for example, 2019-05-06T08:05:01Z. The range of HH is 0-23, and the range of mm and ss is 0-59.

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. Records that meet other search criteria are returned.

expire_time_end

No

String

20

End time of a period during which there are expired resources. The time is in the UTC format yyyy-MM-dd'T'HH:mm:ss'Z', for example, 2019-05-06T08:05:01Z. The range of HH is 0-23, and the range of mm and ss is 0-59.

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. Records that meet other search criteria are returned.

service_type_code

No

String

64

Cloud service type code. For example, the cloud service type code of OBS is hws.service.type.obs. You can call the Querying Cloud Service Types API to query the type of a cloud service.

If this parameter is not included or is set to null, it will not be used as a filter criterion. This parameter cannot be set to an empty string. There will be parameter verification.

Example Request

POST https://bss-intl.myhuaweicloud.com/v2/orders/suscriptions/resources/query HTTP/1.1
Content-Type: application/json
X-Auth-Token: MIIPAgYJKoZIhvcNAQcCo...ggg1BBIINPXsidG9rZ
{
    "resource_ids":[
        "0A063A********BC8548E65D0089A905"
    ],
    "order_id":"CS1905251035OA***",
    "only_main_resource":1,
    "status_list":[
        2
    ],
    "offset":0,
    "limit":10,
    "expire_time_begin":"2021-09-01T08:05:01Z",
    "expire_time_end":"2021-09-03T08:05:01Z",
    "service_type_code": "hws.service.type.obs"
}

Response

Response Parameters

Parameter

Type

Description

error_code

String

Error code.

For details, see Returned Values.

error_msg

String

Error description.

data

List<OrderInstanceV2>

Resource list.

For details, see Table 2.

total_count

Integer

Total number of records

Table 2 OrderInstanceV2

Parameter

Type

Description

id

String

Internal ID of the resource to be provisioned. The ID generated after the resource is provisioned is resource_id.

resource_id

String

Resource ID.

resource_name

String

Resource instance name.

region_code

String

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

service_type_code

String

Cloud service type code. For example, the cloud service type code of OBS is hws.service.type.obs.

resource_type_code

String

Resource type code. For example, the VM resource type code of ECS is hws.resource.type.vm.

resource_spec_code

String

Specification of a cloud service resource. For example, a VM resource specification is s2.small.1.linux (.win or .linux should be added at the end of the specification).

service_type_name

String

Cloud service type. For example, the cloud service type of ECS is Elastic Cloud Server.

resource_type_name

String

Resource type. For example, the resource type of ECS is Cloud Host.

project_id

String

Resource project ID.

product_id

String

Product ID.

parent_resource_id

String

Parent resource ID

is_main_resource

Integer

Primary resource or not.

  • 0: Attached resource
  • 1: Primary resource

status

Integer

Resource status.

  • 2: Provisioned
  • 3: Closed (not visible to customers)
  • 4: Frozen
  • 5: Expired

effective_time

String

Effective time of a resource.

UTC time in "yyyy-MM-dd'T'HH:mm:ss'Z'" format, such as 2019-05-06T08:05:01Z

expire_time

String

Expiration time of a resource.

UTC time in "yyyy-MM-dd'T'HH:mm:ss'Z'" format, such as 2019-05-06T08:05:01Z

expire_policy

Integer

Billing policy after a resource expires.

  • 0: Entering the grace period upon expiration
  • 1: Yearly/monthly to pay-per-use
  • 2: Automatically deleted upon expiration (directly deleted from resources that take effect)
  • 3: Automatically renewed upon expiration
  • 4: Automatically frozen upon expiration
  • 5: Automatically deleted upon expiration (deleted from resources in the retention period)
NOTE:

Only 3 indicates that the resource is automatically renewed. In other cases, the expiration policy for non-automatic renewal is used.

Example Response

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: length
Date: response time
{
  "data": [
  {
     "id": "01154-54600027-0",
     "resource_id": "0A063A11905F42BC8548E65D0089A905",
     "resource_name": "0A063A11905F42BC8548E65D0089A905name",
     "region_code": "ap-southeast-1",
     "service_type_code": "hws.service.type.ebs",
     "resource_type_code": "hws.resource.type.volume",
     "resource_spec_code": "SSD",
     "project_id": "1dd89a5fe99e4cca80edca61e737477a",
     "product_id": "2fd338aca5ae4a01aac81deaa900e441",
     "parent_resource_id": "9ad02e1ad3394d1bb3da48890fbc4c06",
     "is_main_resource": 1,
     "status": 2,
     "effective_time": "2020-05-03T09:11:10Z",
     "expire_time": "2020-06-03T09:11:10Z",
     "expire_policy": 0
    }
   ],
  "total_count": 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 Value

Error Code

Description

400

CBC.0100

Parameter error.

403

CBC.0151

Access denied.

500

CBC.0999

Other errors.