Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
   * 
   *  http://aws.amazon.com/apache2.0
   * 
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.services.ec2.model;
 

Describes a security group rule.

 
 public class IpPermission implements SerializableCloneable {

    
The protocol.

When you call DescribeSecurityGroups, the protocol value returned is the number. Exception: For TCP, UDP, and ICMP, the value returned is the name (for example, tcp, udp, or icmp). For a list of protocol numbers, see Protocol Numbers. (VPC only) When you call AuthorizeSecurityGroupIngress, you can use -1 to specify all.

 
     private String ipProtocol;

    
The start of port range for the TCP and UDP protocols, or an ICMP type number. A value of -1 indicates all ICMP types.
 
     private Integer fromPort;

    
The end of port range for the TCP and UDP protocols, or an ICMP code. A value of -1 indicates all ICMP codes for the specified ICMP type.
 
     private Integer toPort;

    
One or more security group and AWS account ID pairs.
 
One or more IP ranges.
 
(Valid for AuthorizeSecurityGroupEgress, RevokeSecurityGroupEgress and DescribeSecurityGroups only) One or more prefix list IDs for an AWS service. In an AuthorizeSecurityGroupEgress request, this is the AWS service that you want to access through a VPC endpoint from instances associated with the security group.
 
The protocol.

When you call DescribeSecurityGroups, the protocol value returned is the number. Exception: For TCP, UDP, and ICMP, the value returned is the name (for example, tcp, udp, or icmp). For a list of protocol numbers, see Protocol Numbers. (VPC only) When you call AuthorizeSecurityGroupIngress, you can use -1 to specify all.

Returns:
The protocol.

When you call DescribeSecurityGroups, the protocol value returned is the number. Exception: For TCP, UDP, and ICMP, the value returned is the name (for example, tcp, udp, or icmp). For a list of protocol numbers, see Protocol Numbers. (VPC only) When you call AuthorizeSecurityGroupIngress, you can use -1 to specify all.

 
     public String getIpProtocol() {
         return ;
     }
    
    
The protocol.

When you call DescribeSecurityGroups, the protocol value returned is the number. Exception: For TCP, UDP, and ICMP, the value returned is the name (for example, tcp, udp, or icmp). For a list of protocol numbers, see Protocol Numbers. (VPC only) When you call AuthorizeSecurityGroupIngress, you can use -1 to specify all.

Parameters:
ipProtocol The protocol.

When you call DescribeSecurityGroups, the protocol value returned is the number. Exception: For TCP, UDP, and ICMP, the value returned is the name (for example, tcp, udp, or icmp). For a list of protocol numbers, see Protocol Numbers. (VPC only) When you call AuthorizeSecurityGroupIngress, you can use -1 to specify all.

    public void setIpProtocol(String ipProtocol) {
        this. = ipProtocol;
    }
    
    
The protocol.

When you call DescribeSecurityGroups, the protocol value returned is the number. Exception: For TCP, UDP, and ICMP, the value returned is the name (for example, tcp, udp, or icmp). For a list of protocol numbers, see Protocol Numbers. (VPC only) When you call AuthorizeSecurityGroupIngress, you can use -1 to specify all.

Returns a reference to this object so that method calls can be chained together.

Parameters:
ipProtocol The protocol.

When you call DescribeSecurityGroups, the protocol value returned is the number. Exception: For TCP, UDP, and ICMP, the value returned is the name (for example, tcp, udp, or icmp). For a list of protocol numbers, see Protocol Numbers. (VPC only) When you call AuthorizeSecurityGroupIngress, you can use -1 to specify all.

Returns:
A reference to this updated object so that method calls can be chained together.
    public IpPermission withIpProtocol(String ipProtocol) {
        this. = ipProtocol;
        return this;
    }

    
The start of port range for the TCP and UDP protocols, or an ICMP type number. A value of -1 indicates all ICMP types.

Returns:
The start of port range for the TCP and UDP protocols, or an ICMP type number. A value of -1 indicates all ICMP types.
    public Integer getFromPort() {
        return ;
    }
    
    
The start of port range for the TCP and UDP protocols, or an ICMP type number. A value of -1 indicates all ICMP types.

Parameters:
fromPort The start of port range for the TCP and UDP protocols, or an ICMP type number. A value of -1 indicates all ICMP types.
    public void setFromPort(Integer fromPort) {
        this. = fromPort;
    }
    
    
The start of port range for the TCP and UDP protocols, or an ICMP type number. A value of -1 indicates all ICMP types.

Returns a reference to this object so that method calls can be chained together.

Parameters:
fromPort The start of port range for the TCP and UDP protocols, or an ICMP type number. A value of -1 indicates all ICMP types.
Returns:
A reference to this updated object so that method calls can be chained together.
    public IpPermission withFromPort(Integer fromPort) {
        this. = fromPort;
        return this;
    }

    
The end of port range for the TCP and UDP protocols, or an ICMP code. A value of -1 indicates all ICMP codes for the specified ICMP type.

Returns:
The end of port range for the TCP and UDP protocols, or an ICMP code. A value of -1 indicates all ICMP codes for the specified ICMP type.
    public Integer getToPort() {
        return ;
    }
    
    
The end of port range for the TCP and UDP protocols, or an ICMP code. A value of -1 indicates all ICMP codes for the specified ICMP type.

Parameters:
toPort The end of port range for the TCP and UDP protocols, or an ICMP code. A value of -1 indicates all ICMP codes for the specified ICMP type.
    public void setToPort(Integer toPort) {
        this. = toPort;
    }
    
    
The end of port range for the TCP and UDP protocols, or an ICMP code. A value of -1 indicates all ICMP codes for the specified ICMP type.

Returns a reference to this object so that method calls can be chained together.

Parameters:
toPort The end of port range for the TCP and UDP protocols, or an ICMP code. A value of -1 indicates all ICMP codes for the specified ICMP type.
Returns:
A reference to this updated object so that method calls can be chained together.
    public IpPermission withToPort(Integer toPort) {
        this. = toPort;
        return this;
    }

    
One or more security group and AWS account ID pairs.

Returns:
One or more security group and AWS account ID pairs.
        if ( == null) {
              .setAutoConstruct(true);
        }
        return ;
    }
    
    
One or more security group and AWS account ID pairs.

Parameters:
userIdGroupPairs One or more security group and AWS account ID pairs.
    public void setUserIdGroupPairs(java.util.Collection<UserIdGroupPairuserIdGroupPairs) {
        if (userIdGroupPairs == null) {
            this. = null;
            return;
        }
        userIdGroupPairsCopy.addAll(userIdGroupPairs);
        this. = userIdGroupPairsCopy;
    }
    
    
One or more security group and AWS account ID pairs.

NOTE: This method appends the values to the existing list (if any). Use setUserIdGroupPairs(java.util.Collection) or withUserIdGroupPairs(java.util.Collection) if you want to override the existing values.

Returns a reference to this object so that method calls can be chained together.

Parameters:
userIdGroupPairs One or more security group and AWS account ID pairs.
Returns:
A reference to this updated object so that method calls can be chained together.
    public IpPermission withUserIdGroupPairs(UserIdGroupPair... userIdGroupPairs) {
        if (getUserIdGroupPairs() == nullsetUserIdGroupPairs(new java.util.ArrayList<UserIdGroupPair>(userIdGroupPairs.length));
        for (UserIdGroupPair value : userIdGroupPairs) {
            getUserIdGroupPairs().add(value);
        }
        return this;
    }
    
    
One or more security group and AWS account ID pairs.

Returns a reference to this object so that method calls can be chained together.

Parameters:
userIdGroupPairs One or more security group and AWS account ID pairs.
Returns:
A reference to this updated object so that method calls can be chained together.
        if (userIdGroupPairs == null) {
            this. = null;
        } else {
            com.amazonaws.internal.ListWithAutoConstructFlag<UserIdGroupPairuserIdGroupPairsCopy = new com.amazonaws.internal.ListWithAutoConstructFlag<UserIdGroupPair>(userIdGroupPairs.size());
            userIdGroupPairsCopy.addAll(userIdGroupPairs);
            this. = userIdGroupPairsCopy;
        }
        return this;
    }

    
One or more IP ranges.

Returns:
One or more IP ranges.
    public java.util.List<StringgetIpRanges() {
        if ( == null) {
               = new com.amazonaws.internal.ListWithAutoConstructFlag<String>();
              .setAutoConstruct(true);
        }
        return ;
    }
    
    
One or more IP ranges.

Parameters:
ipRanges One or more IP ranges.
    public void setIpRanges(java.util.Collection<StringipRanges) {
        if (ipRanges == null) {
            this. = null;
            return;
        }
        ipRangesCopy.addAll(ipRanges);
        this. = ipRangesCopy;
    }
    
    
One or more IP ranges.

NOTE: This method appends the values to the existing list (if any). Use setIpRanges(java.util.Collection) or withIpRanges(java.util.Collection) if you want to override the existing values.

Returns a reference to this object so that method calls can be chained together.

Parameters:
ipRanges One or more IP ranges.
Returns:
A reference to this updated object so that method calls can be chained together.
    public IpPermission withIpRanges(String... ipRanges) {
        if (getIpRanges() == nullsetIpRanges(new java.util.ArrayList<String>(ipRanges.length));
        for (String value : ipRanges) {
            getIpRanges().add(value);
        }
        return this;
    }
    
    
One or more IP ranges.

Returns a reference to this object so that method calls can be chained together.

Parameters:
ipRanges One or more IP ranges.
Returns:
A reference to this updated object so that method calls can be chained together.
    public IpPermission withIpRanges(java.util.Collection<StringipRanges) {
        if (ipRanges == null) {
            this. = null;
        } else {
            ipRangesCopy.addAll(ipRanges);
            this. = ipRangesCopy;
        }
        return this;
    }

    
(Valid for AuthorizeSecurityGroupEgress, RevokeSecurityGroupEgress and DescribeSecurityGroups only) One or more prefix list IDs for an AWS service. In an AuthorizeSecurityGroupEgress request, this is the AWS service that you want to access through a VPC endpoint from instances associated with the security group.

Returns:
(Valid for AuthorizeSecurityGroupEgress, RevokeSecurityGroupEgress and DescribeSecurityGroups only) One or more prefix list IDs for an AWS service. In an AuthorizeSecurityGroupEgress request, this is the AWS service that you want to access through a VPC endpoint from instances associated with the security group.
        if ( == null) {
              .setAutoConstruct(true);
        }
        return ;
    }
    
    
(Valid for AuthorizeSecurityGroupEgress, RevokeSecurityGroupEgress and DescribeSecurityGroups only) One or more prefix list IDs for an AWS service. In an AuthorizeSecurityGroupEgress request, this is the AWS service that you want to access through a VPC endpoint from instances associated with the security group.

Parameters:
prefixListIds (Valid for AuthorizeSecurityGroupEgress, RevokeSecurityGroupEgress and DescribeSecurityGroups only) One or more prefix list IDs for an AWS service. In an AuthorizeSecurityGroupEgress request, this is the AWS service that you want to access through a VPC endpoint from instances associated with the security group.
    public void setPrefixListIds(java.util.Collection<PrefixListIdprefixListIds) {
        if (prefixListIds == null) {
            this. = null;
            return;
        }
        prefixListIdsCopy.addAll(prefixListIds);
        this. = prefixListIdsCopy;
    }
    
    
(Valid for AuthorizeSecurityGroupEgress, RevokeSecurityGroupEgress and DescribeSecurityGroups only) One or more prefix list IDs for an AWS service. In an AuthorizeSecurityGroupEgress request, this is the AWS service that you want to access through a VPC endpoint from instances associated with the security group.

NOTE: This method appends the values to the existing list (if any). Use setPrefixListIds(java.util.Collection) or withPrefixListIds(java.util.Collection) if you want to override the existing values.

Returns a reference to this object so that method calls can be chained together.

Parameters:
prefixListIds (Valid for AuthorizeSecurityGroupEgress, RevokeSecurityGroupEgress and DescribeSecurityGroups only) One or more prefix list IDs for an AWS service. In an AuthorizeSecurityGroupEgress request, this is the AWS service that you want to access through a VPC endpoint from instances associated with the security group.
Returns:
A reference to this updated object so that method calls can be chained together.
    public IpPermission withPrefixListIds(PrefixListId... prefixListIds) {
        if (getPrefixListIds() == nullsetPrefixListIds(new java.util.ArrayList<PrefixListId>(prefixListIds.length));
        for (PrefixListId value : prefixListIds) {
            getPrefixListIds().add(value);
        }
        return this;
    }
    
    
(Valid for AuthorizeSecurityGroupEgress, RevokeSecurityGroupEgress and DescribeSecurityGroups only) One or more prefix list IDs for an AWS service. In an AuthorizeSecurityGroupEgress request, this is the AWS service that you want to access through a VPC endpoint from instances associated with the security group.

Returns a reference to this object so that method calls can be chained together.

Parameters:
prefixListIds (Valid for AuthorizeSecurityGroupEgress, RevokeSecurityGroupEgress and DescribeSecurityGroups only) One or more prefix list IDs for an AWS service. In an AuthorizeSecurityGroupEgress request, this is the AWS service that you want to access through a VPC endpoint from instances associated with the security group.
Returns:
A reference to this updated object so that method calls can be chained together.
    public IpPermission withPrefixListIds(java.util.Collection<PrefixListIdprefixListIds) {
        if (prefixListIds == null) {
            this. = null;
        } else {
            com.amazonaws.internal.ListWithAutoConstructFlag<PrefixListIdprefixListIdsCopy = new com.amazonaws.internal.ListWithAutoConstructFlag<PrefixListId>(prefixListIds.size());
            prefixListIdsCopy.addAll(prefixListIds);
            this. = prefixListIdsCopy;
        }
        return this;
    }

    
Returns a string representation of this object; useful for testing and debugging.

Returns:
A string representation of this object.
See also:
java.lang.Object.toString()
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getIpProtocol() != nullsb.append("IpProtocol: " + getIpProtocol() + ",");
        if (getFromPort() != nullsb.append("FromPort: " + getFromPort() + ",");
        if (getToPort() != nullsb.append("ToPort: " + getToPort() + ",");
        if (getUserIdGroupPairs() != nullsb.append("UserIdGroupPairs: " + getUserIdGroupPairs() + ",");
        if (getIpRanges() != nullsb.append("IpRanges: " + getIpRanges() + ",");
        if (getPrefixListIds() != nullsb.append("PrefixListIds: " + getPrefixListIds() );
        sb.append("}");
        return sb.toString();
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;
        
        hashCode = prime * hashCode + ((getIpProtocol() == null) ? 0 : getIpProtocol().hashCode()); 
        hashCode = prime * hashCode + ((getFromPort() == null) ? 0 : getFromPort().hashCode()); 
        hashCode = prime * hashCode + ((getToPort() == null) ? 0 : getToPort().hashCode()); 
        hashCode = prime * hashCode + ((getUserIdGroupPairs() == null) ? 0 : getUserIdGroupPairs().hashCode()); 
        hashCode = prime * hashCode + ((getIpRanges() == null) ? 0 : getIpRanges().hashCode()); 
        hashCode = prime * hashCode + ((getPrefixListIds() == null) ? 0 : getPrefixListIds().hashCode()); 
        return hashCode;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == objreturn true;
        if (obj == nullreturn false;
        if (obj instanceof IpPermission == falsereturn false;
        IpPermission other = (IpPermission)obj;
        
        if (other.getIpProtocol() == null ^ this.getIpProtocol() == nullreturn false;
        if (other.getIpProtocol() != null && other.getIpProtocol().equals(this.getIpProtocol()) == falsereturn false
        if (other.getFromPort() == null ^ this.getFromPort() == nullreturn false;
        if (other.getFromPort() != null && other.getFromPort().equals(this.getFromPort()) == falsereturn false
        if (other.getToPort() == null ^ this.getToPort() == nullreturn false;
        if (other.getToPort() != null && other.getToPort().equals(this.getToPort()) == falsereturn false
        if (other.getUserIdGroupPairs() == null ^ this.getUserIdGroupPairs() == nullreturn false;
        if (other.getUserIdGroupPairs() != null && other.getUserIdGroupPairs().equals(this.getUserIdGroupPairs()) == falsereturn false
        if (other.getIpRanges() == null ^ this.getIpRanges() == nullreturn false;
        if (other.getIpRanges() != null && other.getIpRanges().equals(this.getIpRanges()) == falsereturn false
        if (other.getPrefixListIds() == null ^ this.getPrefixListIds() == nullreturn false;
        if (other.getPrefixListIds() != null && other.getPrefixListIds().equals(this.getPrefixListIds()) == falsereturn false
        return true;
    }
    
    @Override
    public IpPermission clone() {
        try {
            return (IpPermissionsuper.clone();
        
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException(
                    "Got a CloneNotSupportedException from Object.clone() "
                    + "even though we're Cloneable!",
                    e);
        }
        
    }
}
    
New to GrepCode? Check out our FAQ X