Querying an Instance by Tag
Function
This API is used to query a specified instance by tag.
Constraints
This API supports the following instances:
- GeminiDB Cassandra
- GeminiDB Mongo
- GeminiDB Influx
- GeminiDB Redis
A maximum of 20 tags can be added to a DB instance. The tag key must be unique.
Authorization Information
Each account has permissions to call all APIs, but IAM users must have the required permissions specifically assigned.
- If you are using role/policy-based authorization, see the required permissions in Permissions and Supported Actions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
gaussdbfornosql::listResourcesByTags
List
-
-
- nosql:instance:list
- nosql:tag:list
-
URI
POST /v3/{project_id}/instances/resource-instances/action
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition Project ID of a tenant in a region. To obtain this value, see Obtaining a Project ID. Constraints N/A Range The value contains 32 characters. Only letters and digits are allowed. Default Value N/A |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | Yes | String | Definition User token You can obtain the token by calling the IAM API by following Obtaining a User Token Through Password Authentication. Constraints N/A Range N/A Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| offset | No | String | Definition Index offset. The query starts from the next piece of data indexed by this parameter. Constraints
Range ≥ 0 Default Value 0: The query starts from the first piece of data. |
| limit | No | String | Definition Number of records returned by a query. Constraints
Range 1–100 Default Value If this parameter is not transferred, the first 100 instances are queried by default. |
| action | Yes | String | Definition Operation identifier. Constraints N/A Range
Default Value N/A |
| matches | No | Array of MatchOption objects | Definition Field to be matched. If this parameter is not specified, the query is not based on the instance name or ID. Constraints N/A |
| tags | No | Array of TagOption objects | Definition Tags to be included. Constraints A maximum of 20 keys are allowed. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| key | Yes | String | Definition Matching key. Constraints N/A Range
Default Value N/A |
| value | Yes | String | Definition Name or ID of the instance to be matched. Constraints N/A Range N/A Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| key | Yes | String | Definition Tag key. Constraints It can contain a maximum of 36 Unicode characters. The key value cannot be null, an empty string, or spaces. Before using key, delete spaces before and after the value. The character set of this parameter is not verified during search. Range N/A Default Value N/A |
| values | Yes | Array of strings | Definition Tag values. Constraints Each tag value can contain a maximum of 43 Unicode characters and cannot contain spaces. Before using values, delete spaces before and after the value. If values is not specified, any value can be queried. The values are in the OR relationship. |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| instances | Array of InstanceResult objects | Definition Instance information list. |
| total_count | Integer | Definition Total number of records. Range N/A |
| Parameter | Type | Description |
|---|---|---|
| instance_id | String | Definition Instance ID. Range N/A |
| instance_name | String | Definition Instance name. Range N/A |
| tags | Array of InstanceTagResult objects | Definition Tags. If there is no tag, an empty array is used by default. |
| Parameter | Type | Description |
|---|---|---|
| key | String | Definition Tag key. Each tag key can contain up to 36 Unicode characters and cannot be left blank. Only digits, uppercase letters, lowercase letters, underscores (_), and hyphens (-) are allowed. Range N/A |
| value | String | Definition Tag value. Each tag value can contain a maximum of 43 Unicode characters and can be an empty string. Only digits, uppercase letters, lowercase letters, underscores (_), periods (.), and hyphens (-) are allowed. Range N/A |
Example Requests
- Querying an instance by name (Set both offset and limit to 100.)
POST https://{Endpoint}/v3/375d8d8fad1f43039e23d3b6c0f60a19/instances/resource-instances/action { "offset" : "100", "limit" : "100", "action" : "filter", "matches" : [{ "key" : "instance_name", "value" : "test-single" }], "tags" : [{ "key" : "key1", "values" : [ "value1", "value2" ] }] } - Querying total records
POST https://{Endpoint}/v3/375d8d8fad1f43039e23d3b6c0f60a19/instances/resource-instances/action { "action" : "count", "tags" : [ { "key" : "key1", "values" : [ "value1", "value2" ] }, { "key" : "key2", "values" : [ "value1", "value2" ] } ], "matches" : [ { "key" : "instance_name", "value" : "test-single" }, { "key" : "instance_id", "value" : "958693039f284d6ebfb177375711072ein06" } ] }
Example Responses
Status code: 200
Success
{
"total_count": 1,
"instances" : [{
"instance_id" : "2acbf2223caf3bac3c33c6153423c3ccin06",
"instance_name" : "test-single",
"tags" : [ {
"key" : "key1",
"value" : "value1"
}, {
"key" : "key2",
"value" : "value1"
} ]
}]
} Status Codes
For details, see Status Codes.
Error Codes
For details, see Error Codes.
What is your overall rating for this page?
Thank 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