/** * Searches through all known regions to find one with any service at the * specified endpoint. If no region is found with a service at that * endpoint, an exception is thrown. * * @param endpoint The endpoint for any service residing in the desired * region. * @return The region containing any service running at the specified * endpoint, otherwise an exception is thrown if no region is found * with a service at the specified endpoint. * @throws MalformedURLException If the given URL is malformed, or if the * one of the service URLs on record is malformed. */ public static Region getRegionByEndpoint(String endpoint) { URI targetEndpointUri = getUriByEndpoint(endpoint); String targetHost = targetEndpointUri.getHost(); for (Region region : getRegions()) { for (String serviceEndpoint : region.getServiceEndpoints().values()) { URI serviceEndpointUrl = getUriByEndpoint(serviceEndpoint); if (serviceEndpointUrl.getHost().equals(targetHost)) return region; } } throw new IllegalArgumentException("No region found with any service for endpoint " + endpoint); }
/** * Searches through all known regions to find one with any service at the * specified endpoint. If no region is found with a service at that * endpoint, an exception is thrown. * * @param endpoint The endpoint for any service residing in the desired * region. * @return The region containing any service running at the specified * endpoint, otherwise an exception is thrown if no region is found * with a service at the specified endpoint. * @throws MalformedURLException If the given URL is malformed, or if the * one of the service URLs on record is malformed. */ public static Region getRegionByEndpoint(String endpoint) { URI targetEndpointUri = getUriByEndpoint(endpoint); String targetHost = targetEndpointUri.getHost(); for (Region region : getRegions()) { for (String serviceEndpoint : region.getServiceEndpoints().values()) { URI serviceEndpointUrl = getUriByEndpoint(serviceEndpoint); if (serviceEndpointUrl.getHost().equals(targetHost)) return region; } } throw new IllegalArgumentException("No region found with any service for endpoint " + endpoint); }
/** * Searches through all known regions to find one with any service at the * specified endpoint. If no region is found with a service at that * endpoint, an exception is thrown. * * @param endpoint The endpoint for any service residing in the desired * region. * @return The region containing any service running at the specified * endpoint, otherwise an exception is thrown if no region is found * with a service at the specified endpoint. * @throws MalformedURLException If the given URL is malformed, or if the * one of the service URLs on record is malformed. */ public static Region getRegionByEndpoint(String endpoint) { URI targetEndpointUri = getUriByEndpoint(endpoint); String targetHost = targetEndpointUri.getHost(); for (Region region : getRegions()) { for (String serviceEndpoint : region.getServiceEndpoints().values()) { URI serviceEndpointUrl = getUriByEndpoint(serviceEndpoint); if (serviceEndpointUrl.getHost().equals(targetHost)) return region; } } throw new IllegalArgumentException("No region found with any service for endpoint " + endpoint); }