Search in sources :

Example 6 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project camel by apache.

the class SesEndpoint method createSESClient.

private AmazonSimpleEmailService createSESClient() {
    AmazonSimpleEmailService client = null;
    ClientConfiguration clientConfiguration = null;
    boolean isClientConfigFound = false;
    if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
        clientConfiguration = new ClientConfiguration();
        clientConfiguration.setProxyHost(configuration.getProxyHost());
        clientConfiguration.setProxyPort(configuration.getProxyPort());
        isClientConfigFound = true;
    }
    if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) {
        AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
        if (isClientConfigFound) {
            client = new AmazonSimpleEmailServiceClient(credentials, clientConfiguration);
        } else {
            client = new AmazonSimpleEmailServiceClient(credentials);
        }
    } else {
        if (isClientConfigFound) {
            client = new AmazonSimpleEmailServiceClient();
        } else {
            client = new AmazonSimpleEmailServiceClient(clientConfiguration);
        }
    }
    return client;
}
Also used : AmazonSimpleEmailService(com.amazonaws.services.simpleemail.AmazonSimpleEmailService) AmazonSimpleEmailServiceClient(com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) AWSCredentials(com.amazonaws.auth.AWSCredentials) ClientConfiguration(com.amazonaws.ClientConfiguration) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Example 7 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project camel by apache.

the class S3Endpoint method createS3Client.

/**
     * Provide the possibility to override this method for an mock implementation
     */
AmazonS3 createS3Client() {
    AmazonS3Client client = null;
    ClientConfiguration clientConfiguration = null;
    boolean isClientConfigFound = false;
    if (configuration.hasProxyConfiguration()) {
        clientConfiguration = new ClientConfiguration();
        clientConfiguration.setProxyHost(configuration.getProxyHost());
        clientConfiguration.setProxyPort(configuration.getProxyPort());
        isClientConfigFound = true;
    }
    if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) {
        AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
        if (isClientConfigFound) {
            client = new AmazonS3Client(credentials, clientConfiguration);
        } else {
            client = new AmazonS3Client(credentials);
        }
    } else {
        if (isClientConfigFound) {
            client = new AmazonS3Client();
        } else {
            client = new AmazonS3Client(clientConfiguration);
        }
    }
    S3ClientOptions clientOptions = S3ClientOptions.builder().setPathStyleAccess(configuration.isPathStyleAccess()).build();
    client.setS3ClientOptions(clientOptions);
    return client;
}
Also used : AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client) S3ClientOptions(com.amazonaws.services.s3.S3ClientOptions) AWSCredentials(com.amazonaws.auth.AWSCredentials) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) ClientConfiguration(com.amazonaws.ClientConfiguration) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Example 8 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project camel by apache.

the class SWFEndpoint method createSWClient.

private AmazonSimpleWorkflowClient createSWClient() throws Exception {
    AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
    ClientConfiguration clientConfiguration = new ClientConfiguration();
    if (!configuration.getClientConfigurationParameters().isEmpty()) {
        setProperties(clientConfiguration, configuration.getClientConfigurationParameters());
    }
    AmazonSimpleWorkflowClient client = new AmazonSimpleWorkflowClient(credentials, clientConfiguration);
    if (!configuration.getSWClientParameters().isEmpty()) {
        setProperties(client, configuration.getSWClientParameters());
    }
    return client;
}
Also used : AmazonSimpleWorkflowClient(com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflowClient) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) AWSCredentials(com.amazonaws.auth.AWSCredentials) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) ClientConfiguration(com.amazonaws.ClientConfiguration)

Example 9 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project hadoop by apache.

the class ITestS3AConfiguration method testDefaultUserAgent.

@Test
public void testDefaultUserAgent() throws Exception {
    conf = new Configuration();
    fs = S3ATestUtils.createTestFileSystem(conf);
    assertNotNull(fs);
    AmazonS3 s3 = fs.getAmazonS3Client();
    assertNotNull(s3);
    ClientConfiguration awsConf = getField(s3, ClientConfiguration.class, "clientConfiguration");
    assertEquals("Hadoop " + VersionInfo.getVersion(), awsConf.getUserAgentPrefix());
}
Also used : AmazonS3(com.amazonaws.services.s3.AmazonS3) Configuration(org.apache.hadoop.conf.Configuration) ClientConfiguration(com.amazonaws.ClientConfiguration) ClientConfiguration(com.amazonaws.ClientConfiguration) Test(org.junit.Test)

Example 10 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project hadoop by apache.

the class ITestS3AConfiguration method testCustomUserAgent.

@Test
public void testCustomUserAgent() throws Exception {
    conf = new Configuration();
    conf.set(Constants.USER_AGENT_PREFIX, "MyApp");
    fs = S3ATestUtils.createTestFileSystem(conf);
    assertNotNull(fs);
    AmazonS3 s3 = fs.getAmazonS3Client();
    assertNotNull(s3);
    ClientConfiguration awsConf = getField(s3, ClientConfiguration.class, "clientConfiguration");
    assertEquals("MyApp, Hadoop " + VersionInfo.getVersion(), awsConf.getUserAgentPrefix());
}
Also used : AmazonS3(com.amazonaws.services.s3.AmazonS3) Configuration(org.apache.hadoop.conf.Configuration) ClientConfiguration(com.amazonaws.ClientConfiguration) ClientConfiguration(com.amazonaws.ClientConfiguration) Test(org.junit.Test)

Aggregations

ClientConfiguration (com.amazonaws.ClientConfiguration)42 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)17 AWSCredentials (com.amazonaws.auth.AWSCredentials)13 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)5 AmazonDynamoDBClient (com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient)4 Configuration (org.apache.hadoop.conf.Configuration)4 PropertiesCredentials (com.amazonaws.auth.PropertiesCredentials)3 File (java.io.File)3 Test (org.testng.annotations.Test)3 AmazonClientException (com.amazonaws.AmazonClientException)2 Protocol (com.amazonaws.Protocol)2 InstanceProfileCredentialsProvider (com.amazonaws.auth.InstanceProfileCredentialsProvider)2 AmazonAutoScalingClient (com.amazonaws.services.autoscaling.AmazonAutoScalingClient)2 AmazonS3 (com.amazonaws.services.s3.AmazonS3)2 S3ClientOptions (com.amazonaws.services.s3.S3ClientOptions)2 TransferManager (com.amazonaws.services.s3.transfer.TransferManager)2 AmazonSimpleDB (com.amazonaws.services.simpledb.AmazonSimpleDB)2 AmazonSimpleDBClient (com.amazonaws.services.simpledb.AmazonSimpleDBClient)2 URI (java.net.URI)2 Date (java.util.Date)2