Search in sources :

Example 1 with DeleteListenerResult

use of com.amazonaws.services.elasticloadbalancingv2.model.DeleteListenerResult in project cloudbreak by hortonworks.

the class AwsNativeLoadBalancerListenerResourceBuilder method delete.

@Override
public CloudResource delete(AwsContext context, com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext auth, CloudResource resource) throws Exception {
    LOGGER.info("Trying to delete listener '{}', may it has already been deleted with it's related load balancer '{}'", resource.getReference(), resource.getInstanceId());
    AmazonElasticLoadBalancingClient loadBalancingClient = context.getLoadBalancingClient();
    DeleteListenerRequest deleteListenerRequest = new DeleteListenerRequest().withListenerArn(resource.getReference());
    DeleteListenerResult deleteResult = null;
    try {
        deleteResult = awsMethodExecutor.execute(() -> loadBalancingClient.deleteListener(deleteListenerRequest), null);
    } catch (AmazonServiceException awsException) {
        if (StringUtils.isNotEmpty(awsException.getErrorCode()) && LISTENER_NOT_FOUND_ERROR_CODE.equals(awsException.getErrorCode())) {
            LOGGER.info("Listener doesn't exist with id: '{}'", resource.getReference());
        } else {
            LOGGER.warn("Listener could not be fetched from AWS with id: '{}'", resource.getReference(), awsException);
            throw awsException;
        }
    }
    return deleteResult != null ? resource : null;
}
Also used : AmazonElasticLoadBalancingClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonElasticLoadBalancingClient) AmazonServiceException(com.amazonaws.AmazonServiceException) DeleteListenerRequest(com.amazonaws.services.elasticloadbalancingv2.model.DeleteListenerRequest) DeleteListenerResult(com.amazonaws.services.elasticloadbalancingv2.model.DeleteListenerResult)

Aggregations

AmazonServiceException (com.amazonaws.AmazonServiceException)1 DeleteListenerRequest (com.amazonaws.services.elasticloadbalancingv2.model.DeleteListenerRequest)1 DeleteListenerResult (com.amazonaws.services.elasticloadbalancingv2.model.DeleteListenerResult)1 AmazonElasticLoadBalancingClient (com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonElasticLoadBalancingClient)1