/** * Gets the region in use by the builder. */ public final String getRegion() { return region == null ? null : region.getName(); }
/** * Returns the region name configured for the default AWS SDK metric collector; * or null if the default is to be used. */ public static String getRegionName() { return region == null ? null : region.getName(); }
public Builder region(Region region) { this.region = region.getName(); return this; }
@Override public String toString() { return getName(); }
@Override public Region getRegion(String regionName) { for (Region region : regions) { if (region.getName().equals(regionName)) { return region; } } return null; }
@Override public int hashCode() { return getName().hashCode(); }
/** * Returns the region configured for the default AWS SDK metric collector; * or null if the default is to be used. * * @throws IllegalArgumentException when using a region not included in * {@link Regions} * * @deprecated Use {@link #getRegionName()} */ public static Regions getRegion() throws IllegalArgumentException { return Regions.fromName(region.getName()); }
private Region cacheRegion(PartitionRegionImpl regionImpl) { final Region region = new Region(regionImpl); regionCache.put(region.getName(), region); return region; }
@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); } }
/** * @deprecated use {@link AmazonS3ClientBuilder#setRegion(String)} */ @Override @Deprecated public synchronized void setRegion(com.amazonaws.regions.Region region) { super.setRegion(region); /* * We need to preserve the user provided region. This is because the * region might be mapped to a global s3 endpoint (e.g. when the client * is in accelerate mode), in which case we won't be able to extract the * region back from the endpoint during request signing phase. */ clientRegion = region.getName(); }
/** * Returns the the KMS region explicitly specified for the AWS KMS client * when such client is internally instantiated; or null if no explicit KMS * region is specified. This KMS region parameter is ignored when the AWS * KMS client of the S3 encryption client is explicitly passed in by the * users, instead of being implicitly created. * * @Deprecated This method is not forward compatible. Throws * IllegalArguementException when a new region is encountered. * * @use {@link #getAwsKmsRegion()} instead */ @Deprecated public Regions getKmsRegion() { if (awskmsRegion == null) return null; return Regions.fromName(awskmsRegion.getName()); }
/** * Sends a request to the AWS Storage Gateway server running at the * specified address, and returns the activation key for that server. * * @param gatewayAddress * The DNS name or IP address of a running AWS Storage Gateway * * @param activationRegionName * The region in which the gateway will be activated. * * @return The activation key required for some API calls to AWS Storage * Gateway. * * @throws AmazonClientException * If any problems are encountered while trying to contact the * remote AWS Storage Gateway server. */ public static String getActivationKey(String gatewayAddress, Region activationRegion) throws AmazonClientException { return getActivationKey(gatewayAddress, activationRegion == null ? null : activationRegion.getName()); }
@Override public URI getServiceEndpoint() { String serviceEndpoint = region.getServiceEndpoint(serviceName); if (serviceEndpoint == null) { serviceEndpoint = String.format("%s.%s.%s", serviceName, region.getName(), region.getDomain()); log.info("{" + serviceName + ", " + region.getName() + "} was not " + "found in region metadata, trying to construct an " + "endpoint using the standard pattern for this region: '" + serviceEndpoint + "'."); } return toURI(stripProtocol(serviceEndpoint)); }
@Override public URI getServiceEndpoint() { String serviceEndpoint = String.format("%s.%s.%s.%s", serviceName, Constants.S3_DUALSTACK_QUALIFIER, region.getName(), region.getDomain()); return toURI(stripProtocol(serviceEndpoint)); }
/** * Returns a client for the requested region, or throws an exception when * unable. * * @param region * The region the returned {@link AmazonS3} will be * configured to use. * @return A client for the given region from the cache, either instantiated * automatically from the provided {@link AWSCredentials} or * provided with {@link #useClient(AmazonS3)}. * @throws IllegalArgumentException * When a region is requested that has not been provided to the * cache with {@link #useClient(AmazonS3)}, and the cache * has no {@link AWSCredentials} with which a client may be * instantiated. */ public AmazonS3 getClient(Region region) { if (region == null) { throw new IllegalArgumentException("S3 region must be specified"); } return getClient(region.toAWSRegion().getName()); }
/** * Returns a {@link TransferManager} for the given region, or throws an * exception when unable. The returned {@link TransferManager} will always * be instantiated from whatever {@link AmazonS3} is in the cache, * whether provided with {@link #useClient(AmazonS3)} or instantiated * automatically from {@link AWSCredentials}. * * Any {@link TransferManager} returned could be shut down if a new * underlying {@link AmazonS3} is provided with * {@link #useClient(AmazonS3)}. * * @param region * The region the returned {@link TransferManager} will be * configured to use. * @return A transfer manager for the given region from the cache, or one * instantiated automatically from any existing * {@link AmazonS3}, */ public TransferManager getTransferManager(Region region) { return getTransferManager(region.toAWSRegion().getName()); }
private static AWSGlueAsync createAsyncGlueClient(GlueHiveMetastoreConfig config) { ClientConfiguration clientConfig = new ClientConfiguration().withMaxConnections(config.getMaxGlueConnections()); AWSGlueAsyncClientBuilder asyncGlueClientBuilder = AWSGlueAsyncClientBuilder.standard() .withClientConfiguration(clientConfig); if (config.getGlueRegion().isPresent()) { asyncGlueClientBuilder.setRegion(config.getGlueRegion().get()); } else if (config.getPinGlueClientToCurrentRegion()) { Region currentRegion = Regions.getCurrentRegion(); if (currentRegion != null) { asyncGlueClientBuilder.setRegion(currentRegion.getName()); } } return asyncGlueClientBuilder.build(); }
Region region = Regions.getCurrentRegion(); if (region != null) { clientBuilder.withRegion(region.getName()); regionOrEndpointSet = true;
Region region = Regions.getCurrentRegion(); if (region != null) { clientBuilder = clientBuilder.withRegion(region.getName()); regionOrEndpointSet = true;