Search in sources :

Example 6 with ClientOverrideConfiguration

use of software.amazon.awssdk.core.client.config.ClientOverrideConfiguration in project flink by apache.

the class AWSAsyncSinkUtil method createAwsAsyncClient.

/**
 * @param configProps configuration properties
 * @param clientConfiguration the AWS SDK v2 config to instantiate the client
 * @param httpClient the underlying HTTP client used to talk to AWS
 * @return a new AWS Client
 */
public static <S extends SdkClient, T extends AwsAsyncClientBuilder<? extends T, S> & AwsClientBuilder<? extends T, S>> S createAwsAsyncClient(final Properties configProps, final SdkClientConfiguration clientConfiguration, final SdkAsyncHttpClient httpClient, final T clientBuilder, final String awsUserAgentPrefixFormat, final String awsClientUserAgentPrefix) {
    String flinkUserAgentPrefix = Optional.ofNullable(configProps.getProperty(awsClientUserAgentPrefix)).orElse(formatFlinkUserAgentPrefix(awsUserAgentPrefixFormat + V2_USER_AGENT_SUFFIX));
    final ClientOverrideConfiguration overrideConfiguration = createClientOverrideConfiguration(clientConfiguration, ClientOverrideConfiguration.builder(), flinkUserAgentPrefix);
    return createAwsAsyncClient(configProps, clientBuilder, httpClient, overrideConfiguration);
}
Also used : ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration)

Example 7 with ClientOverrideConfiguration

use of software.amazon.awssdk.core.client.config.ClientOverrideConfiguration in project data-transfer-project by google.

the class BaseBackblazeS3ClientFactory method createS3Client.

public S3Client createS3Client(String accessKey, String secretKey, String region) {
    AwsSessionCredentials awsCreds = AwsSessionCredentials.create(accessKey, secretKey, "");
    ClientOverrideConfiguration clientOverrideConfiguration = ClientOverrideConfiguration.builder().putHeader("User-Agent", "Facebook-DTP").build();
    // Use any AWS region for the client, the Backblaze API does not care about it
    Region awsRegion = Region.US_EAST_1;
    return S3Client.builder().credentialsProvider(StaticCredentialsProvider.create(awsCreds)).overrideConfiguration(clientOverrideConfiguration).endpointOverride(URI.create(String.format(S3_ENDPOINT_FORMAT_STRING, region))).region(awsRegion).build();
}
Also used : AwsSessionCredentials(software.amazon.awssdk.auth.credentials.AwsSessionCredentials) ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) Region(software.amazon.awssdk.regions.Region)

Aggregations

ClientOverrideConfiguration (software.amazon.awssdk.core.client.config.ClientOverrideConfiguration)7 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Properties (java.util.Properties)2 Test (org.junit.Test)2 SdkAsyncHttpClient (software.amazon.awssdk.http.async.SdkAsyncHttpClient)2 Region (software.amazon.awssdk.regions.Region)2 PinpointSmsVoiceClient (software.amazon.awssdk.services.pinpointsmsvoice.PinpointSmsVoiceClient)2 StringReader (java.io.StringReader)1 URI (java.net.URI)1 Duration (java.time.Duration)1 AWS_ENDPOINT (org.apache.flink.connector.aws.config.AWSConfigConstants.AWS_ENDPOINT)1 AWS_REGION (org.apache.flink.connector.aws.config.AWSConfigConstants.AWS_REGION)1 AWSAsyncSinkUtil.formatFlinkUserAgentPrefix (org.apache.flink.connector.aws.util.AWSAsyncSinkUtil.formatFlinkUserAgentPrefix)1 Document (org.jdom2.Document)1 SAXBuilder (org.jdom2.input.SAXBuilder)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1 ArgumentMatchers.argThat (org.mockito.ArgumentMatchers.argThat)1 Mockito.mock (org.mockito.Mockito.mock)1