本文整理了Java中com.amazonaws.services.s3.model.Region.toAWSRegion
方法的一些代码示例,展示了Region.toAWSRegion
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Region.toAWSRegion
方法的具体详情如下:
包路径:com.amazonaws.services.s3.model.Region
类名称:Region
方法名:toAWSRegion
[英]Returns the respective AWS region.
[中]返回相应的AWS区域。
代码示例来源:origin: aws/aws-sdk-java
/**
* 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());
}
代码示例来源:origin: aws/aws-sdk-java
/**
* 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());
}
代码示例来源:origin: aws/aws-sdk-java
private ServiceEndpointBuilder getBuilder(URI endpoint, String protocol, boolean useDefaultBuilder) {
if(clientOptions.isDualstackEnabled() && !clientOptions.isAccelerateModeEnabled()) {
return new DualstackEndpointBuilder(getServiceNameIntern(), protocol, getRegion().toAWSRegion());
} else {
if(useDefaultBuilder) {
return new DefaultServiceEndpointBuilder(getServiceName(), protocol);
} else {
return new IdentityEndpointBuilder(endpoint);
}
}
}
代码示例来源:origin: aws-amplify/aws-sdk-android
client = new AmazonS3Client(credentials);
client.setRegion(s3region.toAWSRegion());
final AmazonS3Client prev = clientsByRegion.putIfAbsent(s3region, client);
return prev == null ? client : prev;
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void toAWSRegion_UsStandard_ReturnsUsEast1Region() {
assertEquals("us-east-1", Region.US_Standard.toAWSRegion().getName());
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-aws-core
@Override
public URL getURL() throws IOException {
Region region = this.amazonS3.getRegion().toAWSRegion();
return new URL("https", region.getServiceEndpoint(AmazonS3Client.S3_SERVICE_NAME), "/" + this.bucketName + "/" + this.objectName);
}
代码示例来源:origin: spring-cloud/spring-cloud-aws
@Override
public URL getURL() throws IOException {
Region region = this.amazonS3.getRegion().toAWSRegion();
return new URL("https", region.getServiceEndpoint(AmazonS3Client.S3_SERVICE_NAME), "/" + this.bucketName + "/" + this.objectName);
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-dynamodb
/**
* 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());
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-dynamodb
/**
* 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());
}
代码示例来源:origin: dremio/dremio-oss
@Override
public FileSystem create() throws IOException {
final String bucketRegion = s3.getBucketLocation(bucketName);
final String projectedBucketEndPoint = "s3." + bucketRegion + ".amazonaws.com";
String regionEndPoint = projectedBucketEndPoint;
try {
Region region = Region.fromValue(bucketRegion);
com.amazonaws.regions.Region awsRegion = region.toAWSRegion();
if (awsRegion != null) {
regionEndPoint = awsRegion.getServiceEndpoint("s3");
}
} catch (IllegalArgumentException iae) {
// try heuristic mapping if not found
regionEndPoint = projectedBucketEndPoint;
logger.warn("Unknown or unmapped region {} for bucket {}. Will use following fs.s3a.endpoint: {}",
bucketRegion, bucketName, regionEndPoint);
}
// it could be null because no mapping from Region to aws region or there is no such region is the map of endpoints
// not sure if latter is possible
if (regionEndPoint == null) {
logger.error("Could not get AWSRegion for bucket {}. Will use following fs.s3a.endpoint: " + "{} ",
bucketName, projectedBucketEndPoint);
}
String location = S3_URI_SCHEMA + bucketName + "/";
final Configuration bucketConf = new Configuration(parentConf);
bucketConf.set(ENDPOINT, (regionEndPoint != null) ? regionEndPoint : projectedBucketEndPoint);
FileSystem.setDefaultUri(bucketConf, new Path(location).toUri());
return FileSystem.get(bucketConf);
}
});
代码示例来源:origin: org.duracloud/s3storageprovider
public static AmazonS3Client getAmazonS3Client(String accessKey,
String secretKey,
Map<String, String> options) {
AmazonS3Client client = s3Clients.get(key(accessKey, secretKey));
if (null == client) {
Region region = null;
if (options != null && options.get(StorageAccount.OPTS.AWS_REGION.name()) != null) {
region = com.amazonaws.services.s3.model.Region.fromValue(
options.get(StorageAccount.OPTS.AWS_REGION.name())).toAWSRegion();
}
client = newS3Client(accessKey, secretKey, region);
s3Clients.put(key(accessKey, secretKey), client);
}
return client;
}
代码示例来源:origin: tmobile/pacbot
try{
String bucketLocation = amazonS3Client.getBucketLocation(bucket.getName());
bucketRegion = com.amazonaws.services.s3.model.Region.fromValue(bucketLocation).toAWSRegion().getName();
AmazonS3 s3Client = regionS3map.get(bucketRegion);
versionconfig = s3Client.getBucketVersioningConfiguration(bucket.getName());
代码示例来源:origin: Nextdoor/bender
private ServiceEndpointBuilder getBuilder(URI endpoint, String protocol, boolean useDefaultBuilder) {
if(clientOptions.isDualstackEnabled() && !clientOptions.isAccelerateModeEnabled()) {
return new DualstackEndpointBuilder(getServiceNameIntern(), protocol, getRegion().toAWSRegion());
} else {
if(useDefaultBuilder) {
return new DefaultServiceEndpointBuilder(getServiceName(), protocol);
} else {
return new IdentityEndpointBuilder(endpoint);
}
}
}
代码示例来源:origin: pentaho/big-data-plugin
@Override
public PricingClient createClient( String accessKey, String secretKey, String region ) {
AmazonClientCredentials clientCredentials = new AmazonClientCredentials( accessKey, secretKey, region );
AWSPricing awsPricingClient =
AWSPricingAsyncClientBuilder.standard().withRegion( Region.US_Standard.toAWSRegion().getName() )
.withCredentials( new AWSStaticCredentialsProvider( clientCredentials.getAWSCredentials() ) ).build();
PricingClient pricingClient = new PricingClientImpl( awsPricingClient, region );
return pricingClient;
}
}
内容来源于网络,如有侵权,请联系作者删除!