Esta página ainda não está disponível no idioma selecionado. Estamos trabalhando para adicionar mais opções de idiomas. Agradecemos sua compreensão.

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

Querying Images by Tag

Updated on 2024-03-01 GMT+08:00

Function

This API is used to filter or count images using tags or other conditions.

Constraints

To be compatible with remaining tags, the system will not verify the character set of the tag keys and values in the query condition when parameters tags not_tags, tags_any, and not_tags_any are used.

URI

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

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

Parameter

Mandatory

Type

Description

project_id

Yes

String

Specifies the project ID.

Request

  • Request parameters

    Parameter

    Mandatory

    Type

    Description

    action

    Yes

    String

    Identifies the operation. This parameter is case sensitive and its value can be filter or count.

    • The value filter indicates pagination query.
    • The value count indicates that the total number of query results meeting the search criteria will be returned.

    tags

    No

    Array of objects

    Includes all specified tags. A maximum of 10 tag keys are allowed for each query operation. Each tag key can contain a maximum of 10 tag values. Both tag keys and values must be unique. The tag keys cannot be left blank.

    For details, see Table 2.

    tags_any

    No

    Array of objects

    Includes any of specified tags. A maximum of 10 tag keys are allowed for each query operation. Each tag key can contain a maximum of 10 tag values. Both tag keys and values must be unique. The tag keys cannot be left blank and set to an empty string.

    For details, see Table 3.

    not_tags

    No

    Array of objects

    Excludes all specified tags. A maximum of 10 tag keys are allowed for each query operation. Each tag key can contain a maximum of 10 tag values. Both tag keys and values must be unique. The tag keys cannot be left blank.

    For details, see Table 4.

    not_tags_any

    No

    Array of objects

    Excludes any of specified tags. A maximum of 10 tag keys are allowed for each query operation. Each tag key can contain a maximum of 10 tag values. Both tag keys and values must be unique. The tag keys cannot be left blank.

    For details, see Table 5.

    without_any_tag

    No

    Boolean

    If this parameter is set to true, all resources without tags are queried. In this case, the tag, not_tags, tags_any, and not_tags_any fields are ignored.

    limit

    No

    String

    Specifies the maximum number of query records. This parameter is invalid when action is set to count. If action is set to filter, the parameter limit takes effect and its default value is 10. The value of limit ranges from 1 to 1000.

    offset

    No

    String

    Specifies the index position. The query starts from the next image indexed by this parameter. This parameter is not required when data on the first page is queried, and it is invalid when action is set to count. If action is set to filter, the default value of offset is 0. The value of offset cannot be a negative number.

    matches

    No

    Array of objects

    Specifies the search criteria. The tag key is the field to match, for example, resource_name or resource_id. value indicates the matched value. Keys in this list must be unique. The parameter cannot be left blank and may not be transferred.

    For details, see Table 6.

    Table 2 Data structure description of the tags field

    Parameter

    Mandatory

    Type

    Description

    key

    Yes

    String

    Specifies the tag key. The tag key contains a maximum of 127 Unicode characters and cannot be left blank.

    values

    Yes

    Array of strings

    Lists the tag values. Each value can contain a maximum of 255 Unicode characters. If this parameter is left blank, any value is matched. If multiple values are listed, images that have any of the values will be returned.

    Table 3 Data structure description of the tags_any field

    Parameter

    Mandatory

    Type

    Description

    key

    Yes

    String

    Specifies the tag key. The tag key contains a maximum of 127 Unicode characters and cannot be left blank.

    values

    Yes

    Array of strings

    Lists the tag values. Each value can contain a maximum of 255 Unicode characters. If this parameter is left blank, any value is matched. If multiple values are listed, images that have any of the values will be returned.

    Table 4 Data structure description of the not_tags field

    Parameter

    Mandatory

    Type

    Description

    key

    Yes

    String

    Specifies the tag key. The tag key contains a maximum of 127 Unicode characters and cannot be left blank.

    values

    Yes

    Array of strings

    Lists the tag values. Each value can contain a maximum of 255 Unicode characters. If this parameter is left blank, any value is matched. If multiple values are listed, images that have any of the values will be returned.

    Table 5 Data structure description of the not_tags_any field

    Parameter

    Mandatory

    Type

    Description

    key

    Yes

    String

    Specifies the tag key. The tag key contains a maximum of 127 Unicode characters and cannot be left blank.

    values

    Yes

    Array of strings

    Lists the tag values. Each value can contain a maximum of 255 Unicode characters. If this parameter is left blank, any value is matched. When multiple values are specified and the key requirements are met, images that have any of the specified values are queried.

    Table 6 Data structure description of the matches field

    Parameter

    Mandatory

    Type

    Description

    key

    Yes

    String

    Specifies the tag key, that is to say, the field name for the query operation. Valid values include resource_name and resource_id.

    If the field name is resource_name and the value is an empty string, exact query is performed. Otherwise, fuzzy query is performed based on the image name. If the field name is resource_id, exact query is performed based on the image ID.

    value

    Yes

    String

    Specifies the tag value. It cannot be left blank. Each value can contain a maximum of 255 Unicode characters.

Example Request

  • Counting the total number of images that meet the conditions specified by tags
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    POST https://{Endpoint}/v2/fd73a4a14a4a4dfb9771a8475e5198ea/images/resource_instances/action
    {
       "action": "count",
       "matches": [{
          "key": "resource_name",
          "value": "test100"
       }],
       "tags": [
       {
          "key": "key3",
          "values": ["valueXX"]
       }],
       "tags_any": [
       {
          "key": "key0",
          "values": ["valueXX"]
       }],
          "not_tags": [
       {
          "key": "key9",
          "values": ["value9"]
       }],
       "not_tags_any": [{
          "key": "key7",
          "values": ["value7"]
       }]
    }
    
  • Filtering images that meet the conditions specified by tags
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    POST https://{Endpoint}/v2/fd73a4a14a4a4dfb9771a8475e5198ea/images/resource_instances/action
    {
       "action": "filter",
       "limit": "1",
       "offset": "0",
       "matches": [{
          "key": "resource_name",
          "value": "test100"
       }],
       "tags": [
       {
          "key": "key3",
          "values": ["valueXX"]
       }],
       "tags_any": [
       {
          "key": "key0",
          "values": ["valueXX"]
       }],
       "not_tags": [
       {
          "key": "key9",
          "values": ["value9"]
       }],
       "not_tags_any": [{
          "key": "key7",
          "values": ["value7"]
       }]
    }
    

Response

  • Response parameters

    Parameter

    Type

    Description

    resources

    Array of resource objects

    Lists the images.

    total_count

    Integer

    Specifies the total number of query records.

    Table 7 Data structure description of the resource field

    Parameter

    Type

    Description

    resource_id

    String

    Specifies the image ID.

    resource_detail

    ResourceDetail object

    Provides image details.

    tags

    Array of Tags objects

    Lists the image tags.

    resource_name

    String

    Specifies the image name.

    Table 8 ResourceDetail object

    Parameter

    Type

    Mandatory

    Description

    status

    string

    Yes

    Specifies the image status.

    Table 9 Data structure description of the resource_tag field

    Parameter

    Type

    Description

    key

    String

    Specifies the key of the tag.

    value

    String

    Specifies the value of the tag.

  • Example response
    • Example response when action is set to count
      STATUS CODE 200
      1
      2
      3
      {
         "total_count": 36
      }
      
    • Example response when action is set to filter
      STATUS CODE 200
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      {
         "total_count": 36,
         "resources": [{
            "resource_name": "test10002",
            "resource_detail": {"status": "active"},
            "tags": [{
               "value": "value4",
               "key": "key4"
            },
            {
               "value": "valueXX",
               "key": "key3"
            },
            {
               "value": "value2",
               "key": "key2"
            },
            {
               "value": "value5",
               "key": "key5"
            },
            {
               "value": "value8",
               "key": "key8"
            },
            {
               "value": "valueXX",
               "key": "key6"
            },
            {
               "value": "valueXX",
               "key": "key0"
            },
            {
               "value": "value1",
               "key": "key1"
            },
            {
               "value": "value7",
               "key": "key7"
            },
            {
               "value": "valueXX",
               "key": "key9"
            }],
            "resource_id": "8693187d-1590-4f9f-ae34-eb9e3037cf68"
         }]
      }
      

Returned Values

  • Normal

    200

  • Abnormal

    Returned Value

    Description

    400 Bad Request

    Request error.

    401 Unauthorized

    Authentication failed.

    403 Forbidden

    You do not have the rights to perform the operation.

    404 Not Found

    The requested resource was not found.

    500 Internal Server Error

    Internal service error.

    503 Service Unavailable

    The service is unavailable.

Usamos cookies para aprimorar nosso site e sua experiência. Ao continuar a navegar em nosso site, você aceita nossa política de cookies. Saiba mais

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback