Alibaba Cloud CLI is pre-installed in the Cloud Shell. Alibaba Cloud CLI is a management tool based on the Alibaba Cloud OpenAPI. You can manage your cloud resources by using Alibaba Cloud CLI.
The Alibaba Cloud product APIs are divided into two types, RPC API and RESTful API. Most products use RPC style. The method of calling an API differs from different API types.
You can determine the API type by the following characteristics:
If an API requires the
Actionparameter, then the API is the RPC type. If an API requires the
PathPatternAPI, then the API is the RESTful type.
In general, all APIs in a product are of the same type.
Each API only supports one calling method. An error
ApiNotFoundis returned if a wrong method is used.
Start Cloud Shell
To start Cloud Shell, use one of the following methods:
Start Cloud Shell in the Alibaba Cloud Management Console.
In the Alibaba Cloud Management Console, click the Cloud Shell icon in the top navigation bar.
Start Cloud Shell as a stand-alone application
Enter https://shell.aliyun.com in the address bar of a browser.
You can open up to five Cloud Shell windows at the same time.
When you start Cloud Shell, take note of the following items.
The first time you use Cloud Shell, a virtual machine is automatically created. This operation requires up to 40 seconds to complete.
Call RPC APIs in Cloud Shell
Use the following command to call an RPC API:
aliyun <ProductCode> <ActionName> [--parameter1 value1 --paramter2 value2]
ProductCode: The code of the product to call. For example, the product code of ECS is
ecsand the product code of SLB is
slb. Run the
aliyun --helpcommand to obtain product codes. For more information, see Codes of Alibaba Cloud services.
ActionName: The API to call. For example, call the
DescribeInstanceAttributeAPI to view the detailed information of an ECS instance.
parameter: The parameters of the API. For more information about each parameter, see the API documentation of each product.
Run the following command to view the detailed information of an ECS instance.
Change the ID of the ECS instance that you want to view before run the command.
aliyun ecs DescribeInstanceAttribute --InstanceId i-bp198exxxxxx | jq
Call RESTful APIs in the Cloud Shell
Some Alibaba Cloud products, such as Container Service, provide RESTful APIs. The calling method of RESTful APIs is different from that of RPC APIs. The request structure is as follows when calling RESTful APIs in the Cloud Shell:
aliyun <ProductCode> GET /<Resource>
aliyun cs GET /clusters
aliyun <ProductCode> POST /<Resource> --body "$(cat input.json)"
aliyun cs POST /clusters//attach --header "Content-Type=application/json" --body "$(cat attach.json)"
aliyun <ProductCode> DELETE /<Resource>
aliyun cs DELETE /clusters/<cluster-id>