本文整理了Java中com.amazonaws.regions.Regions.getName
方法的一些代码示例,展示了Regions.getName
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Regions.getName
方法的具体详情如下:
包路径:com.amazonaws.regions.Regions
类名称:Regions
方法名:getName
暂无
代码示例来源:origin: aws/aws-sdk-java
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();
}
}
代码示例来源:origin: aws/aws-sdk-java
/**
* 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(Regions region) {
AwsSdkMetrics.region = RegionUtils.getRegion(region.getName());
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Returns the region with the id given, or null if it cannot be found in
* the current regions.xml file.
*/
public static Region getRegion(Regions region) {
return RegionUtils.getRegion(region.getName());
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Returns a region enum corresponding to the given region name.
*
* @param regionName
* The name of the region. Ex.: eu-west-1
* @return Region enum representing the given region name.
*/
public static Regions fromName(String regionName) {
for (Regions region : Regions.values()) {
if (region.getName().equals(regionName)) {
return region;
}
}
throw new IllegalArgumentException("Cannot create enum from " + regionName + " value!");
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Sets the region to be used by the client. This will be used to determine both the
* service endpoint (eg: https://sns.us-west-1.amazonaws.com) and signing region (eg: us-west-1)
* for requests. If neither region or endpoint configuration {@link #setEndpointConfiguration(EndpointConfiguration)}
* are explicitly provided in the builder the {@link #DEFAULT_REGION_PROVIDER} is consulted.
*
* <p> For regions not explicitly in the {@link Regions} enum use the {@link
* #withRegion(String)} overload.</p>
*
* @param region Region to use
* @return This object for method chaining.
*/
public final Subclass withRegion(Regions region) {
return withRegion(region.getName());
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Sets the signing region to be used by the client. This region will <b>NOT</b> be used to compute the endpoint, the endpoint
* must be explicitly provided via the {@link #setEndpoint(URI)} or {@link #withEndpoint(URI)} methods.
*
* <p>
* For regions that are not in the {@link Regions} enum, {@link #setRegion(String)} or {@link #withRegion(String)} should
* be used instead.
* </p>
*
* @param region Region to sign with.
* @return This object for method chaining.
* @see <a href="http://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/java-dg-region-selection.html">AWS Region Selection</a>
*/
public AmazonKinesisVideoPutMediaClientBuilder withRegion(Regions region) {
setRegion(region.getName());
return this;
}
代码示例来源:origin: apache/nifi
protected static AllowableValue createAllowableValue(final Regions region) {
return new AllowableValue(region.getName(), region.getDescription(), "AWS Region Code : " + region.getName());
}
代码示例来源:origin: aws/aws-sdk-java
/**
* If the response doesn't have the x-amz-region header we have to resort to sending a request
* to s3-external-1
*
* @return
*/
private AuthRetryParameters redirectToS3External() {
AWSS3V4Signer v4Signer = buildSigV4Signer(Regions.US_EAST_1.getName());
try {
URI bucketEndpoint = new URI(
String.format("https://%s.s3-external-1.amazonaws.com", endpointResolver.getBucketName()));
return buildRetryParams(v4Signer, bucketEndpoint);
} catch (URISyntaxException e) {
throw new SdkClientException(
"Failed to re-send the request to \"s3-external-1.amazonaws.com\". " + V4_REGION_WARNING, e);
}
}
代码示例来源:origin: aws-amplify/aws-sdk-android
/**
* Determines the logins key for the token.
* This currently varies for cn-north-1 region only.
*
* @return logins key used in the logins map
*/
protected String getLoginsKey() {
if (Regions.CN_NORTH_1.getName().equals(this.region)) {
return "cognito-identity.cn-north-1.amazonaws.com.cn";
} else {
return "cognito-identity.amazonaws.com";
}
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
/**
* 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(Regions region) {
AwsSdkMetrics.region = RegionUtils.getRegion(region.getName());
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
/**
* Returns the region with the id given, or null if it cannot be found in
* the current regions.xml file.
*/
public static Region getRegion(Regions region) {
return RegionUtils.getRegion(region.getName());
}
代码示例来源:origin: aws-amplify/aws-sdk-android
/**
* @param region the region.
* @return the region with the id given, or null if it cannot be found in
* the current regions.xml file.
*/
public static Region getRegion(Regions region) {
return RegionUtils.getRegion(region.getName());
}
代码示例来源:origin: aws-amplify/aws-sdk-android
/**
* Returns a region enum corresponding to the given region name.
*
* @param regionName The name of the region. Ex.: eu-west-1
* @return Region enum representing the given region name.
*/
public static Regions fromName(String regionName) {
for (final Regions region : Regions.values()) {
if (regionName.equals(region.getName())) {
return region;
}
}
throw new IllegalArgumentException("Cannot create enum from " + regionName + " value!");
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
/**
* Sets the region to be used by the client. This will be used to determine both the
* service endpoint (eg: https://sns.us-west-1.amazonaws.com) and signing region (eg: us-west-1)
* for requests. If neither region or endpoint configuration {@link #setEndpointConfiguration(EndpointConfiguration)}
* are explicitly provided in the builder the {@link #DEFAULT_REGION_PROVIDER} is consulted.
*
* <p> For regions not explicitly in the {@link Regions} enum use the {@link
* #withRegion(String)} overload.</p>
*
* @param region Region to use
* @return This object for method chaining.
*/
public final Subclass withRegion(Regions region) {
return withRegion(region.getName());
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
/**
* Returns a region enum corresponding to the given region name.
*
* @param regionName
* The name of the region. Ex.: eu-west-1
* @return Region enum representing the given region name.
*/
public static Regions fromName(String regionName) {
for (Regions region : Regions.values()) {
if (region.getName().equals(regionName)) {
return region;
}
}
throw new IllegalArgumentException("Cannot create enum from " + regionName + " value!");
}
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
public static StreamConnection openS3InputStream(URL url) throws IOException {
S3Params s3Params = S3ParamsExtractor.extract(url);
String region = Objects.nonNull(s3Params.getRegion()) ? s3Params.getRegion() : Regions.US_EAST_1.getName();
return new S3Aws(s3Params, region).getS3AwsInputStream(s3Params);
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testSetRegion() {
final Regions region = Regions.US_WEST_2;
s3.setRegion(Region.getRegion(region));
assertEquals(region.getName(), s3.clientRegion);
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testCreateSigner() {
s3.setS3ClientOptions(accelerateOption);
final Regions region = Regions.US_WEST_2;
s3.setRegion(Region.getRegion(region));
final String bucketName = "bucket";
final String key = "key";
final HttpMethodName method = HttpMethodName.GET;
final GetObjectRequest originalRequest = new GetObjectRequest(bucketName, key);
final Request<?> request = s3.createRequest(bucketName, key, originalRequest, method);
final Signer signer = s3.createSigner(request, bucketName, key);
assertTrue(signer instanceof AWSS3V4Signer);
signer.sign(request, creds);
final String authorization = request.getHeaders().get("Authorization");
assertNotNull(authorization);
final String regionName = authorization.split("/")[2];
assertEquals(region.getName(), regionName);
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testCreateSignerWithSpecialCharacterKeys() {
s3.setS3ClientOptions(accelerateOption);
final Regions region = Regions.US_WEST_2;
s3.setRegion(Region.getRegion(region));
final String bucketName = "bucket";
final String key = "key%^!@#*()";
final HttpMethodName method = HttpMethodName.GET;
final GetObjectRequest originalRequest = new GetObjectRequest(bucketName, key);
final Request<?> request = s3.createRequest(bucketName, key, originalRequest, method);
final Signer signer = s3.createSigner(request, bucketName, key);
assertTrue(signer instanceof AWSS3V4Signer);
signer.sign(request, creds);
final String authorization = request.getHeaders().get("Authorization");
assertNotNull(authorization);
final String regionName = authorization.split("/")[2];
assertEquals(region.getName(), regionName);
assertTrue(request.getResourcePath().contains(key));
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testFromName() {
final Regions usEast1 = Regions.fromName("us-east-1");
assertEquals(usEast1, Regions.US_EAST_1);
final Regions cn1 = Regions.fromName("cn-north-1");
assertEquals(cn1, Regions.CN_NORTH_1);
final Regions govCloud = Regions.fromName("us-gov-west-1");
assertEquals(govCloud, Regions.GovCloud);
assertEquals(usEast1.getName(), "us-east-1");
}
}
内容来源于网络,如有侵权,请联系作者删除!