software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient Java Examples

The following examples show how to use software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApplicationModule.java    From realworld-serverless-application with Apache License 2.0 5 votes vote down vote up
@Singleton
@Inject
@Provides
SsmParameterCachingClient ssmParameterCachingClient() {
  String path = String.format("/applications/apprepo/%s/", System.getProperty("integtests.stage"));
  return new SsmParameterCachingClient(SsmClient.builder()
      .httpClientBuilder(UrlConnectionHttpClient.builder())
      .build(),
      Duration.ofMinutes(5), path);
}
 
Example #2
Source File: ApplicationModule.java    From realworld-serverless-application with Apache License 2.0 5 votes vote down vote up
@Singleton
@Inject
@Provides
CognitoUserManager cognitoUserManager(final SsmParameterCachingClient ssm) {
  String clientId = ssm.getAsString("cognito/userpoolclient/IntegTest/Id");
  String userPoolId = ssm.getAsString("cognito/userpool/ApplicationsApi/Id");
  return new CognitoUserManager(CognitoIdentityProviderClient.builder()
      .httpClientBuilder(UrlConnectionHttpClient.builder())
      .build(), clientId, userPoolId);
}
 
Example #3
Source File: ApplicationModule.java    From realworld-serverless-application with Apache License 2.0 5 votes vote down vote up
@Singleton
@Inject
@Provides
AthenaClient athenaClient(){
  return AthenaClient.builder()
      .httpClientBuilder(UrlConnectionHttpClient.builder())
      .build();
}
 
Example #4
Source File: ApplicationModule.java    From realworld-serverless-application with Apache License 2.0 5 votes vote down vote up
@Singleton
@Inject
@Provides
S3Client s3Client(){
  return S3Client.builder()
      .httpClientBuilder(UrlConnectionHttpClient.builder())
      .build();
}
 
Example #5
Source File: ApplicationModule.java    From realworld-serverless-application with Apache License 2.0 5 votes vote down vote up
@Singleton
@Inject
@Provides
SsmParameterCachingClient ssmParameterCachingClient() {
  String path = String.format("/applications/apprepo/%s/", System.getProperty("integtests.stage"));
  return new SsmParameterCachingClient(SsmClient.builder()
        .httpClientBuilder(UrlConnectionHttpClient.builder())
        .build(),
        Duration.ofMinutes(5), path);
}
 
Example #6
Source File: ApplicationModule.java    From realworld-serverless-application with Apache License 2.0 5 votes vote down vote up
@Singleton
@Inject
@Provides
CognitoUserManager cognitoUserManager(final SsmParameterCachingClient ssm) {
  String clientId = ssm.getAsString(String.format(
          "cognito/userpoolclient/IntegTest/realworld-serverless-application-backend-%s-env/Id",
          System.getProperty("integtests.stage")));
  String userPoolId = ssm.getAsString("cognito/userpool/ApplicationsApi/Id");
  return new CognitoUserManager(CognitoIdentityProviderClient.builder()
        .httpClientBuilder(UrlConnectionHttpClient.builder())
        .build(), clientId, userPoolId);
}
 
Example #7
Source File: KmsResource.java    From quarkus-quickstarts with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, String> start() {
    DockerClientFactory.instance().client();
    String masterKeyId;
    try {
        services = new KmsContainer();
        services.start();
        StaticCredentialsProvider staticCredentials = StaticCredentialsProvider
            .create(AwsBasicCredentials.create("accesskey", "secretKey"));

        client = KmsClient.builder()
            .endpointOverride(new URI(endpoint()))
            .credentialsProvider(staticCredentials)
            .httpClientBuilder(UrlConnectionHttpClient.builder())
            .region(Region.US_EAST_1).build();

        masterKeyId = client.createKey().keyMetadata().keyId();
        client.generateDataKey(r -> r.keyId(masterKeyId).keySpec(DataKeySpec.AES_256));

    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException("Could not start localstack server", e);
    }

    Map<String, String> properties = new HashMap<>();
    properties.put("quarkus.kms.endpoint-override", endpoint());
    properties.put("quarkus.kms.aws.region", "us-east-1");
    properties.put("quarkus.kms.aws.credentials.type", "static");
    properties.put("quarkus.kms.aws.credentials.static-provider.access-key-id", "accessKey");
    properties.put("quarkus.kms.aws.credentials.static-provider.secret-access-key", "secretKey");
    properties.put("key.arn", masterKeyId);

    return properties;
}
 
Example #8
Source File: SnsResource.java    From quarkus-quickstarts with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, String> start() {
    DockerClientFactory.instance().client();
    String topicArn;
    try {
        services = new LocalStackContainer("0.11.1").withServices(Service.SNS);
        services.start();
        StaticCredentialsProvider staticCredentials = StaticCredentialsProvider
            .create(AwsBasicCredentials.create("accesskey", "secretKey"));

        client = SnsClient.builder()
            .endpointOverride(new URI(endpoint()))
            .credentialsProvider(staticCredentials)
            .httpClientBuilder(UrlConnectionHttpClient.builder())
            .region(Region.US_EAST_1).build();

        topicArn = client.createTopic(t -> t.name(TOPIC_NAME)).topicArn();
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException("Could not start ocalstack server", e);
    }

    Map<String, String> properties = new HashMap<>();
    properties.put("quarkus.sns.endpoint-override", endpoint());
    properties.put("quarkus.sns.aws.region", "us-east-1");
    properties.put("quarkus.sns.aws.credentials.type", "static");
    properties.put("quarkus.sns.aws.credentials.static-provider.access-key-id", "accessKey");
    properties.put("quarkus.sns.aws.credentials.static-provider.secret-access-key", "secretKey");
    properties.put("topic.arn", topicArn);

    return properties;
}
 
Example #9
Source File: S3Resource.java    From quarkus-quickstarts with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, String> start() {
    DockerClientFactory.instance().client();
    try {
        s3 = new LocalStackContainer().withServices(Service.S3);
        s3.start();

        client = S3Client.builder()
            .endpointOverride(new URI(endpoint()))
            .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("accesskey", "secretKey")))
            .httpClientBuilder(UrlConnectionHttpClient.builder())
            .region(Region.US_EAST_1).build();

        client.createBucket(b -> b.bucket(BUCKET_NAME));
    } catch (Exception e) {
        throw new RuntimeException("Could not start S3 localstack server", e);
    }

    Map<String, String> properties = new HashMap<>();
    properties.put("quarkus.s3.endpoint-override", endpoint());
    properties.put("quarkus.s3.aws.region", "us-east-1");
    properties.put("quarkus.s3.aws.credentials.type", "static");
    properties.put("quarkus.s3.aws.credentials.static-provider.access-key-id", "accessKey");
    properties.put("quarkus.s3.aws.credentials.static-provider.secret-access-key", "secretKey");
    properties.put("bucket.name", BUCKET_NAME);

    return properties;
}
 
Example #10
Source File: SesResource.java    From quarkus-quickstarts with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, String> start() {
    DockerClientFactory.instance().client();
    try {
        services = new LocalStackContainer("0.11.1").withServices(Service.SES);
        services.start();
        StaticCredentialsProvider staticCredentials = StaticCredentialsProvider
            .create(AwsBasicCredentials.create("accesskey", "secretKey"));

        client = SesClient.builder()
            .endpointOverride(new URI(endpoint()))
            .credentialsProvider(staticCredentials)
            .httpClientBuilder(UrlConnectionHttpClient.builder())
            .region(Region.US_EAST_1).build();

        client.verifyEmailIdentity(req -> req.emailAddress(FROM_EMAIL));
        client.verifyEmailIdentity(req -> req.emailAddress(TO_EMAIL));

    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException("Could not start localstack server", e);
    }

    Map<String, String> properties = new HashMap<>();
    properties.put("quarkus.ses.endpoint-override", endpoint());
    properties.put("quarkus.ses.aws.region", "us-east-1");
    properties.put("quarkus.ses.aws.credentials.type", "static");
    properties.put("quarkus.ses.aws.credentials.static-provider.access-key-id", "accessKey");
    properties.put("quarkus.ses.aws.credentials.static-provider.secret-access-key", "secretKey");

    return properties;
}
 
Example #11
Source File: DynamodbResource.java    From quarkus-quickstarts with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, String> start() {
    DockerClientFactory.instance().client();
    try {
        dynamodb = new LocalStackContainer().withServices(Service.DYNAMODB);
        dynamodb.start();

        client = DynamoDbClient.builder()
            .endpointOverride(new URI(endpoint()))
            .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("accesskey", "secretKey")))
            .httpClientBuilder(UrlConnectionHttpClient.builder())
            .region(Region.US_EAST_1).build();

        client.createTable(tableRequest ->
            tableRequest.tableName(TABLE_NAME)
                .keySchema(keySchema -> keySchema.attributeName("fruitName").keyType(KeyType.HASH))
                .attributeDefinitions(attrDef -> attrDef.attributeName("fruitName").attributeType(ScalarAttributeType.S))
                .provisionedThroughput(throughput -> throughput.writeCapacityUnits(1L).readCapacityUnits(1L)));
    } catch (Exception e) {
        throw new RuntimeException("Could not start Dynamodb localstack server", e);
    }

    Map<String, String> properties = new HashMap<>();
    properties.put("quarkus.dynamodb.endpoint-override", endpoint());
    properties.put("quarkus.dynamodb.aws.region", "us-east-1");
    properties.put("quarkus.dynamodb.aws.credentials.type", "static");
    properties.put("quarkus.dynamodb.aws.credentials.static-provider.access-key-id", "accessKey");
    properties.put("quarkus.dynamodb.aws.credentials.static-provider.secret-access-key", "secretKey");

    return properties;
}
 
Example #12
Source File: SqsResource.java    From quarkus-quickstarts with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, String> start() {
    DockerClientFactory.instance().client();
    String queueUrl;
    try {
        services = new LocalStackContainer("0.11.1").withServices(Service.SQS);
        services.start();
        StaticCredentialsProvider staticCredentials = StaticCredentialsProvider
            .create(AwsBasicCredentials.create("accesskey", "secretKey"));

        client = SqsClient.builder()
            .endpointOverride(new URI(endpoint()))
            .credentialsProvider(staticCredentials)
            .httpClientBuilder(UrlConnectionHttpClient.builder())
            .region(Region.US_EAST_1).build();

        queueUrl = client.createQueue(q -> q.queueName(QUEUE_NAME)).queueUrl();
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException("Could not start localstack server", e);
    }

    Map<String, String> properties = new HashMap<>();
    properties.put("quarkus.sqs.endpoint-override", endpoint());
    properties.put("quarkus.sqs.aws.region", "us-east-1");
    properties.put("quarkus.sqs.aws.credentials.type", "static");
    properties.put("quarkus.sqs.aws.credentials.static-provider.access-key-id", "accessKey");
    properties.put("quarkus.sqs.aws.credentials.static-provider.secret-access-key", "secretKey");
    properties.put("queue.url", queueUrl);

    return properties;
}
 
Example #13
Source File: DependencyFactory.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
/**
 * @return an instance of S3Client
 */
public static S3Client s3Client() {
    return S3Client.builder()
                   .credentialsProvider(EnvironmentVariableCredentialsProvider.create())
                   .region(Region.US_WEST_2)
                   .httpClientBuilder(UrlConnectionHttpClient.builder())
                   .build();
}
 
Example #14
Source File: UrlConnectionHttpClientBenchmark.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Setup(Level.Trial)
public void setup() throws Exception {
    mockServer = new MockServer();
    mockServer.start();
    sdkHttpClient = UrlConnectionHttpClient.builder()
                                           .buildWithDefaults(trustAllTlsAttributeMapBuilder().build());
    client = ProtocolRestJsonClient.builder()
                                   .endpointOverride(mockServer.getHttpsUri())
                                   .httpClient(sdkHttpClient)
                                   .build();
    client.allTypes();
}
 
Example #15
Source File: ITTracingExecutionInterceptor.java    From zipkin-aws with Apache License 2.0 5 votes vote down vote up
SdkHttpClient primeHttpClient() throws IOException {
  server.enqueue(new MockResponse());
  SdkHttpClient httpClient = UrlConnectionHttpClient.builder().build();
  try {
    httpClient.prepareRequest(HttpExecuteRequest.builder()
        .request(SdkHttpRequest.builder()
            .method(SdkHttpMethod.GET)
            .uri(server.url("/").uri())
            .build())
        .build()).call();
  } finally {
    takeRequest();
  }
  return httpClient;
}
 
Example #16
Source File: UrlConnectionClientConfiguration.java    From micronaut-aws with Apache License 2.0 4 votes vote down vote up
/**
 * @return The builder for {@link UrlConnectionHttpClient}
 */
public UrlConnectionHttpClient.Builder getBuilder() {
    return builder;
}