Java 类com.amazonaws.services.ec2.model.DeleteSubnetRequest 实例源码

项目:photon-model    文件:AWSSubnetTaskServiceTest.java   
public void deleteAwsSubnet() {
    if (this.isMock) {
        return;
    }
    DescribeSubnetsRequest subnetRequest = new DescribeSubnetsRequest()
            .withFilters(
                    new Filter(AWS_VPC_ID_FILTER, singletonList(AWS_DEFAULT_VPC_ID)))
            .withFilters(
                    new Filter(AWS_SUBNET_CIDR_FILTER,
                            singletonList(AWS_NON_EXISTING_SUBNET_CIDR)));
    DescribeSubnetsResult subnetResult = this.client.describeSubnets(subnetRequest);
    subnetResult.getSubnets().forEach(subnet -> {
        DeleteSubnetRequest deleteRequest = new DeleteSubnetRequest(subnet.getSubnetId());
        this.client.deleteSubnet(deleteRequest);
    });
}
项目:photon-model    文件:AWSSubnetTaskServiceTest.java   
public void deleteAwsPublicSubnet() {
    if (this.isMock) {
        return;
    }
    DescribeSubnetsRequest subnetRequest = new DescribeSubnetsRequest()
            .withFilters(
                    new Filter(AWS_VPC_ID_FILTER, singletonList(AWS_DEFAULT_VPC_ID)))
            .withFilters(
                    new Filter(AWS_SUBNET_CIDR_FILTER,
                            singletonList(AWS_NON_EXISTING_PUBLIC_SUBNET_CIDR)));
    DescribeSubnetsResult subnetResult = this.client.describeSubnets(subnetRequest);
    subnetResult.getSubnets().forEach(subnet -> {
        DeleteSubnetRequest deleteRequest = new DeleteSubnetRequest(subnet.getSubnetId());
        this.client.deleteSubnet(deleteRequest);
    });
}
项目:cmn-project    文件:DeleteSubnetTask.java   
@Override
public void execute(Context context) throws Exception {
    String key = "subnet/" + resource.id;

    for (com.amazonaws.services.ec2.model.Subnet remoteSubnet : resource.remoteSubnets) {
        new Runner<Void>()
            .maxAttempts(5)
            .retryInterval(Duration.ofSeconds(60))
            .retryOn(e -> e instanceof AmazonServiceException)
            .run(() -> {
                logger.info("delete subnet, subnetId={}, cidr={}", remoteSubnet.getSubnetId(), remoteSubnet.getCidrBlock());
                AWS.vpc.ec2.deleteSubnet(new DeleteSubnetRequest().withSubnetId(remoteSubnet.getSubnetId()));
                context.output(key, String.format("deletedSubnetId=%s, cidr=%s", remoteSubnet.getSubnetId(), remoteSubnet.getCidrBlock()));
                return null;
            });
    }
}
项目:photon-model    文件:AWSNetworkClient.java   
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);
}
项目:aws-mock    文件:BaseTest.java   
/**
 * Delete Subnet.
 *
 * @param subnetId the subnet id
 * @return true if deleted, otherwise false.
 */
protected final boolean deleteSubnet(final String subnetId) {
    DeleteSubnetRequest req = new DeleteSubnetRequest();
    req.setSubnetId(subnetId);
    DeleteSubnetResult result = amazonEC2Client.deleteSubnet(req);
    if (result != null) {
        return true;
    }
    return false;
 }
项目:elasticsearch_my    文件:AmazonEC2Mock.java   
@Override
public void deleteSubnet(DeleteSubnetRequest deleteSubnetRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
项目:photon-model    文件:TestAWSSetupUtils.java   
/**
 * Delete a Subnet
 */
public static void deleteSubnet(AmazonEC2AsyncClient client, String subnetId) {
    if (subnetId != null) {
        client.deleteSubnet(new DeleteSubnetRequest().withSubnetId(subnetId));
    }
}
项目:aws-sdk-java-resources    文件:SubnetImpl.java   
@Override
public void delete(DeleteSubnetRequest request) {
    delete(request, null);
}
项目:aws-sdk-java-resources    文件:SubnetImpl.java   
@Override
public void delete(DeleteSubnetRequest request, ResultCapture<Void>
        extractor) {

    resource.performAction("Delete", request, extractor);
}
项目:aws-sdk-java-resources    文件:SubnetImpl.java   
@Override
public void delete(ResultCapture<Void> extractor) {
    DeleteSubnetRequest request = new DeleteSubnetRequest();
    delete(request, extractor);
}
项目:photon-model    文件:AWSNetworkClient.java   
/**
 * Delete the specified subnet
 *
 * @throws AmazonEC2Exception if the subnet doesn't exist.
 */
public void deleteSubnet(String subnetId) throws AmazonEC2Exception {
    DeleteSubnetRequest req = new DeleteSubnetRequest().withSubnetId(subnetId);
    this.client.deleteSubnet(req);
}
项目:aws-sdk-java-resources    文件:Subnet.java   
/**
 * Performs the <code>Delete</code> action.
 *
 * <p>
 * The following request parameters will be populated from the data of this
 * <code>Subnet</code> resource, and any conflicting parameter value set in
 * the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>SubnetId</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @see DeleteSubnetRequest
 */
void delete(DeleteSubnetRequest request);
项目:aws-sdk-java-resources    文件:Subnet.java   
/**
 * Performs the <code>Delete</code> action and use a ResultCapture to
 * retrieve the low-level client response.
 *
 * <p>
 * The following request parameters will be populated from the data of this
 * <code>Subnet</code> resource, and any conflicting parameter value set in
 * the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>SubnetId</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @see DeleteSubnetRequest
 */
void delete(DeleteSubnetRequest request, ResultCapture<Void> extractor);