Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Querying Resources by Tag

Updated on 2023-11-24 GMT+08:00

Description

This API is used to query the specified DB instances by tag.

Restrictions

A maximum of 20 tags can be added to a DB instance. The tag key must be unique.

URI

  • URI format

    POST https://{Endpoint}/v3/{project_id}/instances/action

  • URI example

    https://dds.ap-southeast-1.myhuaweicloud.com/v3/0549b4a43100d4f32f51c01c2fe4acdb/instances/action

Table 1 Request parameters

Name

Type

IN

Mandatory

Description

X-Auth-Token

string

header

Yes

User token obtained from IAM. For details, see Authentication.

project_id

string

path

Yes

Project ID of a tenant in a region. To obtain the project ID, see Obtaining a Project ID.

Requests

  • Parameter description
    Table 2 Parameter description

    Name

    Type

    Mandatory

    Description

    offset

    String

    No

    The index position. The query starts from the next piece of data indexed by this parameter.

    • If action is set to count, this parameter is not transferred.
    • If action is set to filter, this parameter must be a positive integer. The default value is 0, indicating that the query starts from the first piece of data.

    limit

    String

    No

    The number of resources to be queried.

    • If action is set to count, this parameter is not transferred.
    • If action is set to filter, the value range is from 1 to 100. If this parameter is not transferred, the first 100 DB instances are queried by default.

    action

    String

    Yes

    The operation identifier.

    • If action is set to filter, instances are queried by tag filtering criteria.
    • If action is set to count, only the total number of records is returned.

    matches

    Array of objects

    No

    The search field.

    • If the value is left blank, the query is not based on the instance name or instance ID.
    • If the value is not empty, see Table 4.

    tags

    Array of objects

    No

    The included tags. Each tag contains a maximum of 20 keys. For more information, see Table 3.

    Table 3 tags field data structure description

    Name

    Type

    Mandatory

    Description

    key

    String

    Yes

    The tag key.

    • The key cannot be empty and contains 1 to 128 single-byte characters.
    • The key can contain UTF-8 letters (including Chinese characters), digits, spaces, and the following characters: _.:/=+-@
    • Do not enter labels starting with _sys_, which are system labels.
    NOTE:

    The character set of this parameter is not verified in the search process.

    values

    Array of strings

    Yes

    Lists the tag values.

    • The value can contain UTF-8 letters (including Chinese characters), digits, spaces, and the following characters: _.:/=+-@
    • The value can be empty or null and contains 0 to 255 single-byte characters.

    If the values are null, it indicates querying any value. The values are in OR relationship.

    Table 4 matches field description

    Name

    Type

    Mandatory

    Description

    key

    String

    Yes

    The query criteria. The value can be instance_name or instance_id, indicating that the query is based on the instance name or instance ID.

    value

    String

    Yes

    The name or ID of the DB instance to be matched. You can call the API for querying DB instances to obtain the DB instance name or ID. If you do not have an instance, you can call the API used for creating an instance.

Example Request

  • Querying 1 to 100 specified DB instances by tag
    {
      "offset": "100",
      "limit": "100",
      "action": "filter",
      "matches": [
        {
          "key": "instance_name",
          "value": "test-single"
        }
      ],
      "tags": [
        {
          "key": "key1",
          "values": [
            "value1",
            "value2"
          ]
        }
      ]
    }
  • Querying the total number of resources by instance name or ID
    {
      "action": "count",
      "tags": [
        {
          "key": "key1",
          "values": [
            "value1",
            "value2"
          ]
        },
        {
          "key": "key2",
          "values": [
            "value1",
            "value2"
          ]
        }
      ],
      "matches": [
        {
          "key": "instance_name",
          "value": "test-single"
        },
         {
          "key": "instance_id",
          "value": "958693039f284d6ebfb177375711072ein02"
        }
      ]
    }

Responses

  • Parameter description
    Table 5 Parameter description

    Name

    Type

    Description

    instances

    Array of objects

    The instance list. For details, see Table 6.

    total_count

    Integer

    The total number of queried records.

    Table 6 instance field data structure description

    Name

    Type

    Description

    instance_id

    String

    The instance ID, which can be obtained by calling the API for querying instances. If you do not have an instance, you can call the API used for creating an instance.

    instance_name

    String

    The DB instance name.

    tags

    Array of objects

    The tag list. If there is no tag in the list, tags is taken as an empty array. For more information, see Table 7.

    Table 7 tags field data structure description

    Name

    Type

    Description

    key

    String

    The tag key.

    • The key cannot be empty and contains 1 to 128 single-byte characters.
    • The key can contain UTF-8 letters (including Chinese characters), digits, spaces, and the following characters: _.:/=+-@
    • Do not enter labels starting with _sys_, which are system labels.

    Character set: 0-9, A-Z, a-z, "_", and "-".

    value

    String

    The tag value.

    • The value can contain UTF-8 letters (including Chinese characters), digits, spaces, and the following characters: _.:/=+-@
    • The value can be empty or null and contains 0 to 255 single-byte characters.

    Character set: 0-9, A-Z, a-z, "_", "." and "-".

  • Response example

    Return specified DB instances by tag.

    {
      "instances": [
        {
          "instance_id": "2acbf2223caf3bac3c33c6153423c3ccin02",
          "instance_name": "test-single",
          "tags": [
            {
              "key": "key1",
              "value": "value1"
            },
            {
              "key": "key2",
              "value": "value1"
            }
          ]
        }
      ]
    }

    Number of returned records.

    {
      "total_count": 4
    }

SDK

Click Document Database Service DDS SDK to download the SDK or view the SDK document. To learn how to install and authenticate an SDK, read the Usage section.

Status Code

For more information, see Status Code.

Error Code

For more information, see Error Code.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback