Updated on 2024-03-27 GMT+08:00

Querying the Resource Instance List

Function

This API is used to query the resource instance list.

URI

POST /v5/{project_id}/{resource_type}/resource-instances/filter

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID of a tenant in a region.

For details, see Obtaining a Project ID.

resource_type

Yes

String

Resource type.

  • migration: real-time migration.
  • sync: real-time synchronization.
  • cloudDataGuard: real-time disaster recovery.
  • subscription: data subscription.
  • backupMigration: backup migration.
  • replay: traffic replay.

Enumerated values:

  • migration
  • sync
  • cloudDataGuard
  • subscription
  • backupMigration
  • replay
Table 2 Query parameters

Parameter

Mandatory

Type

Description

limit

No

Integer

Number of records to be queried, which ranges from 1 to 1000. The default value is 1000.

offset

No

Integer

Index position. If offset is set to N, the resource query starts from the N+1 piece of data. The value is 0 by default, indicating that the query starts from the first piece of data. The value cannot be a negative number.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

MIME type of the request body. Use the default value application/json. For APIs used to upload objects or images, the value varies depending on the flow type.

The default value is application/json.

X-Auth-Token

Yes

String

User token obtained from IAM. It is a response to the API for obtaining a user token. After a request is processed, the value of X-Subject-Token in the header is the token value.

X-Language

No

String

Request language type.

Default value: en-us

Enumerated values:

  • en-us
  • zh-cn
Table 4 Request body parameters

Parameter

Mandatory

Type

Description

without_any_tag

No

Boolean

If this parameter is set to true, all resources without tags are queried. In this case, the tags field is ignored. If this parameter is set to false or not specified, it does not take effect, which means that all resources are returned or resources are filtered by tags or matches.

tags

No

Array of objects

Included tags. A maximum of 20 keys are included. Each key can have a maximum of 20 values.

For details, see Table 5.

matches

No

Array of objects

Search field. The tag key is the field to be matched, for example, resource_name. The tag value indicates the value to be matched.

For details, see Table 6.

Table 5 Data structure description of field tags

Parameter

Mandatory

Type

Description

key

Yes

String

Tag key.

values

Yes

Array of strings

Tag value.

Table 6 Data structure description of field matches

Parameter

Mandatory

Type

Description

key

Yes

String

Key.

value

Yes

String

Value.

Response Parameters

Status code: 200

Table 7 Response body parameters

Parameter

Type

Description

total_count

Integer

Total number.

resources

Array of objects

Resource list.

For details, see Table 8.

Table 8 Data structure description of parameter resources

Parameter

Type

Description

resource_id

String

Resource ID.

resource_detail

String

Resource details. The value is a resource object, used for extension. This parameter is left blank by default.

resource_name

String

Resource name.

tags

Array of objects

Tag list.

For details, see Table 9.

Table 9 Data structure description of field tags

Parameter

Type

Description

key

String

Tag key.

value

String

Tag value.

Example Request

Querying the instance list of a synchronization task

 https://{endpoint}/v5/5237e10fe9aa4ad5b16b6a5245248314/sync/resource-instances/filter?limit=1000&offset=0

{
  "tags" : [ {
    "key" : "key1",
    "values" : [ "value1", "value2" ]
  }, {
    "key" : "key2",
    "values" : [ "value1", "value2" ]
  } ],
  "matches" : [ {
    "key" : "resource_name",
    "value" : "resource1"
  } ],
  "without_any_tag" : false
}

Example Response

Status code: 200

OK

{
  "resources" : [ {
    "tags" : [ {
      "key" : "aaaaa",
      "value" : "bbbbb"
    }, {
      "key" : "zzzz",
      "value" : ""
    } ],
    "resource_id" : "2f4af282-d13e-4b10-a1eb-609b47fjb201",
    "resource_detail" : "",
    "resource_name" : "DRS-5634"
  } ],
  "total_count" : 1
}

Status Code

Status Code

Description

200

OK

Error Code

For details, see Error Code.