Example usage for com.amazonaws.services.elasticloadbalancing.model DescribeTagsRequest DescribeTagsRequest

List of usage examples for com.amazonaws.services.elasticloadbalancing.model DescribeTagsRequest DescribeTagsRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.elasticloadbalancing.model DescribeTagsRequest DescribeTagsRequest.

Prototype

DescribeTagsRequest

Source Link

Usage

From source file:io.macgyver.plugin.cloud.aws.scanner.ELBScanner.java

License:Apache License

protected void writeTagsToNeo4j(DescribeLoadBalancersResult results, Region region,
        AmazonElasticLoadBalancingClient client) {
    if (!results.getLoadBalancerDescriptions().isEmpty()) {

        List<String> loadBalancerNames = results.getLoadBalancerDescriptions().stream()
                .map(lb -> lb.getLoadBalancerName()).collect(Collectors.toList());

        // DescribeTags takes at most 20 names at a time
        for (int i = 0; i < loadBalancerNames.size(); i += DESCRIBE_TAGS_MAX) {
            List<String> subsetNames = loadBalancerNames.subList(i,
                    Math.min(i + DESCRIBE_TAGS_MAX, loadBalancerNames.size()));
            DescribeTagsResult describeTagsResult = client
                    .describeTags(new DescribeTagsRequest().withLoadBalancerNames(subsetNames));
            describeTagsResult.getTagDescriptions().forEach(tag -> {
                try {
                    ObjectNode n = convertAwsObject(tag, region);
                    String elbArn = n.path("aws_arn").asText();

                    String cypher = "merge (x:AwsElb {aws_arn:{aws_arn}}) set x+={props} return x";

                    Preconditions.checkNotNull(neoRx);

                    neoRx.execCypher(cypher, "aws_arn", elbArn, "props", n);
                } catch (RuntimeException e) {
                    logger.warn("problem scanning ELB tags", e);
                }/*  ww  w. jav  a  2s.  c o  m*/
            });
        }
    }
}

From source file:org.lendingclub.mercator.aws.ELBScanner.java

License:Apache License

protected void writeTagsToNeo4j(DescribeLoadBalancersResult results, Region region,
        AmazonElasticLoadBalancingClient client) {
    if (!results.getLoadBalancerDescriptions().isEmpty()) {

        List<String> loadBalancerNames = results.getLoadBalancerDescriptions().stream()
                .map(lb -> lb.getLoadBalancerName()).collect(Collectors.toList());

        // DescribeTags takes at most 20 names at a time
        for (int i = 0; i < loadBalancerNames.size(); i += DESCRIBE_TAGS_MAX) {
            List<String> subsetNames = loadBalancerNames.subList(i,
                    Math.min(i + DESCRIBE_TAGS_MAX, loadBalancerNames.size()));
            DescribeTagsResult describeTagsResult = client
                    .describeTags(new DescribeTagsRequest().withLoadBalancerNames(subsetNames));
            describeTagsResult.getTagDescriptions().forEach(tag -> {
                try {
                    ObjectNode n = convertAwsObject(tag, region);

                    String elbArn = n.path("aws_arn").asText();

                    String cypher = "merge (x:AwsElb {aws_arn:{aws_arn}}) set x+={props} return x";

                    Preconditions.checkNotNull(getNeoRxClient());

                    getNeoRxClient().execCypher(cypher, "aws_arn", elbArn, "props", n).forEach(r -> {
                        getShadowAttributeRemover().removeTagAttributes("AwsElb", n, r);
                    });//  w  ww  .j  a va2s .  c  o m

                } catch (RuntimeException e) {
                    maybeThrow(e, "problem scanning ELB tags");

                }
            });
        }
    }
}