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
On this page

Specifying Output Format

Updated on 2023-03-13 GMT+08:00

Use the --cli-query option in a command to pass a JMESPath expression so that you can extract key information from the return result. Use --cli-output to specify the output format of the response data and use --cli-output-num to specify whether to print the row numbers during table output.

Output Order

The sequence of parameters in the output result varies according to the JMESPath expression specified by --cli-query. The output result queried by some expressions does not contain the attribute names (parameter keys) of the output data. If you use these expressions, understand the sequence of the output data to facilitate data processing. The following table describes the output sequence of different types of JMESPath expressions.

Table 1 Data output sequence of different JMESPath expressions

JMESPath Expression Type

Example JMESPath Expression

Attribute Names Contained in JSON or Table Output

Attribute Names Contained in TSV Output

Data Output Sequence

Example Output

Object-level expression

--cli-query="items[0]"

Yes

No

In alphabetical order of the attribute names of the object

Example 1

Attribute-level expression without changing the attribute names

--cli-query="items[0].items[0].[spec.flavor,metadata.uid]"

No

No

In the attribute name order specified in the JMESPath expression

Example 2

Attribute-level expression with the attribute names changed

--cli-query="items[0].{Flavor:spec.flavor,ClusterID:metadata.uid}"

Yes

No

In alphabetical order of the new attribute names

Example 3

The following examples show the sequence of data output in JSON format through different JMESPath expressions:

  • Example 1
    When an object is specified, KooCLI outputs the attribute values in alphabetical order of the attribute names of the object. In this example, the object items[0] is specified. The attributes of the object are sorted in alphabetical order as follows: apiVersion, kind, metadata, spec, status. The output result is as follows:
    hcloud CCE ListClusters --cli-region="ap-southeast-1" --type="VirtualMachine" --project_id="0dd8cb****************19b5a84546" --cli-query="items[0]"
    {
      "apiVersion": "v3",
      "kind": "Cluster",
      "metadata": {
        "creationTimestamp": "2022-05-13 08:51:58.252509 +0000 UTC",
        "labels": {
          "FeatureGates": "elbv3,"
        },
        "name": "github-*****-****",
        "uid": "f288****-****-****-****-****ac101534",
        "updateTimestamp": "2022-05-13 09:10:06.395875 +0000 UTC"
      },
      "spec": {
        "authentication": {
          "authenticatingProxy": {},
          "mode": "rbac"
        },
        "az": "multi_az",
        "billingMode": 0,
        "category": "CCE",
        "containerNetwork": {
          "cidr": "10.*.*.*/**",
          "mode": "vpc-router"
        },
        "eniNetwork": {},
        "extendParam": {
          "alpha.cce/fixPoolMask": "25",
          "kubernetes.io/cpuManagerPolicy": "",
          "upgradefrom": ""
        },
        "flavor": "cce.s2.small",
        "hostNetwork": {
          "SecurityGroup": "653e****-****-****-****-****6a23eb7e",
          "subnet": "d5df****-****-****-****-****4955c724",
          "vpc": "c865****-****-****-****-****efe7e8d8"
        },
        "kubeProxyMode": "iptables",
        "kubernetesSvcIpRange": "10.***.*.*/**",
        "masters": [
          {
            "availabilityZone": "ap-southeast-1b"
          },
          {
            "availabilityZone": "ap-southeast-1a"
          }
        ],
        "supportIstio": true,
        "type": "VirtualMachine",
        "version": "v1.19.10-r0"
      },
      "status": {
        "endpoints": [
          {
            "type": "Internal",
            "url": "https://192.***.*.***:5443"
          },
          {
            "type": "External",
            "url": "https://121.**.**.***:5443"
          }
        ],
        "phase": "Available"
      }
    }
  • Example 2

    When specific attributes of an object are specified without changing the attribute names, KooCLI outputs the attribute values in the order that the attribute names are specified. In this example, the expression items[0].[spec.flavor,metadata.uid] specifies the child attribute flavor of spec and uid of metadata under the object items[0]. In the output result, the value of spec.flavor is displayed prior to that of metadata.uid.

    hcloud CCE ListClusters --cli-region="ap-southeast-1" --type="VirtualMachine" --project_id="0dd8cb****************19b5a84546" --cli-query="items[0].[spec.flavor,metadata.uid]"
    [
      "cce.s2.small",
      "f288****-****-****-****-****ac101534"
    ]
  • Example 3

    When specific attributes of an object are specified with the attribute names changed, KooCLI outputs the attribute values in alphabetical order of the new attribute names. In this example, the child attributes of two attributes under the object items[0] are specified. The expression items[0].{Flavor:spec.flavor,ClusterID:metadata.uid} renames the flavor attribute of spec Flavor and renames the uid attribute of metadata ClusterID. The new attributes are sorted in alphabetical order as follows: ClusterID, Flavor. Therefore, the output result is as follows:

    hcloud CCE ListClusters --cli-region="ap-southeast-1" --type="VirtualMachine" --project_id="0dd8cb****************19b5a84546" --cli-query="items[0].{Flavor:spec.flavor,ClusterID:metadata.uid}"
    {
      "ClusterID": "f288****-****-****-****-****ac101534",
      "Flavor": "cce.s2.small"
    }

Output Format

Use --cli-output to specify the output format. The value can be json, table, or tsv.

  • When the value of --cli-output is json:
    The result is output in JSON format as follows:
    hcloud configure list --cli-output=json --cli-query="profiles[].{Name:name,Mode:mode,Ak:accessKeyId,SK:secretAccessKey}"
    [
      {
        "Ak": "8NV****IOV",
        "Mode": "AKSK",
        "Name": "test",
        "SK": "****"
      },
      {
        "Ak": "H9N****MXW",
        "Mode": "AKSK",
        "Name": "default",
        "SK": "****"
      }
    ]
  • When the value of --cli-output is table:

    The result is output in a table as follows:

    In the meantime, you can use --cli-output-num to specify whether to print the row numbers.

  • When the value of --cli-output is tsv:

    The result is output in TSV format as follows:

    In TSV format output, data values are separated by tab characters and line breaks, and no extra symbols are included. You can use the output result for other commands. The TSV output result does not contain table headers. To prevent confusion when using the data for other commands, you need to understand the data output sequence of different types of JMESPath expressions. For details, see Output Order.

    If multiple attributes are specified but not renamed in a JMESPath expression for TSV format output, attributes enclosed in square brackets ([]) will be displayed in new lines. The following is an example:

    In this example, the attributes name, mode, accessKeyId, and secretAccessKey are specified. Attribute name is output in a new line. The attributes are output in the order that they appear in the command. The first line displays the values of mode, accessKeyId, and secretAccessKey, and the second line displays the value of name.

NOTE:

For details about other precautions for using --cli-query, --cli-output, and --cli-output-num, see FAQs.

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