Example usage for com.amazonaws.services.elasticloadbalancing.model DescribeTagsResult getTagDescriptions

List of usage examples for com.amazonaws.services.elasticloadbalancing.model DescribeTagsResult getTagDescriptions

Introduction

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

Prototype


public java.util.List<TagDescription> getTagDescriptions() 

Source Link

Document

Information about the tags.

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);
                }//from  www .j  ava  2 s.  c  om
            });
        }
    }
}

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);
                    });//from w  ww. ja v  a2 s .  c om

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

                }
            });
        }
    }
}