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

com.distelli.aws.AWSRegionFactory Maven / Gradle / Ivy

There is a newer version: 3.8.16
Show newest version
package com.distelli.aws;

import com.amazonaws.regions.RegionUtils;
import com.amazonaws.regions.Region;
import javax.inject.Singleton;
import javax.inject.Inject;
import java.util.stream.Collectors;
import java.util.List;
import java.util.Collections;

@Singleton
public class AWSRegionFactory {
    @Inject
    protected AWSRegionFactory() {}

    /**
     * @param serviceName The service endpoint prefix which can be
     *     retrieved from the constant ENDPOINT_PREFIX of the specific service
     *     client interface.
     */
    public List listRegionsForServiceName(String serviceName) {
        List regions = RegionUtils.getRegionsForService(serviceName);
        if ( null == regions ) return Collections.emptyList();
        return regions.stream()
            .map(Region::getName)
            .collect(Collectors.toList());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy