Skip to content

Commit 7f614b7

Browse files
Orisdaddypeze
authored andcommitted
add document
1 parent 4166ee3 commit 7f614b7

14 files changed

+324
-1
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,12 @@ The following example shows what the `HTTP DEBUG` do, which will help you debug
158158
< x-acs-request-id : 670F3D09-F8E7-4144-83C3-B56C35DA35ED
159159
< Server : Jetty(7.2.2.v20101205)
160160
```
161+
162+
## Documentation
163+
164+
- [Requirements](docs/0-Requirement-EN.md)
165+
- [Installation](./docs/1-Installation-EN.md)
166+
- [Client](./docs/2-Client-EN.md)
167+
- [Timeout](./docs/3-Timeout-EN.md)
168+
- [Proxy Configurations](./docs/4-Proxy-EN.md)
169+
- [Log](./docs/5-Log-EN.md)

README_zh.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,13 @@ print response
9494
< Access-Control-Max-Age : 172800
9595
< x-acs-request-id : 670F3D09-F8E7-4144-83C3-B56C35DA35ED
9696
< Server : Jetty(7.2.2.v20101205)
97-
```
97+
```
98+
99+
## 文档
100+
101+
- [环境要求](./docs/0-Requirement-CN.md)
102+
- [安装](./docs/1-Installation-CN.md)
103+
- [客户端](./docs/2-Client-CN.md)
104+
- [超时机制](./docs/3-Timeout-CN.md)
105+
- [代理配置](./docs/4-Proxy-CN.md)
106+
- [日志](./docs/5-Log-CN.md)

docs/0-Requirement-CN.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 要求
2+
3+
- 要使用 Alibaba Cloud SDK for Python,您需要一个云账号以及一对`Access Key ID``Access Key Secret`。 请在阿里云控制台中的[AccessKey管理页面](https://usercenter.console.aliyun.com/?spm=5176.doc52740.2.3.QKZk8w#/manage/ak)上创建和查看您的Access Key,或者联系您的系统管理员。
4+
- 要使用 Alibaba Cloud SDK for Python 访问某个产品的API,您需要事先在[阿里云控制台](https://home.console.aliyun.com/?spm=5176.doc52740.2.4.QKZk8w)中开通这个产品。
5+
- Alibaba Cloud SDK for Python 需要python2.7及以上版本。

docs/0-Requirement-EN.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Requirements
2+
3+
- To use Alibaba Cloud SDK for Python, you must have an Alibaba Cloud account as well as an `AccessKey ID` and an `AccessKey Secret`. Create and view your AccessKey on the [RAM console](https://ram.console.aliyun.com/) or contact your system administrator.
4+
- To use the Alibaba Cloud SDK for Python to access the APIs of a product, you must first activate the product on the [Alibaba Cloud console](https://home.console.aliyun.com/?spm=5176.doc52740.2.4.QKZk8w) if required.
5+
- The Alibaba Cloud Python SDK requires python 2.7 or later.

docs/1-Installation-CN.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# 安装
2+
3+
无论您要使用哪个产品的开发工具包,都必须安装`aliyun-python-sdk-core`。比如,对云服务器SDK的调用,您需要安装`aliyun-python-sdk-core``aliyun-python-sdk-ecs`(安装`aliyun-python-sdk-ecs`会自动安装依赖库`aliyun-python-sdk-core`)。
4+
5+
## 通过pip来安装项目依赖
6+
7+
```bash
8+
pip install aliyun-python-sdk-ecs
9+
```

docs/1-Installation-EN.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Installation
2+
3+
You must install `aliyun-python-sdk-core` library no matter which product development kit you want to use. For example, to call the ECS SDK, you need to install `aliyun-python-sdk-core` library and `aliyun-python-sdk-ecs` library.
4+
5+
## use pip install Python SDK library
6+
7+
```bash
8+
pip install aliyun-python-sdk-ecs
9+
```

docs/2-Client-CN.md

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# 客户端
2+
3+
## 使用 AccessKey 调用
4+
5+
```python
6+
from aliyunsdkcore.client import AcsClient
7+
from aliyunsdkecs.request.v20140526.AcceptInquiredSystemEventRequest import AcceptInquiredSystemEventRequest
8+
9+
# 实例化Client
10+
client = AcsClient(
11+
'<access_key_id>', # RAM账号的AccessKey ID
12+
'<access_secret>', # RAM账号Access Key Secret
13+
'<region_id>"' # 地域ID
14+
)
15+
16+
# 创建API请求并设置参数
17+
request = AcceptInquiredSystemEventRequest()
18+
request.set_accept_format('json')
19+
# 发起请求并处理应答或异常
20+
response = client.do_action_with_exception(request)
21+
22+
print(str(response, encoding='utf-8'))
23+
```
24+
25+
## 使用默认凭证提供链
26+
27+
默认凭证提供程序链查找可用的凭证,寻找顺序如下:
28+
29+
1.系统属性
30+
31+
在系统属性里寻找环境凭证,如果定义了 `alibabacloud.accessKeyId``alibabacloud.accessKeyIdSecret` 系统属性且不为空,程序将使用它们创建默认凭证。
32+
33+
2.环境凭证
34+
35+
在环境变量里寻找环境凭证,如果定义了 `ALIBABA_CLOUD_ACCESS_KEY_ID``ALIBABA_CLOUD_ACCESS_KEY_SECRET` 环境变量且不为空,程序将使用它们创建默认凭证。
36+
37+
3.配置文件
38+
39+
如果用户主目录存在默认文件 `~/.alibabacloud/credentials (Windows 为 C:\Users\USER_NAME\.alibabacloud\credentials)`,程序会自动创建指定类型和名称的凭证。默认文件可以不存在,但解析错误会抛出异常。配置名小写。不同的项目、工具之间可以共用这个配置文件,因为不在项目之内,也不会被意外提交到版本控制。 可以通过定义 `ALIBABA_CLOUD_CREDENTIALS_FILE` 环境变量修改默认文件的路径。不配置则使用默认配置 `default`,也可以设置环境变量 `ALIBABA_CLOUD_PROFILE` 使用配置。
40+
41+
```ini
42+
[default] # 默认配置
43+
enable = true # 启用,没有该选项默认不启用
44+
type = access_key # 认证方式为 access_key
45+
access_key_id = foo # Key
46+
access_key_secret = bar # Secret
47+
48+
[client1] # 命名为 `client1` 的配置
49+
type = ecs_ram_role # 认证方式为 ecs_ram_role
50+
role_name = EcsRamRoleTest # Role Name
51+
52+
[client2] # 命名为 `client2` 的配置
53+
enable = false # 不启用
54+
type = ram_role_arn # 认证方式为 ram_role_arn
55+
region_id = cn-test # 获取session用的region
56+
policy = test # 选填 指定权限
57+
access_key_id = foo
58+
access_key_secret = bar
59+
role_arn = role_arn
60+
role_session_name = session_name # 选填
61+
62+
[client3] # 命名为 `client3` 的配置
63+
type = rsa_key_pair # 认证方式为 rsa_key_pair
64+
public_key_id = publicKeyId # Public Key ID
65+
private_key_file = /your/pk.pem # Private Key 文件
66+
```
67+
68+
4.实例 RAM 角色
69+
70+
如果定义了环境变量 `ALIBABA_CLOUD_ECS_METADATA` 且不为空,程序会将该环境变量的值作为角色名称,请求 http://100.100.100.200/latest/meta-data/ram/security-credentials/ 获取临时安全凭证。
71+
72+
```python
73+
from aliyunsdkcore.client import AcsClient
74+
from aliyunsdkecs.request.v20140526.AcceptInquiredSystemEventRequest import AcceptInquiredSystemEventRequest
75+
76+
client = AcsClient(
77+
'<region_id>"'
78+
)
79+
80+
request = AcceptInquiredSystemEventRequest()
81+
request.set_accept_format('json')
82+
83+
response = client.do_action_with_exception(request)
84+
85+
print(str(response, encoding='utf-8'))
86+
```
87+
88+
## 使用 Bearertoken 调用(暂不支持)

docs/2-Client-EN.md

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Client
2+
3+
## Using AccessKey call
4+
5+
```python
6+
from aliyunsdkcore.client import AcsClient
7+
from aliyunsdkecs.request.v20140526.AcceptInquiredSystemEventRequest import AcceptInquiredSystemEventRequest
8+
9+
# Create and initialize a AcsClient instance
10+
client = AcsClient(
11+
'<access_key_id>', # The AccessKey ID of the RAM account
12+
'<access_secret>', # The AccessKey Secret of the RAM account
13+
'<region_id>"' # The region ID
14+
)
15+
16+
# Create an API request and set parameters
17+
request = AcceptInquiredSystemEventRequest()
18+
request.set_accept_format('json')
19+
# Initiate the request and handle the response or exceptions
20+
response = client.do_action_with_exception(request)
21+
22+
print(str(response, encoding='utf-8'))
23+
```
24+
25+
## Use the default credential provider chain
26+
27+
The default credential provider chain looks for available credentials, with following order:
28+
29+
1.System Properties
30+
31+
Look for environment credentials in system properties. If the `alibabacloud.accessKeyId` and `alibabacloud.accessKeyIdSecret` system properties are defined and not empty, the program will use them to create default credentials.
32+
33+
2.Environment Credentials
34+
35+
Look for environment credentials in environment variable. If the `ALIBABA_CLOUD_ACCESS_KEY_ID` and `ALIBABA_CLOUD_ACCESS_KEY_SECRET` environment variables are defined and are not empty, the program will use them to create default credentials.
36+
37+
3.Credentials File
38+
39+
If there is `~/.alibabacloud/credentials default file (Windows shows C:\Users\USER_NAME\.alibabacloud\credentials)`, the program automatically creates credentials with the specified type and name. The default file is not necessarily exist, but a parse error will throw an exception. The name of configuration item is lowercase.This configuration file can be shared between different projects and between different tools. Because it is outside of the project and will not be accidentally committed to the version control. The path to the default file can be modified by defining the `ALIBABA_CLOUD_CREDENTIALS_FILE` environment variable. If not configured, use the default configuration `default`. You can also set the environment variables `ALIBABA_CLOUD_PROFILE` to use the configuration.
40+
41+
```ini
42+
[default] # default setting
43+
enable = true # Enable,Enabled by default if this option is not present
44+
type = access_key # Certification type: access_key
45+
access_key_id = foo # Key
46+
access_key_secret = bar # Secret
47+
48+
[client1] # configuration that is named as `client1`
49+
type = ecs_ram_role # Certification type: ecs_ram_role
50+
role_name = EcsRamRoleTest # Role Name
51+
52+
[client2] # configuration that is named as `client2`
53+
enable = false # Disable
54+
type = ram_role_arn # Certification type: ram_role_arn
55+
region_id = cn-test
56+
policy = test # optional Specify permissions
57+
access_key_id = foo
58+
access_key_secret = bar
59+
role_arn = role_arn
60+
role_session_name = session_name # optional
61+
62+
[client3] # configuration that is named as `client3`
63+
type = rsa_key_pair # Certification type: rsa_key_pair
64+
public_key_id = publicKeyId # Public Key ID
65+
private_key_file = /your/pk.pem # Private Key file
66+
```
67+
68+
4.Instance RAM Role
69+
70+
If the environment variable `ALIBABA_CLOUD_ECS_METADATA` is defined and not empty, the program will take the value of the environment variable as the role name and request http://100.100.100.200/latest/meta-data/ram/security-credentials/ to get the temporary Security credentials.
71+
72+
```python
73+
from aliyunsdkcore.client import AcsClient
74+
from aliyunsdkecs.request.v20140526.AcceptInquiredSystemEventRequest import AcceptInquiredSystemEventRequest
75+
76+
client = AcsClient(
77+
'<region_id>"'
78+
)
79+
80+
request = AcceptInquiredSystemEventRequest()
81+
request.set_accept_format('json')
82+
83+
response = client.do_action_with_exception(request)
84+
85+
print(str(response, encoding='utf-8'))
86+
```

docs/3-Timeout-CN.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# 超时机制
2+
3+
Request 设置 -> Client 设置 -> 默认,优先级依次降低; 默认连接超时为5秒,读超时为10秒;
4+
5+
```python
6+
from aliyunsdkcore.client import AcsClient
7+
from aliyunsdkecs.request.v20140526.AcceptInquiredSystemEventRequest import AcceptInquiredSystemEventRequest
8+
# Client超时设置,对当前所有request有效
9+
client = AcsClient(
10+
'<access_key_id>',
11+
'<access_secret>',
12+
'<region_id>"',
13+
connect_timeout=10, # 连接超时
14+
timeout=15 # 读超时时间
15+
)
16+
17+
request = AcceptInquiredSystemEventRequest()
18+
# request超时设置,仅对当前请求有效
19+
request.set_connect_timeout(10)
20+
request.set_read_timeout(15)
21+
```

docs/3-Timeout-EN.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Timeout
2+
3+
Request Settings -> Client Settings -> Default Settings, priority from high to low; The default ConnectTimeout is 5 seconds and the ReadTimeout is 10 seconds.
4+
5+
```python
6+
from aliyunsdkcore.client import AcsClient
7+
from aliyunsdkecs.request.v20140526.AcceptInquiredSystemEventRequest import AcceptInquiredSystemEventRequest
8+
# The client setting is valid for all requests
9+
client = AcsClient(
10+
'<access_key_id>',
11+
'<access_secret>',
12+
'<region_id>"',
13+
connect_timeout=10, # connect timeout
14+
timeout=15 # read timeout
15+
)
16+
17+
request = AcceptInquiredSystemEventRequest()
18+
# The request setting, valid only for the current request
19+
request.set_connect_timeout(10)
20+
request.set_read_timeout(15)
21+
```

docs/4-Proxy-CN.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# 代理配置
2+
3+
支持以下环境变量:
4+
5+
1. HTTP_PROXY或者http_proxy
6+
2. HTTPS_PROXY或者https_proxy

docs/4-Proxy-EN.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Proxy Configurations
2+
3+
Support below environment variable:
4+
5+
1. HTTP_PROXY or http_proxy
6+
2. HTTPS_PROXY or https_proxy

docs/5-Log-CN.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# 日志
2+
3+
## 设置Logger
4+
5+
```python
6+
from aliyunsdkcore.client import AcsClient
7+
from aliyunsdkecs.request.v20140526.AcceptInquiredSystemEventRequest import AcceptInquiredSystemEventRequest
8+
9+
import sys
10+
11+
client = AcsClient(
12+
'<access_key_id>',
13+
'<access_secret>',
14+
'<region_id>"'
15+
)
16+
client.set_stream_logger(
17+
stream=sys.stderr, # 日志输出对象
18+
format_string='%(thread)d %(asctime)s %(name)s %(levelname)s %(message)s' # 日志输出格式
19+
)
20+
21+
client.set_file_logger(
22+
path='<file_path>' # 日志文件地址
23+
)
24+
25+
```

docs/5-Log-EN.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Log
2+
3+
## Logger configuration
4+
5+
```python
6+
from aliyunsdkcore.client import AcsClient
7+
from aliyunsdkecs.request.v20140526.AcceptInquiredSystemEventRequest import AcceptInquiredSystemEventRequest
8+
9+
import sys
10+
11+
client = AcsClient(
12+
'<access_key_id>',
13+
'<access_secret>',
14+
'<region_id>"'
15+
)
16+
client.set_stream_logger(
17+
stream=sys.stderr, # output stream
18+
format_string='%(thread)d %(asctime)s %(name)s %(levelname)s %(message)s' # log format
19+
)
20+
21+
client.set_file_logger(
22+
path='<file_path>' # log file path
23+
)
24+
```

0 commit comments

Comments
 (0)