diff --git a/docs/10-Endpoint-CN.md b/docs/10-Endpoint-CN.md index 9bd93cc3b7..2f6912f176 100644 --- a/docs/10-Endpoint-CN.md +++ b/docs/10-Endpoint-CN.md @@ -2,27 +2,64 @@ *** ## Endpoint -Endpoint 是请求访问的域名 -优先级:request > profile > rules - +> Endpoint 是请求接口服务的网络域名,如 `ecs.cn-hangzhou.aliyuncs.com` + +### Endpoint 寻址 + +[相关源码](../aliyun-java-sdk-core/src/main/java/com/aliyuncs/endpoint/DefaultEndpointResolver.java) + +1. 用户自定义 + +`用户自定义`是优先级最高的寻址逻辑,可以直接指定 endpoint 的具体内容。 + ```java -DefaultProfile profile = DefaultProfile.getProfile("regionId", "AccessKeyId", "AccessKeySecret"); -IAcsClient client = new DefaultAcsClient(profile); // 全局生效 -DefaultProfile.addEndpoint("regionId", "product", "your endpoint"); +DefaultProfile.addEndpoint("", "", ""); -DescribeRegionsRequest regionsRequest = new DescribeRegionsRequest(); -// 只对当前request生效 -regionsRequest.setSysEndpoint("your endpoint"); +// 只对当前 Request 生效 +DescribeRegionsRequest request = new DescribeRegionsRequest(); +request.setSysEndpoint(""); +``` + +2. Endpoint 拼接规则 -// 拼接规则设置网络,参数:share、 inner、 vpc、 public -regionsRequest.productNetwork = "public"; -DescribeRegionsResponse regionsResponse = client.getAcsResponse(regionsRequest); +在请求 VPC 网络时或产品 SDK 具有 Endpoint 数据文件时,当前寻址逻辑才会生效。 +Endpoint 数据文件示例 ([Ecs Endpoint Data File](../aliyun-java-sdk-ecs/src/main/java/com/aliyuncs/ecs/Endpoint.java)) + +```java +// 公网请求 +request.productNetwork = "public"; // 因为 `productNetwork` 的默认值为 `public`,所以默认情况下不需要配置 `productNetwork` +// 跨域请求 +request.productNetwork = "share"; + +// IPV6 请求 +request.productNetwork = "ipv6"; + +// 代理请求 +request.productNetwork = "proxy"; + +// 内部请求 +request.productNetwork = "inner"; + +// IPV4/IPV6 双协议栈 +request.productNetwork = "dualstack"; + +// VPC 请求 +request.productNetwork = "vpc"; +// 或者通过启用`enableUsingVpcEndpoint`配置来访问 vpc 网络 +DefaultProfile profile = DefaultProfile.getProfile("", "", ""); +profile.enableUsingVpcEndpoint(); ``` -拼接规则方式需要产品端支持并符合规范方可使用。 +3. 根据 Java SDK Core 中的 [endpoints.json](../aliyun-java-sdk-core/src/main/resources/endpoints.json) 数据文件进行寻址 + +内部操作,无需额外配置。 + +4. 请求 Location 服务接口,从远端获取 + +需要产品 SDK 具备 `ServiceCode` *** [← 异常](9-Exception-CN.md) | Endpoint[(English)](10-Endpoint-EN.md) | [首页 →](../README-CN.md) diff --git a/docs/10-Endpoint-EN.md b/docs/10-Endpoint-EN.md index 6577846d9a..0672e88ceb 100644 --- a/docs/10-Endpoint-EN.md +++ b/docs/10-Endpoint-EN.md @@ -2,27 +2,63 @@ *** ## Endpoint -The endpoint is the domain you want to access -Priority:request > profile > rules - +> Endpoint is the domain name of the service API. like `ecs.cn-hangzhou.aliyuncs.com` + +### Search Endpoint + +[Related source code](../aliyun-java-sdk-core/src/main/java/com/aliyuncs/endpoint/DefaultEndpointResolver.java) + +1. User custom defined + +`User custom defined` is the highest-priority logic to search endpoint and allows you to specify endpoint specifics directly. + +```java +// Global effect +DefaultProfile.addEndpoint("", "", ""); + +// Only works for the current request +DescribeRegionsRequest request = new DescribeRegionsRequest(); +request.setSysEndpoint(""); +``` + +2. Endpoint Splicing Rules + +`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](../aliyun-java-sdk-ecs/src/main/java/com/aliyuncs/ecs/Endpoint.java)) + ```java -DefaultProfile profile = DefaultProfile.getProfile("regionId", "AccessKeyId", "AccessKeySecret"); -IAcsClient client = new DefaultAcsClient(profile); -// global -DefaultProfile.addEndpoint("regionId", "product", "your endpoint"); +// Public network request(default) +request.productNetwork = "public"; // Since the default value of `productNetwork` is `public`, there is no need to configure `productNetwork` by default. + +// Share-domain request +request.productNetwork = "share"; -DescribeRegionsRequest regionsRequest = new DescribeRegionsRequest(); -// Only the current request is valid -regionsRequest.setSysEndpoint("your endpoint"); +// IPV6 network request +request.productNetwork = "ipv6"; -// Splicing rules set the network; parameter:share、 inner、 vpc、 public -regionsRequest.productNetwork = "public"; -DescribeRegionsResponse regionsResponse = client.getAcsResponse(regionsRequest); +// Proxy network request +request.productNetwork = "proxy"; +// Internal network request +request.productNetwork = "inner"; + +// IPV4/IPV6 Dual Stack +request.productNetwork = "dualstack"; + +// VPC network request +request.productNetwork = "vpc"; +// Or access the VPC network by enabling the `enableUsingVpcEndpoint` configuration +DefaultProfile profile = DefaultProfile.getProfile("", "", ""); +profile.enableUsingVpcEndpoint(); ``` -Splicing rules need to be supported by the product side and conform to the specification before they can be used。 +3. Search endpoint from the [endpoints.json](../aliyun-java-sdk-core/src/main/resources/endpoints.json) endpoint data file in the Java SDK Core +Internal operation, no additional configuration required. + +4. Request Location Service API to get `Endpoint` from the remote end. + +Requires product SDK with `ServiceCode`. *** [← 异常](9-Exception-EN.md) | Endpoint[(中文)](10-Endpoint-CN.md) | [首页 →](../README.md)