com.amazonaws.services.ec2.model.DescribeInternetGatewaysRequest Java Examples

The following examples show how to use com.amazonaws.services.ec2.model.DescribeInternetGatewaysRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AwsSetup.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
private void validateExistingIGW(AwsNetworkView awsNetworkView, AmazonEC2 amazonEC2Client) {
    if (awsNetworkView.isExistingIGW()) {
        DescribeInternetGatewaysRequest describeInternetGatewaysRequest = new DescribeInternetGatewaysRequest();
        describeInternetGatewaysRequest.withInternetGatewayIds(awsNetworkView.getExistingIgw());
        DescribeInternetGatewaysResult describeInternetGatewaysResult = amazonEC2Client.describeInternetGateways(describeInternetGatewaysRequest);
        if (describeInternetGatewaysResult.getInternetGateways().size() < 1) {
            throw new CloudConnectorException(String.format(IGW_DOES_NOT_EXIST_MSG, awsNetworkView.getExistingIgw()));
        } else {
            InternetGateway internetGateway = describeInternetGatewaysResult.getInternetGateways().get(0);
            InternetGatewayAttachment attachment = internetGateway.getAttachments().get(0);
            if (attachment != null && !attachment.getVpcId().equals(awsNetworkView.getExistingVpc())) {
                throw new CloudConnectorException(String.format(IGWVPC_DOES_NOT_EXIST_MSG, awsNetworkView.getExistingIgw(),
                        awsNetworkView.getExistingVpc()));
            }
        }
    }
}
 
Example #2
Source File: VpcImpl.java    From aws-sdk-java-resources with Apache License 2.0 5 votes vote down vote up
@Override
public InternetGatewayCollection getInternetGateways(
        DescribeInternetGatewaysRequest request) {

    ResourceCollectionImpl result =
            resource.getCollection("InternetGateways", request);

    if (result == null) return null;
    return new InternetGatewayCollectionImpl(result);
}
 
Example #3
Source File: EC2Impl.java    From aws-sdk-java-resources with Apache License 2.0 5 votes vote down vote up
@Override
public InternetGatewayCollection getInternetGateways(
        DescribeInternetGatewaysRequest request) {

    ResourceCollectionImpl result =
            service.getCollection("InternetGateways", request);

    if (result == null) return null;
    return new InternetGatewayCollectionImpl(result);
}
 
Example #4
Source File: AwsPlatformResources.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Override
public CloudGateWays gateways(CloudCredential cloudCredential, Region region, Map<String, String> filters) {
    AmazonEC2Client ec2Client = awsClient.createAccess(cloudCredential);

    Map<String, Set<CloudGateWay>> resultCloudGateWayMap = new HashMap<>();
    CloudRegions regions = regions(cloudCredential, region, filters, true);

    for (Entry<Region, List<AvailabilityZone>> regionListEntry : regions.getCloudRegions().entrySet()) {
        if (region == null || Strings.isNullOrEmpty(region.value()) || regionListEntry.getKey().value().equals(region.value())) {
            ec2Client.setRegion(RegionUtils.getRegion(regionListEntry.getKey().value()));

            DescribeInternetGatewaysRequest describeInternetGatewaysRequest = new DescribeInternetGatewaysRequest();
            DescribeInternetGatewaysResult describeInternetGatewaysResult = ec2Client.describeInternetGateways(describeInternetGatewaysRequest);

            Set<CloudGateWay> gateWays = new HashSet<>();
            for (InternetGateway internetGateway : describeInternetGatewaysResult.getInternetGateways()) {
                CloudGateWay cloudGateWay = new CloudGateWay();
                cloudGateWay.setId(internetGateway.getInternetGatewayId());
                cloudGateWay.setName(internetGateway.getInternetGatewayId());
                Collection<String> vpcs = new ArrayList<>();
                for (InternetGatewayAttachment internetGatewayAttachment : internetGateway.getAttachments()) {
                    vpcs.add(internetGatewayAttachment.getVpcId());
                }
                Map<String, Object> properties = new HashMap<>();
                properties.put("attachment", vpcs);
                cloudGateWay.setProperties(properties);
                gateWays.add(cloudGateWay);
            }
            for (AvailabilityZone availabilityZone : regionListEntry.getValue()) {
                resultCloudGateWayMap.put(availabilityZone.value(), gateWays);
            }
        }
    }
    return new CloudGateWays(resultCloudGateWayMap);
}
 
Example #5
Source File: BaseTest.java    From aws-mock with MIT License 5 votes vote down vote up
/**
 * Describe internet gateway.
 *
 * @return InternetGateway
 */
protected final InternetGateway getInternetGateway() {
    InternetGateway internetGateway = null;

    DescribeInternetGatewaysRequest req = new DescribeInternetGatewaysRequest();
    DescribeInternetGatewaysResult result = amazonEC2Client.describeInternetGateways(req);
    if (result != null && !result.getInternetGateways().isEmpty()) {
        internetGateway = result.getInternetGateways().get(0);
    }

    return internetGateway;
}
 
Example #6
Source File: BaseTest.java    From aws-mock with MIT License 5 votes vote down vote up
/**
* Describe internet gateways.
*
* @return List of InternetGateway
*/
protected final List<InternetGateway> getInternetGateways() {
   List<InternetGateway> internetGateways = null;
   DescribeInternetGatewaysRequest req = new DescribeInternetGatewaysRequest();
   DescribeInternetGatewaysResult result = amazonEC2Client.describeInternetGateways(req);
   if (result != null && !result.getInternetGateways().isEmpty()) {
       internetGateways = result.getInternetGateways();
   }

   return internetGateways;
}
 
Example #7
Source File: EC2Impl.java    From aws-sdk-java-resources with Apache License 2.0 4 votes vote down vote up
@Override
public InternetGatewayCollection getInternetGateways() {
    return getInternetGateways((DescribeInternetGatewaysRequest)null);
}
 
Example #8
Source File: InternetGatewayImpl.java    From aws-sdk-java-resources with Apache License 2.0 4 votes vote down vote up
@Override
public boolean load(DescribeInternetGatewaysRequest request) {
    return load(request, null);
}
 
Example #9
Source File: InternetGatewayImpl.java    From aws-sdk-java-resources with Apache License 2.0 4 votes vote down vote up
@Override
public boolean load(DescribeInternetGatewaysRequest request,
        ResultCapture<DescribeInternetGatewaysResult> extractor) {

    return resource.load(request, extractor);
}
 
Example #10
Source File: Vpc.java    From aws-sdk-java-resources with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieves the InternetGateways collection referenced by this resource.
 */
InternetGatewayCollection getInternetGateways(
        DescribeInternetGatewaysRequest request);
 
Example #11
Source File: InternetGateway.java    From aws-sdk-java-resources with Apache License 2.0 2 votes vote down vote up
/**
 * Makes a call to the service to load this resource's attributes if they
 * are not loaded yet.
 * The following request parameters will be populated from the data of this
 * <code>InternetGateway</code> resource, and any conflicting parameter
 * value set in the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>InternetGatewayIds.0</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @return Returns {@code true} if the resource is not yet loaded when this
 *         method was invoked, which indicates that a service call has been
 *         made to retrieve the attributes.
 * @see DescribeInternetGatewaysRequest
 */
boolean load(DescribeInternetGatewaysRequest request);
 
Example #12
Source File: InternetGateway.java    From aws-sdk-java-resources with Apache License 2.0 2 votes vote down vote up
/**
 * Makes a call to the service to load this resource's attributes if they
 * are not loaded yet, and use a ResultCapture to retrieve the low-level
 * client response
 * The following request parameters will be populated from the data of this
 * <code>InternetGateway</code> resource, and any conflicting parameter
 * value set in the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>InternetGatewayIds.0</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @return Returns {@code true} if the resource is not yet loaded when this
 *         method was invoked, which indicates that a service call has been
 *         made to retrieve the attributes.
 * @see DescribeInternetGatewaysRequest
 */
boolean load(DescribeInternetGatewaysRequest request,
        ResultCapture<DescribeInternetGatewaysResult> extractor);
 
Example #13
Source File: EC2.java    From aws-sdk-java-resources with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieves the InternetGateways collection referenced by this resource.
 */
InternetGatewayCollection getInternetGateways(
        DescribeInternetGatewaysRequest request);