com.aliyuncs.endpoint.UserCustomizedEndpointResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aliyun-java-sdk-core Show documentation
Show all versions of aliyun-java-sdk-core Show documentation
Aliyun Open API SDK for Java
Copyright (C) Alibaba Cloud Computing
All rights reserved.
版权所有 (C)阿里云计算有限公司
http://www.aliyun.com
package com.aliyuncs.endpoint;
import java.util.HashSet;
import java.util.Set;
public class UserCustomizedEndpointResolver extends EndpointResolverBase {
private Set validRegionIds;
public UserCustomizedEndpointResolver() {
validRegionIds = new HashSet();
}
public void putEndpointEntry(String regionId, String productCode, String endpoint) {
putEndpointEntry(makeEndpointKey(productCode, regionId), endpoint);
validRegionIds.add(regionId);
}
@Override
public String resolve(ResolveEndpointRequest request) {
return fetchEndpointEntry(request);
}
@Override
public String makeEndpointKey(ResolveEndpointRequest request) {
return makeEndpointKey(request.productCode, request.regionId);
}
public String makeEndpointKey(String productCode, String regionId) {
return productCode.toLowerCase() + "." + regionId.toLowerCase();
}
@Override
public boolean isRegionIdValid(ResolveEndpointRequest request) {
return validRegionIds.contains(request.regionId);
}
}