全部產品
Search
文件中心

Alibaba Cloud CLI:擷取協助資訊

更新時間:Jul 31, 2025

阿里雲CLI整合了產品和API資訊,輸入--help選項可擷取詳細的命令協助資訊。

擷取支援產品列表及可用命令列選項

aliyun命令後使用--help選項,擷取通用命令列選項及支援產品列表。

  1. 執行以下命令。

    aliyun --help
  2. 預期返回如下資訊(部分截取)。

    shell@Alicloud:~$ aliyun --help
    阿里雲CLI命令列工具 3.0.276
    
    Usage:
      aliyun <product> <operation> [--parameter1 value1 --parameter2 value2 ...]
    
    Flags:
      --mode                    使用 `--mode {AK|StsToken|RamRoleArn|EcsRamRole|RsaKeyPair|RamRoleArnWithRoleName}` 指定認證方式
      --profile,-p              使用 `--profile <profileName>` 指定操作的配置集
      ...
      --help                    列印協助資訊
    
    Sample:
      aliyun ecs DescribeRegions
    
    Products:
      actiontrail                  Action Trail
      adb                          雲原生資料倉儲AnalyticDB MySQL版
      adcp                         分布式雲容器平台
      ...

擷取產品可用OpenAPI列表

在產品code後使用--help選項,可以擷取產品可用OpenAPI列表。在列表中,RPC風格的OpenAPI會顯示介面的功能描述,而ROA風格的OpenAPI則顯示對應的訪問路徑。

說明

阿里雲CLI會在介面描述前顯示不同的標識,以說明介面的狀態或特性,協助您快速識別介面的使用限制和目前狀態:

  • 匿名介面:在描述資訊前會顯示[Anonymous]標識,表示該介面無需身分識別驗證即可調用。如需以匿名方式調用該介面,請參見泛化調用

  • 棄用介面:在描述資訊前會顯示[Deprecated]標識,表示該介面已不推薦使用。建議您儘快切換至更新的替代介面。

RPC風格

  1. 執行如下命令,以擷取Elastic Compute Service (ECS)產品可用OpenAPI列表為例。

    aliyun ecs --help
  2. 預期返回如下資訊。

    shell@Alicloud:~$ aliyun ecs --help
    阿里雲CLI命令列工具 3.0.276
    
    Usage:
      aliyun ecs <ApiName> --parameter1 value1 --parameter2 value2 ...
    
    Product: Ecs (Elastic Compute Service)
    Version: 2014-05-26 
    
    Available Api List: 
      AcceptInquiredSystemEvent                          調用AcceptInquiredSystemEvent接受並授權執行系統事件操作。對問詢中(Inquiring)狀態的系統事件,接受系統事件的預設操作,授權系統執行預設操作。
      ActivateRouterInterface                            [Deprecated]啟用處於Inactive狀態的路由器介面。
      AddBandwidthPackageIps                             [Deprecated]
      AddTags                                            添加或者覆蓋一個或者多個標籤到Elastic Compute Service的各項資源上。您可以添加標籤到執行個體、磁碟、快照、鏡像、安全性群組等,便於管理資源。
      ...

ROA風格

  1. 執行如下命令,以擷取Container Service for Kubernetes (ACK)產品可用OpenAPI列表為例。

    aliyun cs --help
  2. 預期返回如下資訊。

    shell@Alicloud:~$ aliyun cs --help
    阿里雲CLI命令列工具 3.0.276
    
    Usage 1:
      aliyun cs [GET|PUT|POST|DELETE] <PathPattern> --body "..." 
    
    Usage 2 (For API with NO PARAMS in PathPattern only.):
      aliyun cs <ApiName> --parameter1 value1 --parameter2 value2 ... --body "..."
    
    Product: CS (Container ServiceKubernetes版)
    Version: 2015-12-15 
    
    Available Api List: 
      AttachInstances                         : POST /clusters/[ClusterId]/attach
      AttachInstancesToNodePool               : POST /clusters/[ClusterId]/nodepools/[NodepoolId]/attach
      CancelClusterUpgrade                    : POST /api/v2/clusters/[ClusterId]/upgrade/cancel
      CancelComponentUpgrade                  : POST /clusters/[clusterId]/components/[componentId]/cancel
      ...

擷取OpenAPI參數詳情

在介面名稱後使用--help選項,擷取OpenAPI可用參數的詳細資料,包括參數名稱、參數類型等。ROA風格OpenAPI會額外顯示請求方式及訪問路徑。

RPC風格

  1. 執行如下命令,以擷取Elastic Compute ServiceDescribeRegions介面的參數資訊為例。

    aliyun ecs DescribeRegions --help
  2. 預期返回如下資訊。

    shell@Alicloud:~$ aliyun ecs DescribeRegions --help
    阿里雲CLI命令列工具 3.0.276
    
    Product: Ecs (Elastic Compute Service)
    
    Parameters:
      --AcceptLanguage String  Optional
    
      根據漢語、英語和日語篩選返回結果。更多詳情,請參見[RFC7231](https://tools.ietf.org/html/rfc7231)。取值範圍:  
               
      - zh-CN:中文。
      - en-US:英文。
      - ja:日文。
      
      預設值為zh-CN。
    
      --InstanceChargeType String  Optional
    
      執行個體的計費方式,更多詳情,請參見[計費概述](~~25398~~)。取值範圍:
      
      - PrePaid:訂用帳戶。此時,您必須確認自己的帳號支援餘額支付或者信用支付,否則將報錯InvalidPayMethod。
      - PostPaid:隨用隨付。
      
      預設值為PostPaid。
    
      --ResourceType String  Optional
    
      資源類型。取值範圍:
      -  instance:ECS執行個體
      -  disk:磁碟
      -  reservedinstance:預留執行個體券
      -  scu:儲存容量單位包
      
      預設值:instance

ROA風格

  1. 執行如下命令,以擷取Container Service for KubernetesAttachInstances介面的參數資訊為例。

    aliyun cs AttachInstances --help
  2. 預期返回如下資訊。

    shell@Alicloud:~$ aliyun cs AttachInstances --help
    阿里雲CLI命令列工具 3.0.276
    
    Product:     CS (Container ServiceKubernetes版)
    Method:      POST
    PathPattern: /clusters/[ClusterId]/attach
    
    Parameters:
      --ClusterId String  Required
    
      叢集ID。
    
      --body Struct  Optional
    
      請求體參數。