com.amazonaws.regions.Regions.valueOf()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中com.amazonaws.regions.Regions.valueOf方法的一些代码示例,展示了Regions.valueOf的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Regions.valueOf方法的具体详情如下:
包路径:com.amazonaws.regions.Regions
类名称:Regions
方法名:valueOf

Regions.valueOf介绍

暂无

代码示例

代码示例来源:origin: org.apache.oodt/cas-filemgr

@Override
 public S3DataTransferer createDataTransfer() {
    String bucketName = System.getProperty(BUCKET_NAME_PROPERTY);
    String region = System.getProperty(REGION_PROPERTY);        
    String accessKey = System.getProperty(ACCESS_KEY_PROPERTY);
  String secretKey = System.getProperty(SECRET_KEY_PROPERTY);
  boolean encrypt = Boolean.getBoolean(ENCRYPT_PROPERTY);

    AmazonS3Client s3 = new AmazonS3Client(new BasicAWSCredentials(accessKey, secretKey));
  s3.setRegion(Region.getRegion(Regions.valueOf(region)));

  return new S3DataTransferer(s3, bucketName, encrypt);
 }
}

代码示例来源:origin: LendingClub/mercator

public static ArnGenerator newInstance(String account, String region) {
  region=region.toUpperCase().replace("-", "_");
  return newInstance(account, Region.getRegion(Regions.valueOf(region)));
}
public static ArnGenerator newInstance(String account, Regions region) {

代码示例来源:origin: org.geotools/gt-s3-geotiff

private static AmazonS3 getS3Client() {
  Regions region;
  if (System.getProperty("AWS_REGION") != null) {
    try {
      region = Regions.valueOf(System.getProperty("AWS_REGION"));
    } catch (IllegalArgumentException e) {
      // probably not great to have a default, but we can't just blow up if this
      // property isn't set
      LOGGER.warning(
          "AWS_REGION property is set, but not set correctly. "
              + "Check that the AWS_REGION property matches the Regions enum");
      region = Regions.US_EAST_1;
    }
  } else {
    LOGGER.warning("No AWS_REGION property set, defaulting to US_EAST_1");
    region = Regions.US_EAST_1;
  }
  AmazonS3 s3;
  if (Boolean.getBoolean("S3_USE_ANON")) {
    s3 = new AmazonS3Client(new AnonymousAWSCredentials());
  } else {
    s3 = new AmazonS3Client();
  }
  s3.setRegion(Region.getRegion(region));
  return s3;
}

代码示例来源:origin: org.geotools/gt-s3-geotiff

if (this.regionString != null) {
  try {
    region = Regions.valueOf(regionString);
  } catch (IllegalArgumentException e) {

代码示例来源:origin: io.konig/konig-camel-aws-s3

@Override
  protected Result verifyConnectivity(Map<String, Object> parameters) {
    ResultBuilder builder = ResultBuilder.withStatusAndScope(Result.Status.OK, Scope.CONNECTIVITY);

    try {
      S3Configuration configuration = setProperties(new S3Configuration(), parameters);
      AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
      AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
      AmazonS3 client = AmazonS3ClientBuilder.standard().withCredentials(credentialsProvider).withRegion(Regions.valueOf(configuration.getRegion())).build();
      client.listBuckets();
    } catch (SdkClientException e) {
      ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getMessage())
        .detail("aws_s3_exception_message", e.getMessage()).detail(VerificationError.ExceptionAttribute.EXCEPTION_CLASS, e.getClass().getName())
        .detail(VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE, e);

      builder.error(errorBuilder.build());
    } catch (Exception e) {
      builder.error(ResultErrorBuilder.withException(e).build());
    }
    return builder.build();
  }
}

代码示例来源:origin: io.konig/konig-camel-aws-s3

@Override
  protected Result verifyConnectivity(Map<String, Object> parameters) {
    ResultBuilder builder = ResultBuilder.withStatusAndScope(Result.Status.OK, Scope.CONNECTIVITY);

    try {
      S3Configuration configuration = setProperties(new S3Configuration(), parameters);
      AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
      AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
      AmazonS3 client = AmazonS3ClientBuilder.standard().withCredentials(credentialsProvider).withRegion(Regions.valueOf(configuration.getRegion())).build();
      client.listBuckets();
    } catch (SdkClientException e) {
      ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getMessage())
        .detail("aws_s3_exception_message", e.getMessage()).detail(VerificationError.ExceptionAttribute.EXCEPTION_CLASS, e.getClass().getName())
        .detail(VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE, e);

      builder.error(errorBuilder.build());
    } catch (Exception e) {
      builder.error(ResultErrorBuilder.withException(e).build());
    }
    return builder.build();
  }
}

代码示例来源:origin: io.syndesis/aws-s3-connector

@Override
  @SuppressWarnings("PMD.AvoidCatchingGenericException") 
  protected Result verifyConnectivity(Map<String, Object> parameters) {
    ResultBuilder builder = ResultBuilder.withStatusAndScope(Result.Status.OK, Scope.CONNECTIVITY);

    try {
      S3Configuration configuration = setProperties(new S3Configuration(), parameters);
      AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
      AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
      AmazonS3 client = AmazonS3ClientBuilder.standard().withCredentials(credentialsProvider).withRegion(Regions.valueOf(configuration.getRegion())).build();
      client.listBuckets();
    } catch (SdkClientException e) {
      ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getMessage())
        .detail("aws_s3_exception_message", e.getMessage()).detail(VerificationError.ExceptionAttribute.EXCEPTION_CLASS, e.getClass().getName())
        .detail(VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE, e);

      builder.error(errorBuilder.build());
    } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") Exception e) {
      builder.error(ResultErrorBuilder.withException(e).build());
    }
    return builder.build();
  }
}

代码示例来源:origin: io.konig/konig-camel-aws-s3

clientBuilder = clientBuilder.withRegion(Regions.valueOf(configuration.getRegion()));
} else {
  if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
    encClientBuilder = encClientBuilder.withRegion(Regions.valueOf(configuration.getRegion()));

代码示例来源:origin: io.konig/konig-camel-aws-s3

clientBuilder = clientBuilder.withRegion(Regions.valueOf(configuration.getRegion()));
} else {
  if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
    encClientBuilder = encClientBuilder.withRegion(Regions.valueOf(configuration.getRegion()));
    clientBuilder = clientBuilder.withRegion(Regions.valueOf(configuration.getRegion()));
} else {
  if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
    encClientBuilder = encClientBuilder.withRegion(Regions.valueOf(configuration.getRegion()));

相关文章