/** * Parses the specified input stream and returns a {@code RegionMetadata} * object. * * @param input the input stream to parse * @return the parsed region metadata * @throws IOException on error */ public static RegionMetadata parse(final InputStream input) throws IOException { return new RegionMetadata(internalParse(input, false)); }
/** * Returns the region with the given regionName and proper partition if found in region metadata. * Otherwise, returns a {@link Region} object with given regionName and aws partition. */ public static Region getRegion(String regionName) { return getRegionMetadata().getRegion(regionName); }
/** * Returns a list of the regions that support the service given. * * @param serviceAbbreviation * The service endpoint prefix which can be retrieved from the * constant ENDPOINT_PREFIX of the specific service client interface. * */ public static List<Region> getRegionsForService( String serviceAbbreviation) { return getRegionMetadata().getRegionsForService(serviceAbbreviation); }
/** * 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 IllegalArgumentException If the given URL is malformed, or if the * one of the service URLs on record is malformed. */ public Region getRegionByEndpoint(final String endpoint) { String host = getHost(endpoint); for (Region region : regions) { for (String serviceEndpoint : region.getServiceEndpoints().values()) { if (host.equals(getHost(serviceEndpoint))) { return region; } } } throw new IllegalArgumentException( "No region found with any service for endpoint " + endpoint); }
/** * Returns a list of the available AWS regions. */ public static List<Region> getRegions() { return getRegionMetadata().getRegions(); }
@Test public void testGetRegionByEndpoint() { Region region = metadata.getRegionByEndpoint("s3-us-west-1.amazonaws.com"); Assert.assertNotNull(region); Assert.assertEquals("us-west-1", region.getName()); try { metadata.getRegionByEndpoint("bogus-monkeys"); Assert.fail("Expected an IllegalArgumentException"); } catch (IllegalArgumentException e) { } } }
/** * 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 IllegalArgumentException If the given URL is malformed, or if the * one of the service URLs on record is malformed. */ public Region getRegionByEndpoint(final String endpoint) { String host = getHost(endpoint); for (Region region : regions) { for (String serviceEndpoint : region.getServiceEndpoints().values()) { if (host.equals(getHost(serviceEndpoint))) { return region; } } } throw new IllegalArgumentException( "No region found with any service for endpoint " + endpoint); }
/** * Returns a list of the available AWS regions. */ public static List<Region> getRegions() { return getRegionMetadata().getRegions(); }
public static RegionMetadata create() { RegionMetadata metadata = createLegacyXmlRegionMetadata(); if (metadata == null) { metadata = new RegionMetadata(new PartitionsLoader().build()); } return metadata; }
/** * Returns the region with the given regionName and proper partition if found in region metadata. * Otherwise, returns a {@link Region} object with given regionName and aws partition. */ public static Region getRegion(String regionName) { return getRegionMetadata().getRegion(regionName); }
/** * Returns a list of the regions that support the service given. * * @param serviceAbbreviation * The service endpoint prefix which can be retrieved from the * constant ENDPOINT_PREFIX of the specific service client interface. * */ public static List<Region> getRegionsForService( String serviceAbbreviation) { return getRegionMetadata().getRegionsForService(serviceAbbreviation); }
/** * 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 IllegalArgumentException If the given URL is malformed, or if the * one of the service URLs on record is malformed. */ public Region getRegionByEndpoint(final String endpoint) { String host = getHost(endpoint); for (Region region : regions) { for (String serviceEndpoint : region.getServiceEndpoints().values()) { if (host.equals(getHost(serviceEndpoint))) { return region; } } } throw new IllegalArgumentException( "No region found with any service for endpoint " + endpoint); }
/** * Returns a list of the available AWS regions. */ public static List<Region> getRegions() { return getRegionMetadata().getRegions(); }
/** * Parses the specified input stream and returns a {@code RegionMetadata} * object. * * @param input the input stream to parse * @return the parsed region metadata * @throws IOException on error */ public static RegionMetadata parse(final InputStream input) throws IOException { return new RegionMetadata(internalParse(input, false)); }
@Test public void testGetRegion() { Region region = metadata.getRegion("us-east-1"); Assert.assertNotNull(region); Assert.assertEquals("us-east-1", region.getName()); region = metadata.getRegion("us-west-1"); Assert.assertNotNull(region); Assert.assertEquals("us-west-1", region.getName()); region = metadata.getRegion("cn-north-1"); Assert.assertNotNull(region); Assert.assertEquals("cn-north-1", region.getName()); region = metadata.getRegion("bogus-monkeys"); Assert.assertNull(region); }
@Test public void testGetRegionsForService() { List<Region> regions = metadata.getRegionsForService("s3"); Assert.assertNotNull(regions); Assert.assertEquals(2, regions.size()); Assert.assertEquals("us-east-1", regions.get(0).getName()); Assert.assertEquals("us-west-1", regions.get(1).getName()); regions = metadata.getRegionsForService("bogus-monkeys"); Assert.assertNotNull(regions); Assert.assertTrue(regions.isEmpty()); }
/** * Parses the specified input stream and returns a {@code RegionMetadata} * object. * * @param input the input stream to parse * @return the parsed region metadata * @throws IOException on error */ public static RegionMetadata parse(final InputStream input) throws IOException { return new RegionMetadata(internalParse(input, false)); }
/** * Returns the region with the id given, if it exists. Otherwise, returns * null. */ public static Region getRegion(String regionName) { return getRegionMetadata().getRegion(regionName); }
/** * Returns a list of the regions that support the service given. * * @param serviceAbbreviation * The service endpoint prefix which can be retrieved from the * constant ENDPOINT_PREFIX of the specific service client interface. * */ public static List<Region> getRegionsForService( String serviceAbbreviation) { return getRegionMetadata().getRegionsForService(serviceAbbreviation); }
public static RegionMetadata create() { RegionMetadata metadata = createLegacyXmlRegionMetadata(); if (metadata == null) { metadata = new RegionMetadata(new PartitionsLoader().build()); } return metadata; }