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 Security Groups by Tag

Function

This API is used to query security group by tag.

URI

POST /v2.0/{project_id}/security-groups/resource_instances/action

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

action

Yes

String

Operation

The value can be filter or count.

limit

No

Integer

Number of records to be queried.

Value range: 1 to 1000

This parameter is not available when action is set to count. The default value is 1000 when action is set to filter.

offset

No

Integer

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.

This parameter is not available when action is set to count. If action is set to filter, the value must be a number, and the default value is 0. The value cannot be a negative number.

matches

No

Array of Match objects

Search criteria. The tag key is the field to match, and the tag value indicates the matched value.

Currently, only resource_name is supported.

tags

No

Array of ListTag objects

Included tags. Each tag contains a maximum of 10 keys, and each key contains a maximum of 10 values. The structure body cannot be missing, and the key cannot be left blank or set to an empty string. Each tag key must be unique, and each tag value in a tag must be unique.

Table 3 Match

Parameter

Mandatory

Type

Description

key

Yes

String

Key. The tag key can only be the resource name.

value

Yes

String

Value. Each value can contain a maximum of 255 Unicode characters and cannot contain special characters, such as dollar signs ($), hyphens (-), periods (.), or slashes (/).

Maximum: 255

Table 4 ListTag

Parameter

Mandatory

Type

Description

key

Yes

String

Tag key.

The key cannot be left blank.

Minimum: 1

Maximum: 127

values

Yes

Array of strings

Tag values.

If values are null, it indicates any_value. All values of a tag key are in the OR relationship.

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

resources

Array of ListResourceResp objects

Resources

total_count

Integer

Number of resources.

Table 6 ListResourceResp

Parameter

Type

Description

resource_detail

Object

Resource details used for extension, which is left blank by default.

resource_id

String

Resource ID

resource_name

String

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

tags

Array of ResourceTag objects

A list of tags. This parameter is an empty array by default if there is no tag.

Table 7 ResourceTag

Parameter

Type

Description

key

String

Tag key.

The key must be unique for each resource.

Minimum: 0

Maximum: 36

value

String

Tag value

Minimum: 0

Maximum: 43

Status code: 400

Table 8 Response body parameters

Parameter

Type

Description

code

String

Error code returned for a request.

message

String

Error message returned for a request.

Status code: 401

Table 9 Response body parameters

Parameter

Type

Description

code

String

Error code returned for a request.

message

String

Error message returned for a request.

Status code: 403

Table 10 Response body parameters

Parameter

Type

Description

code

String

Error code returned for a request.

message

String

Error message returned for a request.

Status code: 404

Table 11 Response body parameters

Parameter

Type

Description

code

String

Error code returned for a request.

message

String

Error message returned for a request.

Status code: 409

Table 12 Response body parameters

Parameter

Type

Description

code

String

Error code returned for a request.

message

String

Error message returned for a request.

Status code: 500

Table 13 Response body parameters

Parameter

Type

Description

code

String

Error code returned for a request.

message

String

Error message returned for a request.

Example Requests

  • example-1: Request body when action is set to filter

    POST https://{Endpoint}/v2.0/{project_id}/security-groups/resource_instances/action
    
    {
      "offset" : "0",
      "limit" : "100",
      "action" : "filter",
      "matches" : [ {
        "key" : "resource_name",
        "value" : "resource1"
      } ],
      "tags" : [ {
        "key" : "key1",
        "values" : [ "*value1", "value2" ]
      } ]
    }
  • example-2: Request body when action is set to count

    POST https://{Endpoint}/v2.0/{project_id}/security-groups/resource_instances/action
    
    {
      "action" : "count",
      "tags" : [ {
        "key" : "key1",
        "values" : [ "value1", "value2" ]
      }, {
        "key" : "key2",
        "values" : [ "value1", "value2" ]
      } ],
      "matches" : [ {
        "key" : "resource_name",
        "value" : "resource1"
      } ]
    }

Example Responses

Status code: 200

If action in the request body is set to filter, the resource tag list is returned. If action in the request body is set to count, the total number of tags is returned.

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

Status Codes

Status Code

Description

200

If action in the request body is set to filter, the resource tag list is returned. If action in the request body is set to count, the total number of tags is returned.

400

The server failed to process the request.

401

Username and password are required to access the page requested.

403

You are forbidden to access the requested page.

404

The server could not find the requested page.

409

The request could not be processed due to a conflict.

500

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

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