11[ English] ( ./README.md )  | 简体中文
22
3- <p  align =" center " >
4- <a  href ="  https://www.alibabacloud.com " ><img  src =" https://aliyunsdk-pages.alicdn.com/icons/Aliyun.svg " ></a >
5- </p >
6- 
73<h1  align =" center " >Alibaba Cloud CLI</h1 >
84
95<p  align =" center " >
1814<a  href =" https://github.com/aliyun/aliyun-cli/releases " ><img  src =" https://img.shields.io/github/downloads/aliyun/aliyun-cli/total.svg "  alt =" GitHub All Releases "  ></a >
1915<p >
2016
21- 阿里云命令行工具是开源项目,您可以从[ Github] ( https://github.com/aliyun/aliyun-cli ) 上获取最新版本的CLI。
17+ 阿里云命令行工具是开源项目,您可以从 [ Github] ( https://github.com/aliyun/aliyun-cli )  上获取最新版本的 CLI。
18+ 您也可以在安装CLI前在Cloud Shell进行试用:
2219
2320<a  href =" https://shell.aliyun.com/ "  target =" cloudshell " >
2421  <img  src =" https://img.alicdn.com/tfs/TB1wt1zq9zqK1RjSZFpXXakSXXa-1066-166.png "  width =" 180 "  />
2522</a >
2623
27- ## 在线示例  
28- ** [ API Explorer] ( https://api.aliyun.com ) **  提供在线调用云产品 OpenAPI、并动态生成 SDK Example 代码和快速检索接口等能力,能显著降低使用云 API 的难度,强烈推荐使用
29- 
30- <a  href =" https://api.aliyun.com "  target =" api_explorer " >
31-   <img  src =" https://img.alicdn.com/tfs/TB12GX6zW6qK1RjSZFmXXX0PFXa-744-122.png "  width =" 180 "  />
32- </a >
33- 
3424## 简介  
3525
36- 阿里云命令行工具是用Go语言编写的, 基于阿里云OpenAPI打造的 ,用于管理阿里云资源的工具。通过下载和配置该工具,您可以在一个命令行方式下使用多个阿里云产品 。
26+ 阿里云命令行工具是用 Go 语言编写的, 基于阿里云 OpenAPI 打造的 ,用于管理阿里云资源的工具。通过下载和配置该工具,您可以在一个命令行方式下管理多个阿里云产品资源 。
3727
38- 如果您在使用SDK的过程中遇到任何问题 ,欢迎前往[ 阿里云SDK问答社区 ] ( https://yq.aliyun.com/tags/type_ask-tagid_23350  ) 提问,提问前请阅读 [ 提问引导 ] ( https://help.aliyun.com/document_detail/93957.html ) 。亦可在当前GitHub提交Issues 。
28+ 如果您在使用 CLI 的过程中遇到任何问题 ,欢迎前往[ 阿里云 CLI 问答社区 ] ( https://yq.aliyun.com/tags/type_ask-tagid_33502  ) 提问。亦可在当前 GitHub提交 Issues 。
3929
40- ** 注意** :阿里云CLI使用OpenAPI方式访问云产品,确保您已经开通了要使用的云产品并了解该产品的OpenAPI的使用。您可以在[ 阿里云API平台] ( https://developer.aliyun.com/api ) 获取产品API文档,了解API的使用方式及参数列表 。
30+ ** 注意** :阿里云CLI使用OpenAPI方式访问云产品,确保您已经开通了要使用的云产品并了解该产品的OpenAPI的使用。您可以在[ 阿里云API平台] ( https://developer.aliyun.com/api ) 获取产品 API 文档,了解 API 的使用方式及参数列表 。
4131
32+ ## CLI Releases  
4233
43- ## 安装  
44- 
45- 您可以通过下载安装包或者直接编译源码的方式安装阿里云CLI:
34+ CLI 版本更改说明请参考 [ CHANGELOG] ( ./CHANGELOG.md ) 
4635
47- -   ** 下载安装包 (推荐) ** 
36+ ##  安装 
4837
49- 	 阿里云CLI工具下载、解压后即可使用,支持Mac, Linux, Windows平台(x64版本)。	您可以将解压的`aliyun`可执行文件移至`/usr/local/bin`目录下,或添加到`$PATH`中。 
38+ -   ** 下载安装包 (推荐) **    
5039
51- 	 下载链接如下 (3.0.20): 
40+   阿里云CLI工具下载、解压后即可使用,支持Mac, Linux, Windows平台(x64版本)。您可以将解压的 ` aliyun ` 可执行文件移至 ` /usr/local/bin ` 目录下,或添加到 ` $PATH ` 中。 
5241
53- 	- [Mac](https://aliyuncli.alicdn.com/aliyun-cli-macosx-3.0.20-amd64.tgz) 
54- 	- [Linux](https://aliyuncli.alicdn.com/aliyun-cli-linux-3.0.20-amd64.tgz) 
55- 	- [Windows (64 bit)](https://aliyuncli.alicdn.com/aliyun-cli-windows-3.0.20-amd64.zip) 
42+   下载链接如下 (3.0.20):
5643
57- -  ** 编译源码** 
44+   -  [ Mac] ( https://aliyuncli.alicdn.com/aliyun-cli-macosx-3.0.20-amd64.tgz ) 
45+   -  [ Linux] ( https://aliyuncli.alicdn.com/aliyun-cli-linux-3.0.20-amd64.tgz ) 
46+   -  [ Windows (64 bit)] ( https://aliyuncli.alicdn.com/aliyun-cli-windows-3.0.20-amd64.zip ) 
5847
59- 	 如果您能访问[golang.org](https://golang.org/), 并安装配置好Golang环境(go1.10.1),请按照如下步骤下载源码并编译。 
48+ -   ** 使用brew ** 
6049
61- 	``` 
62- 	$ mkdir -p $GOPATH/src/github.com/aliyun 
63- 	$ cd $GOPATH/src/github.com/aliyun 
64- 	$ git clone http://github.com/aliyun/aliyun-cli.git 
65- 	$ git clone http://github.com/aliyun/aliyun-openapi-meta.git 
66- 	$ cd aliyun-cli 
67- 	$ make install 
68- 	``` 
50+   如果你的电脑上安装了 ` brew ` , 你可以使用它来安装阿里云命令行工具:
6951
70- -  ** 使用brew** 
52+   ``` sh 
53+   brew install aliyun-cli
54+   ``` 
7155
72-    如果你的电脑上安装了 ` brew ` , 你可以使用它来安装阿里云命令行工具:
73-    
74-    ``` 
75-    $ brew install aliyun-cli 
76-     ``` 
56+ 如果需要详细安装步骤或者编译安装步骤请访问官网文档 [ 安装 CLI] ( https://help.aliyun.com/document_detail/110343.html?spm=a2c4g.11186623.6.544.47ad1b18WHuF84 ) 
7757
7858## 配置  
7959
80- 在使用阿里云CLI前,您需要运行 ` aliyun configure ` 命令进行配置。在配置阿里云CLI时,您需要提供阿里云账号以及一对AccessKeyId和AccessKeySecret。 
60+ 详细配置指引请访问官网  [ 配置 CLI ] ( https://help.aliyun.com/document_detail/110341.html?spm=a2c4g.11186623.6.552.27f61b18o04a6s ) 
8161
82- 您可以在阿里云控制台的 [ AccessKey页面 ] ( https://ak-console.aliyun.com/#/accesskey ) 创建和查看您的AccessKey,或者联系您的系统管理员获取AccessKey 。
62+ 在使用阿里云CLI之前,您需要配置调用阿里云资源所需的凭证信息、地域、语言等 。
8363
84- ####  基本配置 
64+ 你可以运行 ` aliyun configure ` 命令进行快速配置 
8565
86- ``` 
66+ ``` sh 
8767$ aliyun configure
88- Configuring profile 'default' ... 
89- Aliyun Access Key ID [None]: <Your AccessKey ID> 
90- Aliyun Access Key Secret [None]: <Your AccessKey Secret> 
91- Default Region Id [None]: cn-hangzhou 
92- Default output format [json]: json 
93- Default Languate [zh]: zh 
94- ``` 
95- 
96- #### 多用户配置  
97- 
98- 阿里云CLI支持多用户配置。您可以使用` $ aliyun configure --profile user1 ` 命令指定使用哪个账号调用OpenAPI。
99- 
100- 执行` $ aliyun configure list ` 命令可以查看当前的用户配置, 如下表。 其中在Profile后面有星号(* )标志的为当前使用的默认用户配置。
101- 
102- ``` 
103- Profile   | Credential         | Valid   | Region           | Language 
104- --------- | ------------------ | ------- | ---------------- | -------- 
105- default * | AK:***f9b          | Valid   | cn-beijing       | zh 
106- aaa       | AK:******          | Invalid |                  | 
107- test      | AK:***456          | Valid   |                  | en 
108- ecs       | EcsRamRole:EcsTest | Valid   | cn-beijing       | en 
68+ Configuring profile ' default'   in  ' '   authenticate mode...
69+ Access Key Id []: AccessKey ID
70+ Access Key Secret []: AccessKey Secret
71+ Default Region Id []: cn-hangzhou
72+ Default Output Format [json]: json (Only support json))
73+ Default Language [zh| en] en:
74+ Saving profile[akProfile] ...Done.
10975``` 
11076
111- ####  其他认证方式  
77+ ### 其他认证方式  
11278
11379阿里云CLI,可通过在` configure ` 命令后增加` --mode <authenticationMethod> ` 参数的方式来使用不同的认证方式,目前支持的认证方式如下:
11480
@@ -119,106 +85,99 @@ ecs       | EcsRamRole:EcsTest | Valid   | cn-beijing       | en
11985|  RamRoleArn     |  使用RAM子账号的AssumeRole方式访问     | 
12086|  EcsRamRole     |  在ECS实例上通过EcsRamRole实现免密验证   | 
12187
122- ####  启用zsh/bash自动补全  
88+ ### 启用zsh/bash自动补全  
12389
12490-  使用` aliyun auto-completion ` 命令开启自动补全,目前支持zsh/bash
12591-  使用` aliyun auto-completion --uninstall ` 命令关闭自动补全
12692
127- #### 配置Pretty JSON  
128- 
129- 阿里云CLI返回的执行结果为Raw JSON。如需Pretty JSON,可安装[ jq] ( https://stedolan.github.io/jq/download/ ) 工具,使用方式如下:
130- 
131- ``` 
132- $ aliyun ecs DescribeRegions | jq 
133- ``` 
134- 
13593## 使用阿里云CLI  
13694
137- 阿里云云产品的OpenAPI有RPC和RESTful两种风格,大部分产品使用的是RPC风格。不同风格的API的调用方法也不同。
95+ 这里是基础使用指引,如需要详细使用手册,请访问 [ 这里] ( https://help.aliyun.com/document_detail/110344.html?spm=a2c4g.11186623.6.558.339122a6nSODBj ) 。
96+ 
97+ 阿里云云产品的 OpenAPI 有 RPC 和 RESTful 两种风格,大部分产品使用的是RPC风格。不同风格的API的调用方法也不同。
13898
13999您可以通过以下特点判断API风格:
140100
141101-  API参数中包含` Action ` 字段的是RPC风格,需要` PathPattern ` 参数的是Restful风格。
142102-  一般情况下,每个产品内,所有API的调用风格是统一的。
143103-  每个API仅支持特定的一种风格,传入错误的标识,可能会调用到其他API,或收到“ApiNotFound”的错误信息。
144104
145- #### 调用RPC风格的API
105+ ###  调用RPC风格的API  
146106
147107阿里云CLI中RPC风格的API调用的基本结构如下:
148108
149- ``` 
150- $  aliyun <product> <operation> [--parameter1 value1 --parameter2 value2 ...]
109+ ``` sh 
110+ aliyun < product>  < operation>  [--parameter1 value1 --parameter2 value2 ...]
151111``` 
152112
153113代码示例:
154114
115+ ``` sh 
116+ aliyun rds DescribeDBInstances --PageSize 50
117+ aliyun ecs DescribeRegions
118+ aliyun rds DescribeDBInstanceAttribute --DBInstanceId xxxxxx
155119``` 
156- $ aliyun rds DescribeDBInstances --PageSize 50 
157- $ aliyun ecs DescribeRegions 
158- $ aliyun rds DescribeDBInstanceAttribute --DBInstanceId xxxxxx 
159- ``` 
160- 
161120
162- ####  调用RESTful风格的API  
121+ ### 调用RESTful风格的API  
163122
164123部分阿里云产品如容器服务的OpenAPI为Restful风格,调用Restful风格的接口与调用RPC风格的接口方式不同。参考以下代码示例,调用RESTful API。
165124
166125-  GET请求示例:
167126
168- 	 ``` 
169- 	 $  aliyun cs GET /clusters
170- 	 ``` 
127+      ``` sh 
128+      aliyun cs GET /clusters
129+      ```
171130
172131- POST请求示例:
173132
174- 	 ``` 
175- 	 $  aliyun cs POST /clusters --body "$(cat input.json)"
176- 	 ``` 
133+      ` ` ` sh 
134+      aliyun cs POST /clusters --body " $( cat input.json) " 
135+      ` ` ` 
177136
178137- DELETE请求示例:
179138
180- 	 ``` 
181- 	 $  aliyun cs DELETE /clusters/ce2cdc26227e09c864d0ca0b2d5671a07
182- 	 ``` 
139+      ` ` ` sh 
140+      aliyun cs DELETE /clusters/ce2cdc26227e09c864d0ca0b2d5671a07
141+     ` ` ` 
183142
184- ####  获取帮助信息  
143+ # ## 获取帮助信息
185144
186145阿里云CLI集成了一部分产品的API和参数列表信息, 您可以使用如下命令来获取帮助:
187146
188147- ` $ aliyun help`  : 获取产品列表
189148
190149- ` $ aliyun help  < product> `  : 获取产品的API信息
191150
192- 	 如获取ECS的API信息:`$ aliyun help ecs` 
151+    如获取ECS的API信息:` $ aliyun help  ecs` 
193152
194153- ` $ aliyun help  < product>  < apiName> `  : 获取API的调用信息
195154
196- 	 如获取ECS的CreateInstance的信息: `aliyun help ecs CreateInstance` 
155+    如获取ECS的CreateInstance的信息: ` aliyun help  ecs CreateInstance` 
197156
198- ####  使用` --force ` 参数  
157+ # ## 使用`--force`参数
199158
200159阿里云CLI集成了一部分云产品的元数据,在调用时会对参数的合法性进行检查。如果使用了一个元数据中未包含的API或参数会导致` unknown api`  或` unknown parameter`  错误。可以使用` --force`  参数跳过API和参数检查,强制调用元数据列表外的API和参数,如:
201160
202- ``` 
203- $  aliyun newproduct --version 2018-01-01 --endpoint newproduct.aliyuncs.com --param1 ... --force
161+ ` ` ` sh 
162+ aliyun newproduct --version 2018-01-01 --endpoint newproduct.aliyuncs.com --param1 ... --force 
204163` ` ` 
205164
206165在使用` --force`  参数时,必须指定以下两个参数:
207166
208167- ` --version`  : 指定API的版本,你可以在API文档中找到版本号,如ECS的版本号是` 2014-05-26`  。
209- -  ` --endpoint ` : 指定产品的接入地址,一般产品接入地址是 ` product.aliyuncs.com ` ,或 ` product.en-central-1.aliyuncs.com ` , 请参考各产品的API文档。
168+ - ` --endpoint`  : 指定产品的接入地址。 请参考各产品的API文档。
210169
211170# ### 使用`--output`参数
212171
213172阿里云产品的查询接口会返回json结构化数据,不方便阅读。例如:
214173
215- ``` 
216- $  aliyun ecs DescribeInstances
174+ ` ` ` sh 
175+ aliyun ecs DescribeInstances 
217176` ` ` 
218177
219178执行以上命令将得到以下json结果:
220179
221- ``` 
180+ ` ` ` sh 
222181{ 
223182  " PageNumber"  : 1, 
224183  " TotalCount"  : 2, 
@@ -250,13 +209,13 @@ $ aliyun ecs DescribeInstances
250209
251210可以使用`  --output` 参数提取结果中感兴趣的字段,并进行表格化输出。例如:
252211
253- 
254- ``` 
255- $ aliyun ecs DescribeInstances --output cols=InstanceId,Status 
212+ ` ` `  sh
213+ aliyun ecs DescribeInstances --output cols=InstanceId,Status rows=Instances.Instance[] 
256214` ` ` 
257215
258216执行以上命令将得到以下形式的结果: 
259- ``` 
217+ 
218+ ` ` `  sh
260219InstanceId             | Status 
261220----------             | ------ 
262221i-12345678912345678123 | Stopped 
@@ -269,28 +228,37 @@ i-abcdefghijklmnopqrst | Running
269228
270229可选子参数: 
271230
272- -  ` rows ` : 通过[ jmespath] ( http://jmespath.org/ ) 查询语句来指定表格行在json结果中的数据来源。当查询语句具有` Instances.Instance[] ` 的形式时,可以省略该参数。
231+ - `  rows` : 通过 [jmespath](http://jmespath.org/) 查询语句来指定表格行在json结果中的数据来源。
232+    
233+ # ## 使用`--waiter`参数
273234
274- #### 使用` --waiter ` 参数  
275235该参数用于轮询实例信息直到出现特定状态。 
276236
277237例如使用ECS创建实例后,实例会有启动的过程。我们会不断的查询实例的运行状态,直到状态变为" Running"  。 
278238
279239例如: 
280240
281- ``` 
282- $  aliyun ecs DescribeInstances --InstanceIds '["i-12345678912345678123"]' --waiter expr='Instances.Instance[0].Status' to=Running
241+ ` ` ` sh 
242+ aliyun ecs DescribeInstances --InstanceIds '["  i-12345678912345678123" ]' --waiter expr='Instances.Instance[0].Status' to=Running
283243` ` ` 
284244
285245执行以上命令后,命令行程序将以一定时间间隔进行实例状态轮询,并在实例状态变为`  Running` 时停止轮询。
286246
287- 在使用` --waiter   ` 参数时,必须指定以下两个子参数:
247+ 在使用`  --waiter` 参数时,必须指定以下两个子参数:
288248
289- -  ` expr ` : 通过[ jmespath] ( http://jmespath.org/ ) 查询语句来指定json结果中的被轮询字段。
249+ - `  expr` : 通过  [jmespath](http://jmespath.org/)  查询语句来指定json结果中的被轮询字段。
290250- `  to` : 被轮询字段的目标值。
291251
292252可选子参数: 
293253
294254- `  timeout` : 轮询的超时时间(秒)。
295255- `  interval` : 轮询的间隔时间(秒)。
296256
257+ # # 获取帮助
258+ 
259+ 我们使用 GitHub issues 追踪用户反馈的 bug 和功能请求。请访问以下站点获取帮助: 
260+ 
261+ - 基本使用方法请访问官网 [阿里云CLI](https://help.aliyun.com/document_detail/110244.html? spm=a2c4g.11174283.6.542.553a474fAUytL0) 
262+ - 在 [云栖社区](https://yq.aliyun.com/) 上提问并使用标签 [阿里云CLI](https://yq.aliyun.com/tags/type_ask-tagid_33502) 
263+ - 在 [Stack Overflow](https://stackoverflow.com/) 上提问并使用标签 [aliyun-cli](https://stackoverflow.com/questions/tagged/aliyun-cli) 
264+ - 如果您发现了一个 BUG 或是希望新增一个特性,请[提交 issue](https://github.com/aliyun/aliyun-cli/issues/new/choose)。 
0 commit comments