|
1 |
| -# Endpoint |
2 |
| - |
3 |
| -The endpoint is the domain you want to access |
4 |
| - |
5 |
| -Priority:request > profile > rules |
6 |
| - |
7 |
| -```python |
8 |
| -from aliyunsdkcore.client import AcsClient |
9 |
| -from aliyunsdkecs.request.v20140526.DescribeRegionsRequest import DescribeRegionsRequest |
10 |
| - |
11 |
| -client = AcsClient( |
12 |
| - 'ACCESS_KEY_ID', |
13 |
| - 'ACCESS_KEY_SECRET', |
14 |
| -) |
15 |
| -# global |
16 |
| -client.add_endpoint("region_id", "product", "your endpoint") |
17 |
| - |
18 |
| -request = DescribeRegionsRequest() |
19 |
| -# Only the current request is valid |
20 |
| -request.endpoint = 'your endpoint' |
21 |
| -# Splicing rules set the network; parameter:share、 inner、 vpc、 public |
22 |
| -request.request_network = 'public' |
23 |
| -response = client.do_action_with_exception(request) |
24 |
| -``` |
25 |
| - |
26 |
| -Splicing rules need to be supported by the product side and conform to the specification before they can be used。 |
| 1 | +# Endpoint |
| 2 | + |
| 3 | +Endpoint is the domain name of the service API. like `ecs.cn-hangzhou.aliyuncs.com` |
| 4 | + |
| 5 | +### Search Endpoint |
| 6 | + |
| 7 | +[Related source code](https://github.com/aliyun/aliyun-openapi-python-sdk/blob/master/aliyun-python-sdk-core/aliyunsdkcore/endpoint/default_endpoint_resolver.py) |
| 8 | + |
| 9 | +1. User custom defined |
| 10 | + |
| 11 | +`User custom defined` is the highest-priority logic to search endpoint and allows you to specify endpoint specifics directly. |
| 12 | + |
| 13 | +```python |
| 14 | +# Global effect |
| 15 | +client = AcsClient() |
| 16 | +client.add_endpoint("<region_id>", "<product>", "<endpoint>") |
| 17 | + |
| 18 | + |
| 19 | +# Only works for the current request |
| 20 | +request = DescribeRegionsRequest() |
| 21 | +request.set_endpoint("<endpoint>") |
| 22 | +``` |
| 23 | + |
| 24 | +2. Endpoint Splicing Rules |
| 25 | + |
| 26 | +`Endpoint Splicing Rules` does not take effect until the vpc network is enabled or the product SDK has an Endpoint data file. Endpoint Data File Example : ([Ecs Endpoint Data File](https://github.com/aliyun/aliyun-openapi-python-sdk/blob/master/aliyun-python-sdk-ecs/aliyunsdkecs/endpoint.py)) |
| 27 | + |
| 28 | +```python |
| 29 | +# Public network request(default) |
| 30 | +request.request_network = "public" # Since the default value of `network` is `public`, there is no need to configure `network` by default. |
| 31 | + |
| 32 | +# Share-domain request |
| 33 | +request.request_network = "share" |
| 34 | + |
| 35 | +# Ipv6 network request |
| 36 | +request.request_network = "ipv6" |
| 37 | + |
| 38 | +# Proxy network request |
| 39 | +request.request_network = "proxy" |
| 40 | + |
| 41 | +# Internal network request |
| 42 | +request.request_network = "inner" |
| 43 | + |
| 44 | +# Ipv4/Ipv6 Dual Stack |
| 45 | +request.request_network = "dualstack" |
| 46 | + |
| 47 | +# Vpc network request |
| 48 | +request.request_network = "vpc" |
| 49 | +``` |
| 50 | + |
| 51 | +3. Search endpoint from the [endpoints.json](https://github.com/aliyun/aliyun-openapi-python-sdk/blob/master/aliyun-python-sdk-core/aliyunsdkcore/data/endpoints.json) endpoint data file in the Java SDK Core Internal operation, no additional configuration required. |
| 52 | + |
| 53 | +4. Request Location Service API to get `Endpoint` from the remote end. |
| 54 | + |
| 55 | +Requires product SDK with `ServiceCode`. |
0 commit comments