本文整理汇总了Java中com.amazonaws.regions.Region类的典型用法代码示例。如果您正苦于以下问题:Java Region类的具体用法?Java Region怎么用?Java Region使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Region类属于com.amazonaws.regions包,在下文中一共展示了Region类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExecute_noApiKey_noCreds
import com.amazonaws.regions.Region; //导入依赖的package包/类
@Test
public void testExecute_noApiKey_noCreds() throws IOException {
client = new GenericApiGatewayClientBuilder()
.withEndpoint("https://foobar.execute-api.us-east-1.amazonaws.com")
.withRegion(Region.getRegion(Regions.fromName("us-east-1")))
.withClientConfiguration(new ClientConfiguration())
.withHttpClient(new AmazonHttpClient(new ClientConfiguration(), mockClient, null))
.build();
GenericApiGatewayResponse response = client.execute(
new GenericApiGatewayRequestBuilder()
.withBody(new ByteArrayInputStream("test request".getBytes()))
.withHttpMethod(HttpMethodName.POST)
.withResourcePath("/test/orders").build());
assertEquals("Wrong response body", "test payload", response.getBody());
assertEquals("Wrong response status", 200, response.getHttpResponse().getStatusCode());
Mockito.verify(mockClient, times(1)).execute(argThat(new LambdaMatcher<>(
x -> (x.getMethod().equals("POST")
&& x.getFirstHeader("x-api-key") == null
&& x.getFirstHeader("Authorization") == null
&& x.getURI().toString().equals("https://foobar.execute-api.us-east-1.amazonaws.com/test/orders")))),
any(HttpContext.class));
}
示例2: configure
import com.amazonaws.regions.Region; //导入依赖的package包/类
private void configure() {
Matcher matcher = REGIONAL_ENDPOINT_PATTERN.matcher(uri.toString());
if (matcher.find()) {
String bucketName = matcher.group(1);
String region = matcher.group(2);
String key = matcher.group(4);
Region derivedRegion;
if (region.equals("external-1")) {
derivedRegion = Region.getRegion(Regions.US_EAST_1);
} else {
derivedRegion = RegionUtils.getRegion(region);
}
this.region = Optional.of(derivedRegion);
this.bucketName = bucketName;
this.key = key;
} else {
this.region = Optional.absent();
this.bucketName = getBucketName(uri.getHost());
this.key = getS3BucketKey(uri);
}
}
示例3: awsRegion
import com.amazonaws.regions.Region; //导入依赖的package包/类
@Bean
public Region awsRegion() {
Region region;
if(regionString != null && !regionString.isEmpty()) {
region = RegionUtils.getRegion(regionString);
} else {
AwsRegionProvider regionProvider = new DefaultAwsRegionProviderChain();
region = RegionUtils.getRegion(regionProvider.getRegion());
}
if(region == null) {
throw new BeanInitializationException("Unable to determine AWS region");
}
return region;
}
示例4: amazonCloudWatchClient
import com.amazonaws.regions.Region; //导入依赖的package包/类
@Bean
public AmazonCloudWatch amazonCloudWatchClient(final AWSCredentialsProvider awsCredentialsProvider,
final ClientConfiguration awsClientConfig, final Region awsRegion) {
return AmazonCloudWatchClientBuilder.standard()
.withCredentials(awsCredentialsProvider)
.withClientConfiguration(awsClientConfig)
.withRegion(awsRegion.getName())
.build();
}
示例5: doLaunch
import com.amazonaws.regions.Region; //导入依赖的package包/类
@Override
public void doLaunch(MessageInput input) throws MisfireException {
serverStatus.awaitRunning(() -> lifecycleStateChange(Lifecycle.RUNNING));
LOG.info("Starting s3 subscriber");
final String legacyRegionName = input.getConfiguration().getString(CK_LEGACY_AWS_REGION, DEFAULT_REGION.getName());
final String sqsRegionName = input.getConfiguration().getString(CK_AWS_SQS_REGION, legacyRegionName);
final String s3RegionName = input.getConfiguration().getString(CK_AWS_S3_REGION, legacyRegionName);
subscriber = new S3Subscriber(
Region.getRegion(Regions.fromName(sqsRegionName)),
Region.getRegion(Regions.fromName(s3RegionName)),
input.getConfiguration().getString(CK_SQS_NAME),
input,
input.getConfiguration().getString(CK_ACCESS_KEY),
input.getConfiguration().getString(CK_SECRET_KEY),
input.getConfiguration().getInt(CK_THREAD_COUNT)
);
subscriber.start();
}
示例6: getRunningInstances
import com.amazonaws.regions.Region; //导入依赖的package包/类
@Override
public Iterator<EsInstance> getRunningInstances(Region region, String[] fields) throws Exception {
Preconditions.checkNotNull(region);
//state eq running and in the specificied region
QueryBuilder queryBuilder = QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("state", "running"))
.must(QueryBuilders.termQuery("region", region.getName().toLowerCase()));
ScrollableResponse<List<EsInstance>> response = this.retrieveScrollByQuery(queryBuilder,
fields, BATCHSIZE,
str -> (EsInstance) insertMapper.readValue(str, getInstanceClass()));
EsIterator<EsInstance>
iterator =
new EsIterator<>(response, r -> scrollNext(r.getContinousToken(),
str -> (EsInstance) insertMapper.readValue(str, getInstanceClass())));
return iterator;
}
示例7: getRecentlyTerminatedInstances
import com.amazonaws.regions.Region; //导入依赖的package包/类
@Override
public Iterator<EsInstance> getRecentlyTerminatedInstances(Region region,
int days) throws Exception {
Preconditions.checkNotNull(region);
Preconditions.checkArgument(days > 0);
DateTime start = getStartSinceDay(days);
QueryBuilder queryBuilder = QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("region", region.getName().toLowerCase()))
.must(QueryBuilders.termQuery("state", "terminated"))
.must(QueryBuilders.rangeQuery("aws_launch_time").gte(start));
ScrollableResponse<List<EsInstance>> response = this.retrieveScrollByQuery(queryBuilder,
EsMapper.getIncludeFields(getInstanceClass()), BATCHSIZE,
str -> (EsInstance) insertMapper.readValue(str, getInstanceClass()));
EsIterator<EsInstance>
iterator =
new EsIterator<>(response, r -> scrollNext(r.getContinousToken(),
str -> (EsInstance) insertMapper.readValue(str, getInstanceClass())));
return iterator;
}
示例8: resolveRequestEndpoint
import com.amazonaws.regions.Region; //导入依赖的package包/类
/**
* Set the request's endpoint and resource path with the new region provided
*
* @param request Request to set endpoint for
* @param regionString New region to determine endpoint to hit
*/
public void resolveRequestEndpoint(Request<?> request, String regionString) {
if (regionString != null) {
final Region r = RegionUtils.getRegion(regionString);
if (r == null) {
throw new SdkClientException("Not able to determine region" +
" for " + regionString + ".Please upgrade to a newer " +
"version of the SDK");
}
endpointBuilder.withRegion(r);
}
final URI endpoint = endpointBuilder.getServiceEndpoint();
if (shouldUseVirtualAddressing(endpoint)) {
request.setEndpoint(convertToVirtualHostEndpoint(endpoint, bucketName));
request.setResourcePath(SdkHttpUtils.urlEncode(getHostStyleResourcePath(), true));
} else {
request.setEndpoint(endpoint);
if (bucketName != null) {
request.setResourcePath(SdkHttpUtils.urlEncode(getPathStyleResourcePath(), true));
}
}
}
示例9: webHookDump
import com.amazonaws.regions.Region; //导入依赖的package包/类
public static String webHookDump(InputStream stream, String school, String extension) {
if (stream != null) {
extension = extension == null || extension.isEmpty() ? ".xml" : extension.contains(".") ? extension : "." + extension;
String fileName = "webhooks/" + school + "/" + school + "_" + Clock.getCurrentDateDashes() + "_" + Clock.getCurrentTime() + extension;
AmazonS3 s3 = new AmazonS3Client();
Region region = Region.getRegion(Regions.US_WEST_2);
s3.setRegion(region);
try {
File file = CustomUtilities.inputStreamToFile(stream);
s3.putObject(new PutObjectRequest(name, fileName, file));
return CustomUtilities.fileToString(file);
} catch (Exception e) {
e.printStackTrace();
}
}
return "";
}
示例10: configureClient
import com.amazonaws.regions.Region; //导入依赖的package包/类
private void configureClient(S3RegionalResource s3RegionalResource) {
Optional<URI> endpoint = s3ConnectionProperties.getEndpoint();
if (endpoint.isPresent()) {
amazonS3Client.setEndpoint(endpoint.get().toString());
} else {
Optional<Region> region = s3RegionalResource.getRegion();
if (region.isPresent()) {
amazonS3Client.setRegion(region.get());
}
}
}
示例11: sqsConnection
import com.amazonaws.regions.Region; //导入依赖的package包/类
@Bean
public SQSConnection sqsConnection(final AWSCredentialsProvider awsCredentialsProvider,
final ClientConfiguration awsClientConfig, final Region awsRegion) throws JMSException {
SQSConnectionFactory connectionFactory = SQSConnectionFactory.builder()
.withRegion(awsRegion) //Gets region form meta data
.withAWSCredentialsProvider(awsCredentialsProvider)
.withClientConfiguration(awsClientConfig)
.build();
return connectionFactory.createConnection();
}
示例12: getRegions
import com.amazonaws.regions.Region; //导入依赖的package包/类
public List<RegionEntry> getRegions() {
if(regionEntries != null)
return regionEntries;
regionEntries = new ArrayList<>();
for(Region region : RegionUtils.getRegions()) {
String description = regionDescriptions.get(region.getName());
if(description != null)
regionEntries.add(new RegionEntry(region, description));
}
return regionEntries;
}
示例13: amazonElbClient
import com.amazonaws.regions.Region; //导入依赖的package包/类
@Bean
public AmazonElasticLoadBalancing amazonElbClient(final AWSCredentialsProvider awsCredentialsProvider,
final ClientConfiguration awsClientConfig, final Region awsRegion) {
return AmazonElasticLoadBalancingClientBuilder.standard()
.withCredentials(awsCredentialsProvider)
.withClientConfiguration(awsClientConfig)
.withRegion(awsRegion.getName())
.build();
}
示例14: amazonCloudFormationClient
import com.amazonaws.regions.Region; //导入依赖的package包/类
@Bean
public AmazonCloudFormation amazonCloudFormationClient(final AWSCredentialsProvider awsCredentialsProvider,
final ClientConfiguration awsClientConfig, final Region awsRegion) {
return AmazonCloudFormationClientBuilder.standard()
.withCredentials(awsCredentialsProvider)
.withClientConfiguration(awsClientConfig)
.withRegion(awsRegion.getName())
.build();
}
示例15: amazonS3Client
import com.amazonaws.regions.Region; //导入依赖的package包/类
@Bean
public AmazonS3 amazonS3Client(final AWSCredentialsProvider awsCredentialsProvider,
final ClientConfiguration awsClientConfig, final Region awsRegion) {
return AmazonS3ClientBuilder.standard()
.withCredentials(awsCredentialsProvider)
.withClientConfiguration(awsClientConfig)
.withRegion(awsRegion.getName())
.build();
}