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 Resources

Updated on 2024-08-09 GMT+08:00

Function

This API is used to query resources.

URI

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

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Specifies the project ID.

resource_type

Yes

String

Specifies the resource type.

cph-server: cloud phone server

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Specifies the user token. It can be obtained by calling an Identity and Access Management (IAM) API. The value of X-Subject-Token in the response header is the user token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

action

Yes

String

Specifies the operation to be performed. The operation can be filter or count. filter indicates pagination query. count indicates that the total number of query results meeting the search criteria will be returned.

offset

No

String

Specifies where the query starts. The query starts from the next data record indexed by this parameter. You do not need to specify this parameter when querying 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.If you set action to count, this parameter is not required.If you set action to filter, offset is 0 by default. The offset value must be a positive number.

limit

No

String

Specifies the maximum number of records to be queried.

If you set action to count, this parameter is not required.

If you set action to filter, this parameter takes effect. The value ranges from 1 to 1000 (default).

without_any_tag

No

Boolean

Specifies any tag that is not contained. If this parameter is set to true, all resources without tags are queried.

tags

No

Array of Tags objects

A maximum of 10 tag keys are allowed in each query operation. Each tag key can have up to 10 tag values. The structure body is mandatory. The tag key cannot be left blank or be an empty string. Each tag key and values of each key must be unique. Resources identified by different keys are in AND relationship.

matches

No

Array of Match objects

Specifies the key-value pair to be matched.

The key can only be resource_name.

The value will be exactly matched.

Table 4 Tags

Parameter

Mandatory

Type

Description

key

Yes

String

Specifies the tag key.

  • A key can contain a maximum of 127 Unicode characters.

  • key must be specified.

values

Yes

Array of strings

Specifies the tag value list.

  • A maximum of 10 values are supported.

  • Values of the same tag must be unique.

  • Each tag value can contain a maximum of 255 Unicode characters.

  • If this parameter is left blank, any value can be used.

Table 5 Match

Parameter

Mandatory

Type

Description

key

Yes

String

Specifies the key.

key can only be resource_name. In such a case, value is the resource name.

value

Yes

String

Specifies the value.

key can only be resource_name. In such a case, value is the resource name.

Response Parameters

Status code: 200

Table 6 Response body parameters

Parameter

Type

Description

resources

Array of Resource objects

Lists the resources.

total_count

Integer

Total number of resources

Table 7 Resource

Parameter

Type

Description

resource_id

String

Specifies the resource ID.

resource_detail

String

Specifies resource details.

resource_name

String

Specifies the resource name.

tags

Array of Tag objects

Specifies the resource name.

Table 8 Tag

Parameter

Type

Description

key

String

Specifies the tag key.

  • A key can contain a maximum of 127 Unicode characters.

  • A key cannot be left blank, start or end with a space, nor start with sys. A key can contain letters, digits, spaces, and special characters _.:=+-@ of any language.

value

String

Specifies the list of tag values.

  • Each tag value can contain a maximum of 255 Unicode characters.

  • A tag value cannot be left blank nor start or end with a space. It can contain letters, digits, spaces, and special characters _.:=+-@.

Example Requests

  • Querying the number of resources

    Post https://{CPH Endpoint}/v1/{project_id}/{resource_type}/resource_instances/action
    
    {
      "action" : "count",
      "tags" : [ {
        "key" : "key1",
        "values" : [ "value1", "value2" ]
      }, {
        "key" : "key2",
        "values" : [ "value1", "value2" ]
      } ],
      "matches" : [ {
        "key" : "resource_name",
        "value" : "resource1"
      } ]
    }
  • Querying resources

    Post https://{CPH Endpoint}/v1/{project_id}/{resource_type}/resource_instances/action
    
    {
      "offset" : "100",
      "limit" : "100",
      "action" : "filter",
      "tags" : [ {
        "key" : "key1",
        "values" : [ "value1", "value2" ]
      }, {
        "key" : "key2",
        "values" : [ "value1", "value2" ]
      } ],
      "matches" : [ {
        "key" : "resource_name",
        "value" : "resource1"
      } ]
    }

Example Responses

Status code: 200

ok

{
  "resources" : [ {
    "resource_detail" : null,
    "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

ok

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