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 ECSs by Tag (Discarded)

Updated on 2024-04-16 GMT+08:00

Function

This API is used to filter ECSs by tag and obtain all tags and resources used by an ECS.

This API supports checking fine-grained permissions for enterprise projects. For details, see ecs:cloudServers:list.

URI

POST /v1/{project_id}/cloudservers/resource_instances/action

Table 1 describes the parameters in the URI.
Table 1 Parameter description

Parameter

Mandatory

Description

project_id

Yes

Specifies the project ID.

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

Request

Table 2 describes the request parameters.
Table 2 Request parameters

Parameter

Mandatory

Type

Description

action

Yes

String

Specifies the operation. Value filter indicates to filter ECSs by tag. The ECSs that meet the filter criteria are displayed.

limit

No

String

Limits the maximum number of queried ECSs. The value cannot be a negative number. The maximum value is 1,000.

  • If the action value is count, this parameter is invalid.
  • If the action value is filter, this parameter is mandatory. The value ranges from 0 to 1,000. If no value is specified for limit, the default value of this parameter is 1,000.

offset

No

String

Specifies the start of the record to be returned. The value must be a number that is greater than or equal to 0.

This parameter is optional when data on the first page is queried.

  • If the action value is count, this parameter is invalid.
  • If the action value is filter, this parameter is mandatory. If no value is specified for offset, the default value of this parameter is 0.

tags

No

Array of objects

Displays the ECSs with all the specified tags. For details, see Table 3.

  • The structure body must be included.
  • The tag key cannot be left blank or set to an empty string.
  • A key must be unique.
  • Values of the same key must be unique.

not_tags

No

Array of strings

Displays the ECSs with none of specified tags.

  • The structure body must be included.
  • The tag key cannot be left blank or set to an empty string.
  • Keys must be unique.
  • Values of the same key must be unique.

matches

No

Array of objects

Specifies the search field, which is used to search for ECSs.

Currently, only resource_name can be used for search. For more information, see Table 4.

Table 3 tag field description

Parameter

Mandatory

Type

Description

key

Yes

String

Specifies the tag key.

  • Contains a maximum of 127 Unicode characters.
  • Cannot be left blank.

values

Yes

Array of strings

Specifies tag values.

  • Values of the same tag must be unique.
  • Each value contains a maximum of 255 Unicode characters.
  • If this parameter is not specified, its value is any_value.
  • The values are in the OR relationship.
Table 4 match field description

Parameter

Mandatory

Type

Description

key

Yes

String

Specifies the key field to be matched.

The tag key can only be resource_name. In such a case, the tag value is the ECS name.

  • The key must be unique, and the value is used for matching.
  • This field is a fixed dictionary value.
  • This field cannot be left blank.

value

Yes

String

Specifies the tag value.

The tag key can only be resource_name. In such a case, the tag value is the ECS name.

  • Contains a maximum of 255 Unicode characters.
  • Cannot be left blank.

Response

Response parameters

Table 5 describes the response parameters.

Table 5 Response parameters

Parameter

Type

Description

resources

Array of objects

Specifies returned ECSs. For details, see Table 6.

total_count

Integer

Specifies the total number of queried ECSs.

Table 6 resource field description

Parameter

Type

Description

resource_id

String

Specifies the ECS ID.

resource_detail

String

Reserved

tags

Array of objects

Lists tags.

resource_name

String

Specifies the resource name, which is the ECS name.

Table 7 resource_tag field description

Parameter

Type

Description

key

String

Specifies the tag key.

  • Contains a maximum of 127 Unicode characters.
  • Cannot be left blank.
  • Consists of only digits, letters, hyphens (-), and underscores (_).

value

String

Specifies the tag value.

  • Contains a maximum of 255 Unicode characters.
  • Can be left blank.
  • Consists of only digits, letters, hyphens (-), and underscores (_).

Examples

  • Example request
    POST  https://{endpoint}/v1/{project_id}/cloudservers/resource_instances/action
    {
        "offset": "100", 
        "limit": "1", 
        "action": "filter", 
        "matches":[
        {
            "key": "resource_name", 
            "value": "ecs_test"
         }], 
        "tags": [
        {
            "key": "key1", 
            "values": [
                "value1", 
                "value2"
            ]
        }]
    }
  • Example response
    {
          "resources": [
             {
                "resource_detail": null, 
                "resource_id": "31760ffa-6711-406d-bc94-bce4ae925a8a", 
                "resource_name": "ecs_test", 
                "tags": [
                    {
                       "key": "key1",
                       "value": "value1"
                    }
                 ]
             }
           ], 
          "total_count": 1000
    }

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