Java源码示例:com.amazonaws.services.ec2.model.DescribeInternetGatewaysRequest
示例1
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()));
}
}
}
}
示例2
@Override
public InternetGatewayCollection getInternetGateways(
DescribeInternetGatewaysRequest request) {
ResourceCollectionImpl result =
resource.getCollection("InternetGateways", request);
if (result == null) return null;
return new InternetGatewayCollectionImpl(result);
}
示例3
@Override
public InternetGatewayCollection getInternetGateways(
DescribeInternetGatewaysRequest request) {
ResourceCollectionImpl result =
service.getCollection("InternetGateways", request);
if (result == null) return null;
return new InternetGatewayCollectionImpl(result);
}
示例4
@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);
}
示例5
/**
* 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;
}
示例6
/**
* 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;
}
示例7
@Override
public InternetGatewayCollection getInternetGateways() {
return getInternetGateways((DescribeInternetGatewaysRequest)null);
}
示例8
@Override
public boolean load(DescribeInternetGatewaysRequest request) {
return load(request, null);
}
示例9
@Override
public boolean load(DescribeInternetGatewaysRequest request,
ResultCapture<DescribeInternetGatewaysResult> extractor) {
return resource.load(request, extractor);
}
示例10
/**
* Retrieves the InternetGateways collection referenced by this resource.
*/
InternetGatewayCollection getInternetGateways(
DescribeInternetGatewaysRequest request);
示例11
/**
* 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);
示例12
/**
* 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);
示例13
/**
* Retrieves the InternetGateways collection referenced by this resource.
*/
InternetGatewayCollection getInternetGateways(
DescribeInternetGatewaysRequest request);