當前位置: 首頁>>代碼示例>>Java>>正文


Java Region類代碼示例

本文整理匯總了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));
}
 
開發者ID:rpgreen,項目名稱:apigateway-generic-java-sdk,代碼行數:26,代碼來源:GenericApiGatewayClientTest.java

示例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);
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:23,代碼來源:S3RegionalResource.java

示例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;
}
 
開發者ID:shinesolutions,項目名稱:aem-orchestrator,代碼行數:17,代碼來源:AwsConfig.java

示例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();
}
 
開發者ID:shinesolutions,項目名稱:aem-orchestrator,代碼行數:10,代碼來源:AwsConfig.java

示例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();
}
 
開發者ID:sherzberg,項目名稱:graylog-plugin-s3,代碼行數:23,代碼來源:S3Transport.java

示例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;
}
 
開發者ID:pinterest,項目名稱:soundwave,代碼行數:21,代碼來源:EsInstanceStore.java

示例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;
}
 
開發者ID:pinterest,項目名稱:soundwave,代碼行數:26,代碼來源:EsInstanceStore.java

示例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));
        }
    }
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:30,代碼來源:S3RequestEndpointResolver.java

示例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 "";
}
 
開發者ID:faizan-ali,項目名稱:full-javaee-app,代碼行數:18,代碼來源:S3Object.java

示例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());
        }
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:12,代碼來源:S3Client.java

示例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();
}
 
開發者ID:shinesolutions,項目名稱:aem-orchestrator,代碼行數:13,代碼來源:AwsConfig.java

示例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;
}
 
開發者ID:satr,項目名稱:intellij-idea-plugin-connector-for-aws-lambda,代碼行數:13,代碼來源:ConnectorModel.java

示例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();
}
 
開發者ID:shinesolutions,項目名稱:aem-orchestrator,代碼行數:10,代碼來源:AwsConfig.java

示例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();
}
 
開發者ID:shinesolutions,項目名稱:aem-orchestrator,代碼行數:10,代碼來源:AwsConfig.java

示例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();
}
 
開發者ID:shinesolutions,項目名稱:aem-orchestrator,代碼行數:10,代碼來源:AwsConfig.java


注:本文中的com.amazonaws.regions.Region類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。