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;
}
Aggregations