Example usage for com.amazonaws.services.ec2.model Vpc getVpcId

List of usage examples for com.amazonaws.services.ec2.model Vpc getVpcId

Introduction

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

Prototype


public String getVpcId() 

Source Link

Document

The ID of the VPC.

Usage

From source file:com.infinitechaos.vpcviewer.web.rest.dto.VpcDTO.java

License:Open Source License

public VpcDTO(final Vpc vpc) {
    this.vpcId = vpc.getVpcId();
    this.cidrBlock = vpc.getCidrBlock();
    this.state = vpc.getState();
    this.tags.addAll(vpc.getTags().stream().map(TagDTO::new).collect(Collectors.toList()));

    this.name = vpc.getTags().stream().filter(t -> t.getKey().equals("Name")).findFirst().map(Tag::getValue)
            .orElse("n/a");
}

From source file:com.netflix.edda.EddaEc2Client.java

License:Apache License

public DescribeVpcsResult describeVpcs(DescribeVpcsRequest request) {
    validateEmpty("Filter", request.getFilters());

    TypeReference<List<Vpc>> ref = new TypeReference<List<Vpc>>() {
    };/*from   w  w  w .j  a v a2  s . com*/
    String url = config.url() + "/api/v2/aws/vpcs;_expand";
    try {
        List<Vpc> vpcs = parse(ref, doGet(url));

        List<String> ids = request.getVpcIds();
        if (shouldFilter(ids)) {
            List<Vpc> vs = new ArrayList<Vpc>();
            for (Vpc v : vpcs) {
                if (matches(ids, v.getVpcId()))
                    vs.add(v);
            }
            vpcs = vs;
        }

        return new DescribeVpcsResult().withVpcs(vpcs);
    } catch (IOException e) {
        throw new AmazonClientException("Faled to parse " + url, e);
    }
}

From source file:com.netflix.spinnaker.clouddriver.aws.deploy.handlers.MigrateSecurityGroupStrategy.java

License:Apache License

private Map<String, String> getVpcMappings(List<NetflixAmazonCredentials> accounts) {
    Map<String, String> mappings = new HashMap<>();
    if (target.getVpcId() == null) {
        return mappings;
    }//from ww w .ja  v a 2  s.  c  o m
    AmazonEC2 baseTarget = getAmazonClientProvider().getAmazonEC2(target.getCredentials(), target.getRegion());
    Vpc targetVpc = baseTarget.describeVpcs().getVpcs().stream()
            .filter(vpc -> vpc.getVpcId().equals(target.getVpcId())).findFirst().orElse(null);

    String targetName = AmazonVpcProvider.getVpcName(targetVpc);

    accounts.forEach(account -> {
        List<Vpc> vpcs = getAmazonClientProvider().getAmazonEC2(account, target.getRegion()).describeVpcs()
                .getVpcs();
        Vpc match = vpcs.stream().filter(vpc -> AmazonVpcProvider.getVpcName(vpc).equals(targetName))
                .findFirst().orElse(null);
        mappings.put(account.getAccountId(), match.getVpcId());
    });
    return mappings;
}

From source file:org.jenkinsci.plugins.amazonwebservices.cloud.EC2.java

License:Open Source License

public static List<String> getVPCs(AmazonEC2 ec2) {
    DescribeVpcsResult ec2res = ec2.describeVpcs();
    List<String> res = new ArrayList<String>();
    for (Vpc v : ec2res.getVpcs()) {
        res.add(v.getVpcId());
    }//  w w w  .ja va  2  s.c o  m
    return res;
}