Example usage for com.amazonaws.services.ec2.model IpPermission withFromPort

List of usage examples for com.amazonaws.services.ec2.model IpPermission withFromPort

Introduction

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

Prototype


public IpPermission withFromPort(Integer fromPort) 

Source Link

Document

The start of port range for the TCP and UDP protocols, or an ICMP/ICMPv6 type number.

Usage

From source file:com.axemblr.provisionr.amazon.functions.ConvertRuleToIpPermission.java

License:Apache License

@Override
public IpPermission apply(Rule rule) {
    IpPermission permission = new IpPermission().withIpProtocol(rule.getProtocol().toString().toLowerCase())
            .withIpRanges(rule.getCidr());

    if (!rule.getPorts().isEmpty()) {
        permission.withFromPort(rule.getPorts().lowerEndpoint()).withToPort(rule.getPorts().upperEndpoint());
    } else {//from   w ww .  j  av a2s .c o  m
        permission.withFromPort(-1).withToPort(-1);
    }
    return permission;
}

From source file:org.apache.provisionr.amazon.functions.ConvertRuleToIpPermission.java

License:Apache License

@Override
public IpPermission apply(Rule rule) {
    checkNotNull(rule, "rule is null");

    IpPermission permission = new IpPermission().withIpProtocol(rule.getProtocol().toString().toLowerCase())
            .withIpRanges(rule.getCidr());

    if (!rule.getPorts().isEmpty()) {
        permission.withFromPort(rule.getPorts().lowerEndpoint()).withToPort(rule.getPorts().upperEndpoint());
    } else {//from  www .j  a  v a2  s  .  co m
        permission.withFromPort(-1).withToPort(-1);
    }
    return permission;
}