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

项目:aws-doc-sdk-examples    文件:DeleteSecurityGroup.java   
public static void main(String[] args)
{
    final String USAGE =
        "To run this example, supply a security group id\n" +
        "Ex: DeleteSecurityGroup <security-group-id>\n";

    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }

    String group_id = args[0];

    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    DeleteSecurityGroupRequest request = new DeleteSecurityGroupRequest()
        .withGroupId(group_id);

    DeleteSecurityGroupResult response = ec2.deleteSecurityGroup(request);

    System.out.printf(
        "Successfully deleted security group with id %s", group_id);
}
项目:incubator-provisionr    文件:DeleteSecurityGroup.java   
@Override
public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) {
    final String groupName = SecurityGroups.formatNameFromBusinessKey(execution.getProcessBusinessKey());
    try {
        LOG.info(">> Deleting Security Group {}", groupName);

        client.deleteSecurityGroup(new DeleteSecurityGroupRequest().withGroupName(groupName));

    } catch (AmazonServiceException e) {
        if (e.getErrorCode().equals(ErrorCodes.SECURITY_GROUP_NOT_FOUND)) {
            LOG.info("<< Security Group {} not found. Ignoring this error.", groupName);
        } else {
            throw Throwables.propagate(e);
        }
    }
}
项目:photon-model    文件:AWSSecurityGroupClient.java   
public DeferredResult<Void> deleteSecurityGroupAsync(String securityGroupId) {
    DeleteSecurityGroupRequest req = new DeleteSecurityGroupRequest()
            .withGroupId(securityGroupId);
    String message = "Delete AWS Security Group with id [" + securityGroupId + "].";

    AWSDeferredResultAsyncHandler<DeleteSecurityGroupRequest, DeleteSecurityGroupResult>
            handler = new AWSDeferredResultAsyncHandler<>(this.service, message);

    this.client.deleteSecurityGroupAsync(req, handler);

    return handler.toDeferredResult()
            .thenApply(result -> (Void) null);
}
项目:photon-model    文件:TestAWSSetupUtils.java   
public static void deleteSecurityGroupUsingEC2Client(AmazonEC2AsyncClient client,
        VerificationHost host, String awsGroupId) {
    host.log(Level.INFO, "Starting to delete aws Security group with id %s", awsGroupId);
    if (awsGroupId == null) {
        return;
    }

    try {
        DeleteSecurityGroupRequest deleteSecurityGroupRequest = new DeleteSecurityGroupRequest()
                .withGroupId(awsGroupId);
        client.deleteSecurityGroup(deleteSecurityGroupRequest);

        host.waitFor(
                "Timeout waiting for AWS to delete a SecurityGroup with name " + awsGroupId,
                () -> {
                    // Check if the SG is actually not present on AWS after the delete operation
                    SecurityGroup discoveredSGOnAWS = getSecurityGroupsIdUsingEC2Client(client, awsGroupId);

                    if (discoveredSGOnAWS != null) {
                        // Requested SG was not deleted from AWS
                        return false;
                    }

                    host.log("Deleted SG with id: %s", awsGroupId);
                    return true;
                });
    } catch (Exception e) {
        String message = e.getMessage();
        if (!message.contains("The security group '" + awsGroupId + "' already exists")) {
            throw e;
        }
    }
}
项目:incubator-provisionr    文件:AmazonActivityLiveTest.java   
protected void quietlyDeleteSecurityGroupIfExists(String groupName) {
    try {
        client.deleteSecurityGroup(new DeleteSecurityGroupRequest().withGroupName(groupName));

    } catch (AmazonServiceException e) {
        if (!e.getErrorCode().equals("InvalidGroup.NotFound")) {
            throw Throwables.propagate(e);
        }
    }
}
项目:cfnassist    文件:TestManageSecGroups.java   
private static void deleteGroupIfPresent() {
    try {   
        DescribeSecurityGroupsRequest describeSecurityGroupsRequest = new DescribeSecurityGroupsRequest().withGroupNames(GROUP_NAME);
        DescribeSecurityGroupsResult existing = ec2Client.describeSecurityGroups(describeSecurityGroupsRequest);
        if (existing.getSecurityGroups().size()>0) {
            DeleteSecurityGroupRequest deleteGroup = new DeleteSecurityGroupRequest().withGroupName(GROUP_NAME);
            ec2Client.deleteSecurityGroup(deleteGroup); 
        }
    } catch (AmazonServiceException exception) {
        // no op
    }
}
项目:usergrid    文件:AmazonIpRuleManager.java   
@Override
public boolean deleteRuleSet( final String name ) {
    try {
        DeleteSecurityGroupRequest request = new DeleteSecurityGroupRequest().withGroupName( name );
        client.deleteSecurityGroup( request );
        return true;
    }
    catch ( AmazonServiceException e ) {
        LOG.warn( "Error while trying to delete security group", e );
        return false;
    }
}
项目:aws-mock    文件:BaseTest.java   
/**
 * Delete SecurityGroup.
 *
 * @param groupId the group id
 * @return true if deleted, otherwise false.
 */
protected final boolean deleteSecurityGroup(final String groupId) {
    DeleteSecurityGroupRequest req = new DeleteSecurityGroupRequest();
    req.setGroupId(groupId);
    DeleteSecurityGroupResult result = amazonEC2Client.deleteSecurityGroup(req);
    if (result != null) {
        return true;
    }

    /*CreateSecurityGroupRequest createSecurityGroupRequest = new CreateSecurityGroupRequest();
    AuthorizeSecurityGroupEgressRequest authorizeSecurityGroupEgressRequest = new AuthorizeSecurityGroupEgressRequest();
    authorizeSecurityGroupEgressRequest.setIpProtocol(ipProtocol);
    CreateSecurityGroupResult result = amazonEC2Client.authorizeSecurityGroupEgress(authorizeSecurityGroupEgressRequest);*/
    return false;
}
项目:elasticsearch_my    文件:AmazonEC2Mock.java   
@Override
public void deleteSecurityGroup(DeleteSecurityGroupRequest deleteSecurityGroupRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
项目:photon-model    文件:AWSSecurityGroupClient.java   
public void deleteSecurityGroup(String securityGroupId) {
    DeleteSecurityGroupRequest req = new DeleteSecurityGroupRequest()
            .withGroupId(securityGroupId);

    this.client.deleteSecurityGroup(req);
}
项目:cmn-project    文件:EC2.java   
public void deleteSecurityGroup(String securityGroupId) {
    logger.info("delete security group, securityGroupId={}", securityGroupId);
    ec2.deleteSecurityGroup(new DeleteSecurityGroupRequest().withGroupId(securityGroupId));
}
项目:aws-sdk-java-resources    文件:SecurityGroupImpl.java   
@Override
public void delete(DeleteSecurityGroupRequest request) {
    delete(request, null);
}
项目:aws-sdk-java-resources    文件:SecurityGroupImpl.java   
@Override
public void delete(DeleteSecurityGroupRequest request, ResultCapture<Void>
        extractor) {

    resource.performAction("Delete", request, extractor);
}
项目:aws-sdk-java-resources    文件:SecurityGroup.java   
/**
 * Performs the <code>Delete</code> action.
 *
 * <p>
 * The following request parameters will be populated from the data of this
 * <code>SecurityGroup</code> resource, and any conflicting parameter value
 * set in the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>GroupId</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @see DeleteSecurityGroupRequest
 */
void delete(DeleteSecurityGroupRequest request);
项目:aws-sdk-java-resources    文件:SecurityGroup.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>SecurityGroup</code> resource, and any conflicting parameter value
 * set in the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>GroupId</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @see DeleteSecurityGroupRequest
 */
void delete(DeleteSecurityGroupRequest request, ResultCapture<Void>
        extractor);