本文整理了Java中com.amazonaws.services.s3.model.Region.fromValue
方法的一些代码示例,展示了Region.fromValue
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Region.fromValue
方法的具体详情如下:
包路径:com.amazonaws.services.s3.model.Region
类名称:Region
方法名:fromValue
[英]Returns the Amazon S3 Region enumeration value representing the specified Amazon S3 Region ID string. If specified string doesn't map to a known Amazon S3 Region, then an IllegalArgumentException
is thrown.
[中]返回表示指定Amazon S3区域ID字符串的Amazon S3区域枚举值。如果指定的字符串没有映射到已知的Amazon S3区域,则会抛出IllegalArgumentException
。
代码示例来源:origin: aws/aws-sdk-java
@Override
public synchronized Region getRegion() {
String authority = super.endpoint.getAuthority();
if (Constants.S3_HOSTNAME.equals(authority)) {
return Region.US_Standard;
} else {
Matcher m = Region.S3_REGIONAL_ENDPOINT_PATTERN.matcher(authority);
if (m.matches()) {
return Region.fromValue(m.group(1));
} else {
throw new IllegalStateException(
"S3 client with invalid S3 endpoint configured: " + authority);
}
}
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Returns the S3 region in {@link Region} format.
* <p>
* Do not use this method if {@link S3Link} is created with a region not in {@link Region} enum.
* Use {@link #getRegion()} instead.
* </p>
*
* @return S3 region.
*/
public Region getS3Region() {
return Region.fromValue(getRegion());
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Override
public Region getRegion() {
final String authority = super.endpoint.getAuthority();
if (Constants.S3_HOSTNAME.equals(authority)) {
return Region.US_Standard;
}
final Matcher m = Region.S3_REGIONAL_ENDPOINT_PATTERN.matcher(authority);
if (m.matches()) {
return Region.fromValue(m.group(1));
} else {
throw new IllegalStateException("S3 client with invalid S3 endpoint configured");
}
}
代码示例来源:origin: aws-amplify/aws-sdk-android
public Region getS3Region() {
return Region.fromValue(id.getRegionId());
}
代码示例来源:origin: aws-amplify/aws-sdk-android
/**
* Tests if correct enums are returned when the location constraints are
* passed to fromValue method.
*/
@Test
public void testFromValueForOthers() {
assertEquals(Region.EU_Ireland, Region.fromValue("eu-west-1"));
assertEquals(Region.EU_Ireland, Region.fromValue("EU"));
assertEquals(Region.US_GovCloud, Region.fromValue("s3-us-gov-west-1"));
}
代码示例来源:origin: aws-amplify/aws-sdk-android
/**
* Tests if US Standard Enum is returned in cases where empty string or "US"
* is passed to fromValue method.
*/
@Test
public void testFromValueForUSStandard() {
assertEquals(Region.US_Standard, Region.fromValue(null));
assertEquals(Region.US_Standard, Region.fromValue("US"));
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void fromValue_usEast1String_ReturnsUsStandard() {
assertEquals(Region.US_Standard, Region.fromValue("us-east-1"));
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testRegionEnumeration() {
assertEquals(Region.EU_Ireland, Region.fromValue(Region.EU_Ireland.toString()));
assertEquals(Region.US_Standard, Region.fromValue(Region.US_Standard.toString()));
}
代码示例来源:origin: aws-amplify/aws-sdk-android
static ID fromJson(String json) throws IOException {
String bucket = null;
String key = null;
String regionId = null;
final AwsJsonReader reader = JsonUtils.getJsonReader(new StringReader(json));
reader.beginObject();
reader.nextName(); // get to "s3"
reader.beginObject();
while (reader.hasNext()) {
final String name = reader.nextName();
if ("bucket".equals(name)) {
bucket = reader.nextString();
} else if ("key".equals(name)) {
key = reader.nextString();
} else if ("region".equals(name)) {
regionId = reader.nextString();
} else {
// skip unknown value
reader.skipValue();
}
}
reader.endObject();
reader.endObject();
final Region region = regionId == null ? null : Region.fromValue(regionId);
return new ID(region, bucket, key);
}
}
代码示例来源:origin: HotelsDotCom/circus-train
void setRegion(String region) {
Region.fromValue(region);
this.region = region;
}
代码示例来源:origin: com.hotels/circus-train-s3-mapreduce-cp
void setRegion(String region) {
Region.fromValue(region);
this.region = region;
}
代码示例来源:origin: com.amazonaws/aws-android-sdk-s3
@Override
public Region getRegion() {
final String authority = super.endpoint.getAuthority();
if (Constants.S3_HOSTNAME.equals(authority)) {
return Region.US_Standard;
}
final Matcher m = Region.S3_REGIONAL_ENDPOINT_PATTERN.matcher(authority);
if (m.matches()) {
return Region.fromValue(m.group(1));
} else {
throw new IllegalStateException("S3 client with invalid S3 endpoint configured");
}
}
代码示例来源:origin: Nextdoor/bender
@Override
public synchronized Region getRegion() {
String authority = super.endpoint.getAuthority();
if (Constants.S3_HOSTNAME.equals(authority)) {
return Region.US_Standard;
} else {
Matcher m = Region.S3_REGIONAL_ENDPOINT_PATTERN.matcher(authority);
if (m.matches()) {
return Region.fromValue(m.group(1));
} else {
throw new IllegalStateException(
"S3 client with invalid S3 endpoint configured: " + authority);
}
}
}
代码示例来源:origin: classmethod/gradle-aws-plugin
private String getAwsRegionName(final String region) {
try {
return Region.fromValue(region).toString();
} catch (IllegalArgumentException e) {
throw new GradleException(e.getMessage(), e);
}
}
代码示例来源:origin: HotelsDotCom/circus-train
@Override
public void validate(String name, String value) throws ParameterException {
try {
Region.fromValue(value);
} catch (IllegalArgumentException e) {
throw new ParameterException("Parameter " + name + " is not a valid AWS region (found " + value + ")", e);
}
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-dynamodb
/**
* Returns the S3 region in {@link Region} format.
* <p>
* Do not use this method if {@link S3Link} is created with a region not in {@link Region} enum.
* Use {@link #getRegion()} instead.
* </p>
*
* @return S3 region.
*/
public Region getS3Region() {
return Region.fromValue(getRegion());
}
代码示例来源:origin: com.hotels/circus-train-s3-mapreduce-cp
@Override
public void validate(String name, String value) throws ParameterException {
try {
Region.fromValue(value);
} catch (IllegalArgumentException e) {
throw new ParameterException("Parameter " + name + " is not a valid AWS region (found " + value + ")", e);
}
}
代码示例来源: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: HotelsDotCom/circus-train
private String regionForUri(AmazonS3 client, AmazonS3URI uri) {
String bucketRegion = client.getBucketLocation(uri.getBucket());
Region region = Region.fromValue(bucketRegion);
// S3 doesn't have a US East 1 region, US East 1 is really the region
// US Standard. US Standard places the data in either an east coast
// or west coast data center geographically closest to you.
// SigV4 requires you to mention a region while signing a request
// and for the S3's US standard endpoints the value to be used is "us-east-1"
// US West 1 has an endpoint and so is treated as a stand alone region,
// US East 1 doesn't and so is bundled into US Standard
if (region.equals(Region.US_Standard)) {
bucketRegion = "us-east-1";
} else {
bucketRegion = region.toString();
}
return bucketRegion;
}
代码示例来源:origin: com.hotels/circus-train-s3-s3-copier
private String regionForUri(AmazonS3 client, AmazonS3URI uri) {
String bucketRegion = client.getBucketLocation(uri.getBucket());
Region region = Region.fromValue(bucketRegion);
// S3 doesn't have a US East 1 region, US East 1 is really the region
// US Standard. US Standard places the data in either an east coast
// or west coast data center geographically closest to you.
// SigV4 requires you to mention a region while signing a request
// and for the S3's US standard endpoints the value to be used is "us-east-1"
// US West 1 has an endpoint and so is treated as a stand alone region,
// US East 1 doesn't and so is bundled into US Standard
if (region.equals(Region.US_Standard)) {
bucketRegion = "us-east-1";
} else {
bucketRegion = region.toString();
}
return bucketRegion;
}
内容来源于网络,如有侵权,请联系作者删除!