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 2022-01-25 GMT+08:00

Function

Query DNS resources by tag.

Resources are sorted by creation time in descending order.

URI

POST /v2/{project_id}/{resource_type}/resource_instances/action

For details, see Table 1.
Table 1 Parameters in the URI

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. You can obtain it in Obtaining a Project ID.

resource_type

Yes

String

Resource type, which can be DNS-public_zone, DNS-private_zone, DNS-public_recordset, DNS-private_recordset, or DNS-ptr_record

Request

  • Parameter description
    Table 2 Parameters in the request

    Parameter

    Mandatory

    Type

    Description

    tags

    No

    Array of tags objects

    Includes specified tags. For details, see Table 3.

    The structure body is mandatory. A maximum of 10 tag keys are allowed in each query operation. The tag key cannot be left blank or set to the empty string. One tag key can have up to 10 tag values. Each tag key must be unique, and the tag values of one key must also be unique.

    tags_any

    No

    Array of tags objects

    Includes any of the specified tags. For details, see Table 3.

    The structure body is mandatory. A maximum of 10 tag keys are allowed in each query operation. The tag key cannot be left blank or set to the empty string. One tag key can have up to 10 tag values. Each tag key must be unique, and the tag values of one key must also be unique.

    not_tags

    No

    Array of tags objects

    Excludes specified tags. For details, see Table 3.

    The structure body is mandatory. A maximum of 10 tag keys are allowed in each query operation. The tag key cannot be left blank or set to the empty string. One tag key can have up to 10 tag values. Each tag key must be unique, and the tag values of one key must also be unique.

    not_tags_any

    No

    Array of tags objects

    Excludes any of the specified tags. For details, see Table 3.

    The structure body is mandatory. A maximum of 10 tag keys are allowed in each query operation. The tag key cannot be left blank or set to the empty string. One tag key can have up to 10 tag values. Each tag key must be unique, and the tag values of one key must also be unique.

    limit

    No

    Integer

    Number of resources on each page

    The value range is 1–1000.

    • If action is set to filter, the default value is 1000.
    • If action is set to count, this parameter does not take effect.

    offset

    No

    Integer

    Start offset of pagination query. The query will start from the next resource of the offset value.

    The value ranges from 0 to 2147483647.

    The default value is 0.

    • You do not need to specify this parameter when querying resources on the first page.
    • When you query resources on subsequent pages, set the value of offset to the location returned in the response body for the previous query.
    • If action is set to filter, this parameter takes effect. Its value can be 0 (default) or a positive integer.
    • If action is set to count, this parameter does not take effect.

    action

    Yes

    String

    Operation to be performed

    The value can be:

    • filter: queries resources in pages by filter condition.
    • count: queries the total number of resources.

    matches

    No

    Array of matches objects

    Field to be matched. For details, see Table 4.

    This parameter specifies the key-value pair to be matched in the query.

    If value is left blank, exact matching will work. Otherwise, fuzzy matching will work.

    Table 3 Parameters in the tags field

    Parameter

    Mandatory

    Type

    Description

    key

    No

    String

    Tag key. A key contains 127 Unicode characters and cannot be blank. (This parameter is not verified in the search process.)

    values

    No

    Array of strings

    Values of the tag.

    A value contains a maximum of 255 Unicode characters.

    The asterisk (*) is a reserved character.

    If the value starts with an asterisk (*), fuzzy matching will work for the string following the asterisk.

    If this parameter is not specified, any value is matched. The values are in OR relationship.

    Table 4 Parameters in the matches field

    Parameter

    Mandatory

    Type

    Description

    key

    Yes

    String

    Key to be matched. Currently, it can only be resource_name.

    value

    No

    String

    Value to be matched. It contains a maximum of 255 Unicode characters and cannot contain underscores (_) and percent sign (%).

  • Example request
    Query DNS resources by tag.
    POST https://{DNS_Endpoint}/v2/{project_id}/DNS-private_zone/resource_instances/action
    The following is a request example when action is set to filter:
    {
        "offset": "100", 
        "limit": "100", 
        "action": "filter", 
        "matches": [
            {
                "key": "resource_name", 
                "value": "resource1"
            }
        ], 
        "not_tags": [
            {
                "key": "key1", 
                "values": [
                    "*value1", 
                    "value2"
                ]
            }
        ], 
        "tags": [
            {
                "key": "key1", 
                "values": [
                    "*value1", 
                    "value2"
                ]
            }
        ], 
        "tags_any": [
            {
                "key": "key1", 
                "values": [
                    "value1", 
                    "value2"
                ]
            }
        ], 
        "not_tags_any": [
            {
                "key": "key1", 
                "values": [
                    "value1", 
                    "value2"
                ]
            }
        ]
    }
    The following is a request example when action is set to count:
    {
        "action": "count", 
        "not_tags": [
            {
                "key": "key1", 
                "values": [
                    "value1", 
                    "*value2"
                ]
            }
        ], 
        "tags": [
            {
                "key": "key1", 
                "values": [
                    "value1", 
                    "value2"
                ]
            }, 
            {
                "key": "key2", 
                "values": [
                    "value1", 
                    "value2"
                ]
            }
        ], 
        "tags_any": [
            {
                "key": "key1", 
                "values": [
                    "value1", 
                    "value2"
                ]
            }
        ], 
        "not_tags_any": [
            {
                "key": "key1", 
                "values": [
                    "value1", 
                    "value2"
                ]
            }
        ], 
        "matches": [
            {
                "key": "resource_name", 
                "value": "resource1"
            }
        ]
    }

Response

  • Parameter description
    Table 5 Parameters in the response

    Parameter

    Type

    Description

    resources

    Array of resource objects

    Resource list For details, see Table 6.

    total_count

    Integer

    Number of resources that meet the filter criteria. The number is irrelevant to limit or offset.

    Table 6 Parameters in the resources field

    Parameter

    Type

    Description

    resource_id

    String

    Resource ID

    resource_detail

    Object

    Resource details. This field is reserved for subsequent extension, and its value defaults to an empty string.

    tags

    Array of tag objects

    List of queried tags. If no tag is matched, an empty array is returned. For details, see Table 2.

    resource_name

    String

    Resource name. If no resource name is matched, the value is left blank.

  • Example response
    The following is a request example when action is set to filter:
    {
        "resources": [
            {
                "resource_detail": null, 
                "resource_id": "cdfs_cefs_wesas_12_dsad", 
                "resource_name": "resouece1", 
                "tags": [
                    {
                        "key": "key1", 
                        "value": "value1"
                    }, 
                    {
                        "key": "key2", 
                        "value": "value1"
                    }
                ]
            }
        ], 
        "total_count": 1000
    }
    The following is a request example when action is set to count:
    {
        "total_count": 1000
    }

Returned Value

If a 2xx status code is returned, for example, 200, 202, or 204, the request is successful.

For details, see Status 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