Example usage for com.amazonaws.services.ec2.model DescribeSecurityGroupsRequest getGroupIds

List of usage examples for com.amazonaws.services.ec2.model DescribeSecurityGroupsRequest getGroupIds

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model DescribeSecurityGroupsRequest getGroupIds.

Prototype


public java.util.List<String> getGroupIds() 

Source Link

Document

The IDs of the security groups.

Usage

From source file:com.netflix.edda.EddaEc2Client.java

License:Apache License

public DescribeSecurityGroupsResult describeSecurityGroups(DescribeSecurityGroupsRequest request) {
    validateEmpty("Filter", request.getFilters());

    TypeReference<List<SecurityGroup>> ref = new TypeReference<List<SecurityGroup>>() {
    };/*from  w ww. j  av  a  2  s.  com*/
    String url = config.url() + "/api/v2/aws/securityGroups;_expand";
    try {
        List<SecurityGroup> securityGroups = parse(ref, doGet(url));

        List<String> names = request.getGroupNames();
        List<String> ids = request.getGroupIds();
        if (shouldFilter(names) || shouldFilter(ids)) {
            List<SecurityGroup> sgs = new ArrayList<SecurityGroup>();
            for (SecurityGroup sg : securityGroups) {
                if (matches(names, sg.getGroupName()) && matches(ids, sg.getGroupId()))
                    sgs.add(sg);
            }
            securityGroups = sgs;
        }

        return new DescribeSecurityGroupsResult().withSecurityGroups(securityGroups);
    } catch (IOException e) {
        throw new AmazonClientException("Faled to parse " + url, e);
    }
}