All Products
Search
Document Center

Alibaba Cloud CLI:Command line options for API calls

Last Updated:Aug 06, 2024

This topic describes the command line options provided by Alibaba Cloud CLI for you to use when you call the API operations of Alibaba Cloud services. When you use Alibaba Cloud CLI, you can specify command line options to change the behaviors of commands or implement extended features of commands.

Syntax

You can append an option to an API command by using the following syntax:

aliyun <product> <ApiName> --option [optionParams]
  • Separate an option and its parameters with spaces. If an option has a field, specify the field and its value in the format of field=value as a parameter. For information about the format requirements for parameters of different data types, see Parameter formats.

  • Some options do not need you to specify parameters. The following table describes the details.

Available options

Option

Description

--profile or -p

You can use the --profile option and its parameter profileName to specify a configuration profile. After you specify a valid configuration profile, Alibaba Cloud CLI ignores the default identity credential and environment variable configurations and uses the configurations that you specify to run commands.

Example: Call the DescribeInstances operation of Elastic Compute Service (ECS) with the akProfile configuration profile specified.

aliyun ecs DescribeInstances --profile akProfile

--region

You can use the --region option and its parameter region to specify a region. After you specify a valid region, Alibaba Cloud CLI ignores the region in the default identity credential and environment variable configurations and uses the region that you specify to run commands.

Example: Call the DescribeInstances operation of ECS with the cn-beijing region specified.

aliyun ecs DescribeInstances --region cn-beijing

--endpoint

You can use the --endpoint option to specify an endpoint. For information about the endpoints supported by an Alibaba Cloud service, see the Endpoints topic in the Developer Reference > API Reference section in the documentation of the service.

Example: Call the DescribeMonitorGroups operation of CloudMonitor with the metrics.cn-qingdao.aliyuncs.com endpoint specified.

aliyun cms DescribeMonitorGroups --endpoint metrics.cn-qingdao.aliyuncs.com

--version

You can use the --version option to specify an API version in the format of YYYY-MM-DD. This option must be used together with the --force option. For more information, see Forcibly call an API operation.

Example: Call the DescribeMetricList operation of CloudMonitor with the 2017-03-01 API version specified.

aliyun cms QueryMetricList 
  --Project acs_ecs_dashboard 
  --Metric cpu_idle 
  --version 2017-03-01 
  --force

--header

You can use the --header option to add a request header. You can repeatedly use the option to add multiple request headers.

Example: Add the X-foo=bar request header to a command.

aliyun <product> <ApiName> --header X-foo=bar

--body

You can use the --body option to add a request body when you call a RESTful API operation. You can specify a JSON string or reference a JSON file as a variable for this option.

Example: Call the RunClusterCheck operation of Container Service for Kubernetes (ACK) with a JSON string specified as the request body.

aliyun cs POST /clusters/{cluster_id}/checks 
  --body "{\"type\":\"NodePoolUpgrade\",\"target\":\"np1f6779297c4444a3a1cdd29be8e5****\"}"

--read-timeout

You can use the --read-timeout option to specify the I/O timeout period in seconds. After you specify a valid I/O timeout period, Alibaba Cloud CLI ignores the I/O timeout period in the default identity credential configurations and uses the I/O timeout period that you specify to run commands.

Example: Specify the I/O timeout period as 20 seconds.

aliyun <product> <ApiName> --read-timeout 20

--connect-timeout

You can use the --connect-timeout option to specify the connection timeout period in seconds. After you specify a valid connection timeout period, Alibaba Cloud CLI ignores the connection timeout period in the default identity credential configurations and uses the connection timeout period that you specify to run commands.

Example: Specify the connection timeout period as 20 seconds.

aliyun <product> <ApiName> --connect-timeout 20

--retry-count

You can use the --retry-count option to specify the number of retries allowed. After you specify a valid number, Alibaba Cloud CLI ignores the relevant retry configuration in the default identity credential configurations and uses the number of retries that you specify to run commands.

Example: Specify the number of retries allowed as 5.

aliyun <product> <ApiName> --retry-count 5

--secure

You can use the --secure option to enable the HTTPS mode.

This option does not have a parameter.

--quiet,-q

You can use the --quiet option to disable the output of return results.

This option does not have a parameter.

--help

You can use the --help option to obtain the help information about a command.

This option does not have a parameter.

For more information, see Use the help command.

--output or -o

You can use the --output option to specify the fields to return in the form of a table.

For more information, see Extract parameters and tabulate output.

--pager

You can use the --pager option to specify to return aggregated results of a paging API operation.

For more information, see Aggregate the results of paging operations.

--force

You can use the --force option to specify to forcibly call API operations and use parameters that are not in the metadata list.

This option does not have a parameter.

For more information, see Forcibly call an API operation.

--waiter

You can use the --waiter option to specify to poll return results and return data when a field changes to a specific value.

For more information, see Poll the return results.

--dryrun

You can use the --dryrun option to specify to simulate a call to the server and return the simulation results without performing actual operations on cloud resources.

This option does not have a parameter.

For more information, see Simulate a call.