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
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
Help Center/ MapReduce Service/ API Reference/ API V1.1/ Tag Management APIs/ Querying a List of Clusters with Specified Tags

Querying a List of Clusters with Specified Tags

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

Function

This API is used to filter clusters by tag.

By default, clusters and tags are sorted in descending order of creation time.

Constraints

None

Debugging

You can debug this API in API Explorer. Automatic authentication is supported. API Explorer can automatically generate sample SDK code and provide the sample SDK code debugging.

URI

  • Format

    POST /v1.1/{project_id}/clusters/resource_instances/action

  • Parameter description
    Table 1 URI parameter

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Explanation

    Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

    Constraints

    N/A

    Value range

    The value must consist of 1 to 64 characters. Only letters and digits are allowed.

    Default value

    N/A

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

tags

No

Array of TagWithMultiValue objects

Explanation

The returned result contains the resources corresponding to all tags in this parameter.

Constraints

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. For details about the parameters, see Table 3.

Value range

N/A

Default value

N/A

tags_any

No

Array of TagWithMultiValue objects

Explanation

The returned result contains the resources corresponding to any tag in this parameter.

Constraints

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. Keys must be unique and values of a key must be unique. For details about the parameters, see Table 3.

Value range

N/A

Default value

N/A

not_tags

No

Array of TagWithMultiValue objects

Explanation

The returned result does not contain the resources corresponding to all tags in this parameter.

Constraints

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. Keys must be unique and values of a key must be unique. For details about the parameters, see Table 3.

Value range

N/A

Default value

N/A

not_tags_any

No

Array of TagWithMultiValue objects

Explanation

The returned result does not contain the resources corresponding to any tag in this parameter.

Constraints

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. Keys must be unique and values of a key must be unique. For details about the parameters, see Table 3.

Value range

N/A

Default value

N/A

limit

No

Integer

Explanation

Number of query records.

Constraints

If you set action to count, this parameter is not required. If action is set to filter, the default value of this parameter is 1000.

Value range

1-1000

Default value

N/A

offset

No

Integer

Explanation

Index position. The query starts from the next data record indexed by this parameter. You do not need to specify this parameter when you query resources on the first page. When you query resources on subsequent pages, set this parameter to the location returned in the response body for the previous query.

Constraints

If you set action to count, this parameter is not required. If action is set to filter, the default value is 0.

Value range

≥0

Default value

N/A

action

Yes

String

Explanation

Operation ID (only filter and count is available). filter: The query is paginated. count: The total number of records is returned by search condition.

Constraints

N/A

Value range

  • filter: Perform pagination query.
  • count: Query the total number of resources.

Default value

N/A

matches

No

Array of Match objects

Explanation

Search field. key indicates the field to be matched, for example, resource_name. value indicates the matched value. This field is a fixed dictionary value. Determine whether fuzzy match is required based on different fields. For example, if key is resource_name, fuzzy search is used by default. If value is an empty string, exact match is used. For details about the parameters, see Table 4.

Constraints

N/A

Value range

N/A

Default value

N/A

Table 3 TagWithMultiValue

Parameter

Mandatory

Type

Description

key

Yes

String

Explanation

Tag key.

Constraints

N/A

Value range

A tag key can contain letters, digits, spaces, and special characters (_.:=+-@), but cannot start or end with a space or start with _sys_.

Default value

N/A

values

No

Array of strings

Explanation

Tag value.

Constraints

A tag value can contain letters, digits, spaces, and special characters (_.:=+-@), but cannot start or end with a space or start with _sys_.

Value range

N/A

Default value

N/A

Table 4 Match

Parameter

Mandatory

Type

Description

key

No

String

Explanation

Key. Currently, only resource_name is available, indicating the cluster name. Other keys will be supported later.

Constraints

N/A

Value range

The value can contain 1 to 64 characters.

Default value

N/A

value

No

String

Explanation

Value. A value can contain a maximum of 64 Unicode characters.

Constraints

N/A

Value range

The value can contain 0 to 64 characters.

Default value

N/A

Response Parameters

Table 5 Response parameters

Parameter

Type

Description

resources

Array of MRSResource objects

Explanation

Resource details. For details, see Table 6.

Constraints

N/A

Value range

N/A

Default value

N/A

total_count

Integer

Explanation

Total number of resources.

Constraints

N/A

Value range

N/A

Default value

N/A

Table 6 MRSResource

Parameter

Type

Description

resource_detail

String

Explanation

Resource details.

Constraints

N/A

Value range

N/A

Default value

N/A

resource_id

String

Explanation

Resource ID.

Constraints

N/A

Value range

N/A

Default value

N/A

resource_name

String

Explanation

Resource name.

Constraints

N/A

Value range

N/A

Default value

N/A

tags

Array of TagPlain objects

Explanation

Tag list. For details, see Table 7.

Constraints

N/A

Value range

N/A

Default value

N/A

Table 7 TagPlain

Parameter

Type

Description

key

String

Explanation

Tag key.

Constraints

N/A

Value range

A tag key can contain letters, digits, spaces, and special characters (_.:=+-@), but cannot start or end with a space or start with _sys_.

Default value

N/A

value

String

Explanation

Tag value.

Constraints

N/A

Value range

A tag value can contain letters, digits, spaces, and special characters (_.:=+-@), but cannot start or end with a space or start with _sys_.

Default value

N/A

Example Request

  • Query the cluster list when action is set to filter.
    POST https://{endpoint}/v1.1/{project_id}/{resource_type}/resource_instances/action
    
    {
      "offset" : "100",
      "limit" : "100",
      "action" : "filter",
      "matches" : [ {
        "key" : "resource_name",
        "value" : "clusterA"
      } ],
      "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" ]
      } ]
    }
  • Query the cluster list when action is set to count.
    POST https://{endpoint}/v1.1/{project_id}/{resource_type}/resource_instances/action
    
    {
      "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" : "clusterA"
      } ]
    }

Example Response

Status code: 200

The operation is successful.

{
  "resources" : [ {
    "resource_detail" : null,
    "resource_id" : "cdfs_cefs_wesas_12_dsad",
    "resource_name" : "clusterA",
    "tags" : [ {
      "key" : "key1",
      "value" : "value1"
    }, {
      "key" : "key2",
      "value" : "value1"
    } ]
  } ],
  "total_count" : "1000"
}

Status Codes

See Status Codes.

Error Codes

See Error Codes.

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