All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aliyuncs.endpoint.UserCustomizedEndpointResolver Maven / Gradle / Ivy

Go to download

Aliyun Open API SDK for Java Copyright (C) Alibaba Cloud Computing All rights reserved. 版权所有 (C)阿里云计算有限公司 http://www.aliyun.com

There is a newer version: 4.7.1
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy