@Override public Collection<String> listRuleSets() { DescribeSecurityGroupsRequest request = new DescribeSecurityGroupsRequest(); DescribeSecurityGroupsResult result = null; try { result = client.describeSecurityGroups( request ); } catch ( Exception e ) { LOG.warn( "Error while getting security groups", e ); return new LinkedList<String>(); } Collection<String> groups = new ArrayList<String>(); for( SecurityGroup group : result.getSecurityGroups() ) { groups.add( group.getGroupName() ); } return groups; }
public DescribeSecurityGroupsResult unmarshall(StaxUnmarshallerContext context) throws Exception { DescribeSecurityGroupsResult describeSecurityGroupsResult = new DescribeSecurityGroupsResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return describeSecurityGroupsResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("securityGroupInfo", targetDepth)) { describeSecurityGroupsResult.withSecurityGroups(new ArrayList<SecurityGroup>()); continue; } if (context.testExpression("securityGroupInfo/item", targetDepth)) { describeSecurityGroupsResult.withSecurityGroups(SecurityGroupStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("nextToken", targetDepth)) { describeSecurityGroupsResult.setNextToken(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return describeSecurityGroupsResult; } } } }
/** * <p> * Information about one or more security groups. * </p> * * @param securityGroups * Information about one or more security groups. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeSecurityGroupsResult withSecurityGroups(java.util.Collection<SecurityGroup> securityGroups) { setSecurityGroups(securityGroups); return this; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getSecurityGroups() == null) ? 0 : getSecurityGroups().hashCode()); hashCode = prime * hashCode + ((getNextToken() == null) ? 0 : getNextToken().hashCode()); return hashCode; }
/** * Information about one or more security groups. * <p> * Returns a reference to this object so that method calls can be chained together. * * @param securityGroups Information about one or more security groups. * * @return A reference to this updated object so that method calls can be chained * together. */ public DescribeSecurityGroupsResult withSecurityGroups(SecurityGroup... securityGroups) { if (getSecurityGroups() == null) setSecurityGroups(new java.util.ArrayList<SecurityGroup>(securityGroups.length)); for (SecurityGroup value : securityGroups) { getSecurityGroups().add(value); } return this; }
public DescribeSecurityGroupsResult unmarshall(StaxUnmarshallerContext context) throws Exception { DescribeSecurityGroupsResult describeSecurityGroupsResult = new DescribeSecurityGroupsResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) return describeSecurityGroupsResult; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("securityGroupInfo/item", targetDepth)) { describeSecurityGroupsResult.getSecurityGroups().add(SecurityGroupStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { return describeSecurityGroupsResult; } } } }
public DescribeSecurityGroupsResult describeSecurityGroups(DescribeSecurityGroupsRequest request) { return new DescribeSecurityGroupsResult() .withSecurityGroups( describe(request, "groupIds", "securityGroups", SecurityGroup.class)); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeSecurityGroupsResult == false) return false; DescribeSecurityGroupsResult other = (DescribeSecurityGroupsResult) obj; if (other.getSecurityGroups() == null ^ this.getSecurityGroups() == null) return false; if (other.getSecurityGroups() != null && other.getSecurityGroups().equals(this.getSecurityGroups()) == false) return false; if (other.getNextToken() == null ^ this.getNextToken() == null) return false; if (other.getNextToken() != null && other.getNextToken().equals(this.getNextToken()) == false) return false; return true; }
public DescribeSecurityGroupsResult describeSecurityGroups(DescribeSecurityGroupsRequest request) { return new DescribeSecurityGroupsResult().withSecurityGroups(describe(request, "groupIds", "securityGroups", SecurityGroup.class, new TypeReference<List<SecurityGroup>>() { })); }
@Override public Collection<IpRule> getRules( final String name, final boolean inbound ) { DescribeSecurityGroupsRequest request = new DescribeSecurityGroupsRequest().withGroupNames( name ); DescribeSecurityGroupsResult result = client.describeSecurityGroups( request ); if( result.getSecurityGroups().size() != 1 ) { return null; } Collection<IpRule> ipRules = new ArrayList<IpRule>(); List<IpPermission> permissions; if( inbound ) { permissions = result.getSecurityGroups().get( 0 ).getIpPermissions(); } else { permissions = result.getSecurityGroups().get( 0 ).getIpPermissionsEgress(); } for( IpPermission permission : permissions ) { ipRules.add( toIpRule( permission ) ); } return ipRules; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getSecurityGroups() != null) sb.append("SecurityGroups: ").append(getSecurityGroups()).append(","); if (getNextToken() != null) sb.append("NextToken: ").append(getNextToken()); sb.append("}"); return sb.toString(); }
public DescribeSecurityGroupsResult unmarshall(StaxUnmarshallerContext context) throws Exception { DescribeSecurityGroupsResult describeSecurityGroupsResult = new DescribeSecurityGroupsResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return describeSecurityGroupsResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("securityGroupInfo", targetDepth)) { describeSecurityGroupsResult.withSecurityGroups(new ArrayList<SecurityGroup>()); continue; } if (context.testExpression("securityGroupInfo/item", targetDepth)) { describeSecurityGroupsResult.withSecurityGroups(SecurityGroupStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("nextToken", targetDepth)) { describeSecurityGroupsResult.setNextToken(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return describeSecurityGroupsResult; } } } }
/** * <p> * Information about one or more security groups. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setSecurityGroups(java.util.Collection)} or {@link #withSecurityGroups(java.util.Collection)} if you want * to override the existing values. * </p> * * @param securityGroups * Information about one or more security groups. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeSecurityGroupsResult withSecurityGroups(SecurityGroup... securityGroups) { if (this.securityGroups == null) { setSecurityGroups(new com.amazonaws.internal.SdkInternalList<SecurityGroup>(securityGroups.length)); } for (SecurityGroup ele : securityGroups) { this.securityGroups.add(ele); } return this; }
ec2.describeSecurityGroups(request); for(SecurityGroup group : response.getSecurityGroups()) { System.out.printf( "Found security group with id %s, " +
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getSecurityGroups() == null) ? 0 : getSecurityGroups().hashCode()); hashCode = prime * hashCode + ((getNextToken() == null) ? 0 : getNextToken().hashCode()); return hashCode; }
/** * <p> * Information about one or more security groups. * </p> * * @param securityGroups * Information about one or more security groups. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeSecurityGroupsResult withSecurityGroups(java.util.Collection<SecurityGroup> securityGroups) { setSecurityGroups(securityGroups); return this; }
Collections.singletonList(config.getACLGroupName())); DescribeSecurityGroupsResult result = client.describeSecurityGroups(req); for (SecurityGroup group : result.getSecurityGroups()) for (IpPermission perm : group.getIpPermissions()) if (perm.getFromPort() == from && perm.getToPort() == to) new DescribeSecurityGroupsRequest().withFilters(nameFilter, vpcFilter); DescribeSecurityGroupsResult result = client.describeSecurityGroups(req); for (SecurityGroup group : result.getSecurityGroups()) for (IpPermission perm : group.getIpPermissions()) if (perm.getFromPort() == from && perm.getToPort() == to)
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeSecurityGroupsResult == false) return false; DescribeSecurityGroupsResult other = (DescribeSecurityGroupsResult) obj; if (other.getSecurityGroups() == null ^ this.getSecurityGroups() == null) return false; if (other.getSecurityGroups() != null && other.getSecurityGroups().equals(this.getSecurityGroups()) == false) return false; if (other.getNextToken() == null ^ this.getNextToken() == null) return false; if (other.getNextToken() != null && other.getNextToken().equals(this.getNextToken()) == false) return false; return true; }
/** * <p> * Information about one or more security groups. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setSecurityGroups(java.util.Collection)} or {@link #withSecurityGroups(java.util.Collection)} if you want * to override the existing values. * </p> * * @param securityGroups * Information about one or more security groups. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeSecurityGroupsResult withSecurityGroups(SecurityGroup... securityGroups) { if (this.securityGroups == null) { setSecurityGroups(new com.amazonaws.internal.SdkInternalList<SecurityGroup>(securityGroups.length)); } for (SecurityGroup ele : securityGroups) { this.securityGroups.add(ele); } return this; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeSecurityGroupsResult == false) return false; DescribeSecurityGroupsResult other = (DescribeSecurityGroupsResult)obj; if (other.getSecurityGroups() == null ^ this.getSecurityGroups() == null) return false; if (other.getSecurityGroups() != null && other.getSecurityGroups().equals(this.getSecurityGroups()) == false) return false; return true; }