Example usage for com.amazonaws.services.autoscaling.model DescribePoliciesRequest getPolicyNames

List of usage examples for com.amazonaws.services.autoscaling.model DescribePoliciesRequest getPolicyNames

Introduction

In this page you can find the example usage for com.amazonaws.services.autoscaling.model DescribePoliciesRequest getPolicyNames.

Prototype


public java.util.List<String> getPolicyNames() 

Source Link

Document

The names of one or more policies.

Usage

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

License:Apache License

public DescribePoliciesResult describePolicies(DescribePoliciesRequest request) {
    TypeReference<List<ScalingPolicy>> ref = new TypeReference<List<ScalingPolicy>>() {
    };/*w  ww  .  ja  va2 s. co m*/
    String url = config.url() + "/api/v2/aws/scalingPolicies;_expand";
    try {
        List<ScalingPolicy> scalingPolicies = parse(ref, doGet(url));

        String asg = request.getAutoScalingGroupName();
        List<String> names = request.getPolicyNames();
        if (shouldFilter(asg) || shouldFilter(names)) {
            List<ScalingPolicy> sps = new ArrayList<ScalingPolicy>();
            for (ScalingPolicy sp : scalingPolicies) {
                if (matches(asg, sp.getAutoScalingGroupName()) && matches(names, sp.getPolicyName()))
                    sps.add(sp);
            }
            scalingPolicies = sps;
        }

        return new DescribePoliciesResult().withScalingPolicies(scalingPolicies);
    } catch (IOException e) {
        throw new AmazonClientException("Faled to parse " + url, e);
    }
}