Search in sources :

Example 1 with DeleteSubnetResult

use of com.amazonaws.services.ec2.model.DeleteSubnetResult in project photon-model by vmware.

the class AWSNetworkClient method deleteSubnetAsync.

public DeferredResult<Void> deleteSubnetAsync(String subnetId) {
    DeleteSubnetRequest req = new DeleteSubnetRequest().withSubnetId(subnetId);
    String message = "Delete AWS Subnet with id [" + subnetId + "].";
    AWSDeferredResultAsyncHandler<DeleteSubnetRequest, DeleteSubnetResult> handler = new AWSDeferredResultAsyncHandler<DeleteSubnetRequest, DeleteSubnetResult>(this.service, message) {

        @Override
        protected Exception consumeError(Exception exception) {
            if (exception instanceof AmazonEC2Exception) {
                AmazonEC2Exception amazonExc = (AmazonEC2Exception) exception;
                if (STATUS_CODE_SUBNET_NOT_FOUND.equals(amazonExc.getErrorCode())) {
                    // AWS subnet doesn't exist.
                    this.service.logWarning(() -> String.format("Unable to delete AWS " + "subnet with id [%s], as it does not exist.", subnetId));
                    return RECOVERED;
                }
            }
            return exception;
        }
    };
    this.client.deleteSubnetAsync(req, handler);
    return handler.toDeferredResult().thenApply(result -> (Void) null);
}
Also used : DeleteSubnetResult(com.amazonaws.services.ec2.model.DeleteSubnetResult) DeleteSubnetRequest(com.amazonaws.services.ec2.model.DeleteSubnetRequest) AmazonEC2Exception(com.amazonaws.services.ec2.model.AmazonEC2Exception) AmazonEC2Exception(com.amazonaws.services.ec2.model.AmazonEC2Exception)

Aggregations

AmazonEC2Exception (com.amazonaws.services.ec2.model.AmazonEC2Exception)1 DeleteSubnetRequest (com.amazonaws.services.ec2.model.DeleteSubnetRequest)1 DeleteSubnetResult (com.amazonaws.services.ec2.model.DeleteSubnetResult)1