Refine search
/** * Lookups the {@link Region} object for the given string region name. * * @param regionStr Region name. * @return Region object. * @throws SdkClientException If region cannot be found in the metadata. */ private Region getRegionObject(String regionStr) { Region regionObj = RegionUtils.getRegion(regionStr); if (regionObj == null) { throw new SdkClientException(String.format("Could not find region information for '%s' in SDK metadata.", regionStr)); } return regionObj; }
/** * @param regionName the region name. * @return the region with the id given, if it exists. Otherwise, returns * null. */ public static Region getRegion(String regionName) { for (Region r : getRegions()) { if (r.getName().equals(regionName)) { return r; } } return null; }
@SdkTestInternalApi SnsMessageManager(String region, SignatureVerifier signatureVerifier) { this.endpoint = RegionUtils.getRegion(region).getServiceEndpoint(AmazonSNS.ENDPOINT_PREFIX); this.signatureVerifier = signatureVerifier; this.messageUnmarshaller = new SnsMessageUnmarshaller(client); }
@Override public String getRegionName() { String authority = super.endpoint.getAuthority(); if(Constants.S3_HOSTNAME.equals(authority)) { return "us-east-1"; } Matcher m = Region.S3_REGIONAL_ENDPOINT_PATTERN.matcher(authority); try { m.matches(); return RegionUtils.getRegion(m.group(1)).getName(); } catch (Exception e) { throw new IllegalStateException("No valid region has been specified. Unable to return region name", e); } }
/** * Sets the region to be used for the default AWS SDK metric collector; * or null if the default is to be used. */ public static void setRegion(String region) { AwsSdkMetrics.region = RegionUtils.getRegion(region); }
AmazonRedshift redshiftClient ; String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+account + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"Redshift\" , \"region\":\"" ; for(Region region : RegionUtils.getRegions()){ try{ if(!skipRegions.contains(region.getName())){ redshiftClient = AmazonRedshiftClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build(); String nextMarker = null; DescribeClustersResult result; log.debug(InventoryConstants.ACCOUNT + account +" Type : Redshift " +region.getName() + " >> "+redshiftList.size()); redshiftMap.put(account+delimiter+region.getName(),redshiftList);
/** * Returns the respective AWS region. */ public com.amazonaws.regions.Region toAWSRegion() { final String s3regionId = getFirstRegionId(); if (s3regionId == null) { // US Standard return RegionUtils.getRegionByEndpoint(Constants.S3_HOSTNAME); } else { return RegionUtils.getRegion(s3regionId); } } }
String destinationRegion = originalCopySnapshotRequest .getDestinationRegion() != null ? originalCopySnapshotRequest .getDestinationRegion() : RegionUtils.getRegionByEndpoint( endPointDestination.getHost()).toString(); URI endPointSource = toURI(RegionUtils.getRegion(sourceRegion) .getServiceEndpoint(serviceName));
@Test public void testGetRegionByEndpoint() { Region usWest2 = RegionUtils.getRegionByEndpoint("s3.us-west-2.amazonaws.com"); Region standard = RegionUtils.getRegionByEndpoint("s3.amazonaws.com"); assertEquals(usWest2.getName(), "us-west-2"); assertEquals(usWest2.getServiceEndpoint(ServiceAbbreviations.S3), "s3.us-west-2.amazonaws.com"); assertEquals(standard.getName(), "us-east-1"); assertEquals(standard.getServiceEndpoint(ServiceAbbreviations.S3), "s3.amazonaws.com"); }
.getRegionByEndpoint(this.endpoint.getHost()) .getName(); } catch (final IllegalArgumentException exception) {
private String resolveCertCommonName(String region) { if (Regions.CN_NORTH_1.getName().equals(region)) { return "sns-cn-north-1.amazonaws.com.cn"; } if (Regions.CN_NORTHWEST_1.getName().equals(region)) { return "sns-cn-northwest-1.amazonaws.com.cn"; } if (Regions.GovCloud.getName().equals(region)) { return "sns-us-gov-west-1.amazonaws.com"; } return "sns." + RegionUtils.getRegion(region).getDomain(); } }
public ECRClient(RegistryCred registryCred) { _registryCred = registryCred; BasicAWSCredentials awsCreds = new BasicAWSCredentials(registryCred.getKey(), registryCred.getSecret()); _awsEcrClient = new AmazonECRClient(awsCreds); Region awsRegion = RegionUtils.getRegion(registryCred.getRegion()); if(awsRegion == null) throw(new IllegalArgumentException("Invalid Region: "+registryCred.getRegion()+" for ECR Registry")); if(!awsRegion.isServiceSupported("ecr")) throw(new IllegalArgumentException("ECR is not supported in Region: "+registryCred.getRegion())); String endpoint = awsRegion.getServiceEndpoint("ecr"); if(endpoint == null) throw(new IllegalArgumentException("Unable to determine ECR endpoint in Region: "+registryCred.getRegion())); _awsEcrClient.setEndpoint(endpoint); }
public static String selectPartitionName(String region) { return (RegionUtils.getRegion(region).getPartition()); }
/** * @param serviceAbbreviation the service abbreviation. * @return a list of the regions that support the service given. * * @see ServiceAbbreviations */ @SuppressWarnings("checkstyle:hiddenfield") public static synchronized List<Region> getRegionsForService(String serviceAbbreviation) { List<Region> regions = new LinkedList<Region>(); for (Region r : getRegions()) { if (r.isServiceSupported(serviceAbbreviation)) { regions.add(r); } } return regions; }
/** * 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); }
@Test(expected = IllegalArgumentException.class) public void testGetRegionByEndpointWithBogusEndpoint() { Region standard = RegionUtils.getRegionByEndpoint("bogus.amazonaws.com"); }
/** * @param regionName the region name. * @return the region with the id given, if it exists. Otherwise, returns * null. */ public static Region getRegion(String regionName) { for (Region r : getRegions()) { if (r.getName().equals(regionName)) { return r; } } return null; }
private URI createEndpoint(String regionName, String serviceName) { final Region region = RegionUtils.getRegion(regionName); if (region == null) { throw new AmazonClientException("{" + serviceName + ", " + regionName + "} was not " + "found in region metadata. Update to latest version of SDK and try again."); } return toURI(region.getServiceEndpoint(serviceName)); }