/** * <p> * [EC2-Classic and default VPC only] One or more security group names. You can specify either the security group * name or the security group ID. For security groups in a nondefault VPC, use the <code>group-name</code> filter to * describe security groups by name. * </p> * <p> * Default: Describes all your security groups. * </p> * * @param groupNames * [EC2-Classic and default VPC only] One or more security group names. You can specify either the security * group name or the security group ID. For security groups in a nondefault VPC, use the * <code>group-name</code> filter to describe security groups by name.</p> * <p> * Default: Describes all your security groups. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeSecurityGroupsRequest withGroupNames(java.util.Collection<String> groupNames) { setGroupNames(groupNames); return this; }
setGroupNames(new com.amazonaws.internal.SdkInternalList<String>(groupNames.length));
/** * [EC2-Classic and default VPC only] One or more security group names. * You can specify either the security group name or the security group * ID. For security groups in a nondefault VPC, use the * <code>group-name</code> filter to describe security groups by name. * <p>Default: Describes all your security groups. * <p> * Returns a reference to this object so that method calls can be chained together. * * @param groupNames [EC2-Classic and default VPC only] One or more security group names. * You can specify either the security group name or the security group * ID. For security groups in a nondefault VPC, use the * <code>group-name</code> filter to describe security groups by name. * <p>Default: Describes all your security groups. * * @return A reference to this updated object so that method calls can be chained * together. */ public DescribeSecurityGroupsRequest withGroupNames(String... groupNames) { if (getGroupNames() == null) setGroupNames(new java.util.ArrayList<String>(groupNames.length)); for (String value : groupNames) { getGroupNames().add(value); } return this; }
/** * <p> * [EC2-Classic and default VPC only] One or more security group names. You can specify either the security group * name or the security group ID. For security groups in a nondefault VPC, use the <code>group-name</code> filter to * describe security groups by name. * </p> * <p> * Default: Describes all your security groups. * </p> * * @param groupNames * [EC2-Classic and default VPC only] One or more security group names. You can specify either the security * group name or the security group ID. For security groups in a nondefault VPC, use the * <code>group-name</code> filter to describe security groups by name.</p> * <p> * Default: Describes all your security groups. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeSecurityGroupsRequest withGroupNames(java.util.Collection<String> groupNames) { setGroupNames(groupNames); return this; }
public SecurityGroup findOneSecurityGroupByName(String securityGroupName) { DescribeSecurityGroupsRequest securityRequest = new DescribeSecurityGroupsRequest(); securityRequest.setGroupNames(Arrays.asList(securityGroupName)); DescribeSecurityGroupsResult securityDescription = ec2.describeSecurityGroups(securityRequest); return securityDescription.getSecurityGroups().get(0); }
@Override public Optional<SecurityGroup> getSecurityGroup(String name) { checkNotBlank(name, "name"); List<String> names = getSecurityGroupNames(); if (names.contains(name)) { DescribeSecurityGroupsRequest request = new DescribeSecurityGroupsRequest(); request.setGroupNames(Collections.singletonList(name)); DescribeSecurityGroupsResult result = client.describeSecurityGroups(request); List<SecurityGroup> groups = result.getSecurityGroups(); checkState(groups.size() == 1, "Expected exactly 1 security group but there were %s instead", groups.size()); SecurityGroup group = groups.get(0); return Optional.of(group); } else { return Optional.<SecurityGroup> absent(); } }
setGroupNames(new com.amazonaws.internal.SdkInternalList<String>(groupNames.length));