Search in sources :

Example 1 with AmazonElasticLoadBalancingAsyncClientBuilder

use of com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingAsyncClientBuilder in project photon-model by vmware.

the class AWSUtils method getLoadBalancingAsyncClient.

/**
 * Method to get a load balancing async client.
 *
 * Note: ARN-based credentials will not work unless they have already been exchanged to
 * AWS for session credentials. If unset, this method will fail. To enable ARN-based
 * credentials, migrate to {@link #getAwsLoadBalancingAsyncClient(AuthCredentialsServiceState,
 * String, ExecutorService)}.
 *
 * @param credentials An {@link AuthCredentialsServiceState} object.
 * @param region The region to get the AWS client in.
 * @param executorService The executor service to run async services in.
 */
public static AmazonElasticLoadBalancingAsyncClient getLoadBalancingAsyncClient(AuthCredentialsServiceState credentials, String region, ExecutorService executorService) {
    AmazonElasticLoadBalancingAsyncClientBuilder amazonElasticLoadBalancingAsyncClientBuilder = AmazonElasticLoadBalancingAsyncClientBuilder.standard().withClientConfiguration(createClientConfiguration()).withCredentials(getAwsStaticCredentialsProvider(credentials)).withExecutorFactory(() -> executorService);
    if (region == null) {
        region = Regions.DEFAULT_REGION.getName();
    }
    if (isAwsClientMock()) {
        AwsClientBuilder.EndpointConfiguration endpointConfiguration = new AwsClientBuilder.EndpointConfiguration(getAWSMockHost() + AWS_MOCK_LOAD_BALANCING_ENDPOINT, region);
        amazonElasticLoadBalancingAsyncClientBuilder.setEndpointConfiguration(endpointConfiguration);
    } else {
        amazonElasticLoadBalancingAsyncClientBuilder.setRegion(region);
    }
    return (AmazonElasticLoadBalancingAsyncClient) amazonElasticLoadBalancingAsyncClientBuilder.build();
}
Also used : AmazonElasticLoadBalancingAsyncClient(com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingAsyncClient) AmazonElasticLoadBalancingAsyncClientBuilder(com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingAsyncClientBuilder) AwsClientBuilder(com.amazonaws.client.builder.AwsClientBuilder)

Aggregations

AwsClientBuilder (com.amazonaws.client.builder.AwsClientBuilder)1 AmazonElasticLoadBalancingAsyncClient (com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingAsyncClient)1 AmazonElasticLoadBalancingAsyncClientBuilder (com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingAsyncClientBuilder)1