El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

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 2025-01-27 GMT+08:00

Function

This API is used to query resources in a project by tag.

By default, resources and resource tags are in descending order of their creation time.

URI

POST /autoscaling-api/v1/{project_id}/{resource_type}/resource_instances/action

Table 1 Parameter description

Parameter

Mandatory

Type

Description

project_id

Yes

String

Specifies the project ID.

resource_type

Yes

String

Specifies the resource type. An example value is scaling_group_tag.

Request

Table 2 Request parameters

Parameter

Mandatory

Type

Description

tags

No

Array of Tag objects

Specifies filter criteria with tags included. A maximum of 10 keys can be contained. The structure body must be complete. For details, see Table 3.

tags_any

No

Array of Tag objects

Specifies filter criteria with any tag included. A maximum of 10 keys can be contained. For details, see Table 3.

not_tags

No

Array of Tag objects

Specifies filter criteria without tags included. A maximum of 10 keys can be contained. For details, see Table 3.

not_tags_any

No

Array of Tag objects

Specifies filter criteria without any tag included. A maximum of 10 keys can be contained. For details, see Table 3.

limit

No

String

Specifies the maximum number of query records. The maximum value is 1,000, and the minimum value is 1.

  • If action is set to count, this parameter is invalid.
  • If action is set to filter, the default value is 1000.

marker

No

String

Marks the paging location (index position). You are advised to use the offset parameter to set the index position.

Marks the paging location (resource ID or index location).

action

Yes

String

Specifies the operation, which can be filter or count.

  • filter: indicates that resources are filtered by tag and the resources meeting the search criteria are returned on pages.
  • count: indicates that resources are searched by tag and the number of resources meeting the search criteria is returned.

offset

No

String

Specifies the index position. The query starts from the next image indexed by this parameter. The value must be a non-negative number.

You do not need to specify this parameter when querying resources on the first page. When you query resources on subsequent pages, set offset to the location returned in the response body for the previous query.

  • If the action value is count, this parameter is invalid.
  • If the action value is filter, the default value is 0.

matches

No

Array of match objects

Specifies fuzzy search. For details, see Table 4.

Table 3 Tag field description

Parameter

Mandatory

Type

Description

key

Yes

String

Specifies the tag key. It contains a maximum of 36 Unicode characters. It cannot be left blank (This parameter is not verified in the search process.) A maximum of 10 keys are allowed and the key cannot be left blank or an empty string. Each key must be unique.

values

Yes

Array of strings

Specifies tag values. A value contains a maximum of 43 Unicode characters. A key contains a maximum of 10 values. Each value of the same key must be unique.

  • The asterisk (*) is reserved for the system. If the value starts with *, it indicates that fuzzy match is performed for the digits following *. The value cannot contain only asterisks (*).
  • If the values are null (not default), it indicates any_value (querying any value). The resources contain one or multiple values listed in values will be found and displayed.
Table 4 match field description

Parameter

Mandatory

Type

Description

key

Yes

String

Specifies the key based on which to query resources.

The parameter value can only be resource_name.

value

Yes

String

Specifies the value. The value is a fixed dictionary value. A value contains a maximum of 255 Unicode characters. If the value is an empty string or resource_id, exact match is used.

Example Request

  • This example queries the details of AS groups of a tenant using the following search criteria: including the tag (key = key1 and value = value1), excluding the tag (key = key2 and value = value2), index position 100, and a maximum number of 100 records.
    POST https: //{Endpoint}/autoscaling-api/v1/{project_id}/scaling_group_tag/resource_instances/action
    
    {
    	"offset": "100",
    	"limit": "100",
    	"action": "filter",
    	"matches": [{
    		"key": "resource_name",
    		"value": "resource1"
    	}],
    	"not_tags": [{
    		"key": "key2",
    		"values": ["value2"]
    	}],
    	"tags": [{
    		"key": "key1",
    		"values": ["value1"]
    	}]
    }
  • This example counts the number of AS groups for a tenant using the following search criteria: including the tag (key = key1 and value = value1) and excluding the tag (key = key2 and value = value2).
    POST https: //{Endpoint}/autoscaling-api/v1/{project_id}/scaling_group_tag/resource_instances/action
    
    {
    	"action": "count",
    	"not_tags": [{
    		"key": "key2",
    		"values": ["value2"]
    	}],
    	"tags": [{
    		"key": "key1",
    		"values": ["value1"]
    	}],
    	"matches": [{
    		"key": "resource_name",
    		"value": "resource1"
    	}]
    }

Response

Table 5 Response parameters

Parameter

Type

Description

resources

Array of Resource objects

Specifies tag resources. For details, see Table 6.

total_count

Integer

Specifies the total number of records. When action is set to count, only this parameter is returned. The values of resources and marker are not returned.

marker

String

Specifies the paging location identifier.

Table 6 Resource field description

Parameter

Type

Description

resource_id

String

Specifies the resource ID.

resource_detail

String

Specifies the resource details.

tags

Array of ResourceTag objects

Specifies tags. If there is no tag, the field tags is taken as an empty array by default. For details, see Table 7.

resource_name

String

Specifies the resource name. If there is no resource, this parameter is an empty string by default.

Table 7 ResourceTag field description

Parameter

Type

Description

key

String

Specifies the tag key. It contains a maximum of 36 Unicode characters.

value

String

Specifies the tag value. It contains a maximum of 43 Unicode characters.

Example Response

  • Example response when action is set to filter
    {
    	"resources": [{
    		"resource_id": "64af4b6f-ec51-4436-8004-7a8f30080c87",
    		"resource_detail": "SCALING_GROUP_TAG",
    		"tags": [{
    			"key": "key1","value": "value1"
    		}],
    		"resource_name": "as_scaling_group_1"
    	},
    	{
    		"resource_id": "7122ef51-604b-40e7-b9b2-1de4cd78dc60",
    		"resource_detail": "SCALING_GROUP_TAG",
    		"tags": [{
    			"key": "key1","value": "value1"
    		}],
    		"resource_name": "as_scaling_group_2"
    	}],
    	"marker": "2",
    	"total_count": 2
    }
  • Example response when action is set to count
    {
           "total_count": 1000
    }

Returned Values

  • Normal

    200

  • Abnormal

    Returned Value

    Description

    400 Bad Request

    The server failed to process the request.

    401 Unauthorized

    You must enter the username and password to access the requested page.

    403 Forbidden

    You are forbidden to access the requested page.

    404 Not Found

    The server could not find the requested page.

    405 Method Not Allowed

    You are not allowed to use the method specified in the request.

    406 Not Acceptable

    The response generated by the server could not be accepted by the client.

    407 Proxy Authentication Required

    You must use the proxy server for authentication to process the request.

    408 Request Timeout

    The request timed out.

    409 Conflict

    The request could not be processed due to a conflict.

    500 Internal Server Error

    Failed to complete the request because of an internal service error.

    501 Not Implemented

    Failed to complete the request because the server does not support the requested function.

    502 Bad Gateway

    Failed to complete the request because the request is invalid.

    503 Service Unavailable

    Failed to complete the request because the system is unavailable.

    504 Gateway Timeout

    A gateway timeout error occurred.

Error Codes

See Error Codes.

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback