Example usage for com.amazonaws.services.ec2 AmazonEC2AsyncClient describeSecurityGroups

List of usage examples for com.amazonaws.services.ec2 AmazonEC2AsyncClient describeSecurityGroups

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2 AmazonEC2AsyncClient describeSecurityGroups.

Prototype

DescribeSecurityGroupsResult describeSecurityGroups(
        DescribeSecurityGroupsRequest describeSecurityGroupsRequest);

Source Link

Document

Describes the specified security groups or all of your security groups.

Usage

From source file:com.vmware.photon.controller.model.adapters.awsadapter.AWSFirewallService.java

License:Open Source License

public SecurityGroup getSecurityGroupByID(AmazonEC2AsyncClient client, String groupID) {
    SecurityGroup cellGroup = null;/*from  w w w . j  a  va2s .  co m*/

    DescribeSecurityGroupsRequest req = new DescribeSecurityGroupsRequest().withGroupIds(groupID);
    DescribeSecurityGroupsResult cellGroups = client.describeSecurityGroups(req);
    if (cellGroups != null) {
        cellGroup = cellGroups.getSecurityGroups().get(0);
    }
    return cellGroup;
}

From source file:com.vmware.photon.controller.model.adapters.awsadapter.AWSUtils.java

License:Open Source License

public static SecurityGroup getSecurityGroup(AmazonEC2AsyncClient client, String name) {
    SecurityGroup cellGroup = null;/*from w w w.  j  av  a  2 s .com*/

    DescribeSecurityGroupsRequest req = new DescribeSecurityGroupsRequest()
            .withFilters(new Filter("group-name", Arrays.asList(name)));
    DescribeSecurityGroupsResult cellGroups = client.describeSecurityGroups(req);
    if (cellGroups != null && !cellGroups.getSecurityGroups().isEmpty()) {
        cellGroup = cellGroups.getSecurityGroups().get(0);
    }
    return cellGroup;
}