Example usage for com.amazonaws.services.cloudwatch.model DescribeAlarmsRequest getAlarmNames

List of usage examples for com.amazonaws.services.cloudwatch.model DescribeAlarmsRequest getAlarmNames

Introduction

In this page you can find the example usage for com.amazonaws.services.cloudwatch.model DescribeAlarmsRequest getAlarmNames.

Prototype


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

Source Link

Document

The names of the alarms.

Usage

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

License:Apache License

public DescribeAlarmsResult describeAlarms(DescribeAlarmsRequest request) {
    validateEmpty("ActionPrefix", request.getActionPrefix());
    validateEmpty("AlarmNamePrefix", request.getAlarmNamePrefix());

    TypeReference<List<MetricAlarm>> ref = new TypeReference<List<MetricAlarm>>() {
    };/*  w w w. j a v  a  2 s. c  om*/
    String url = config.url() + "/api/v2/aws/alarms;_expand";
    try {
        List<MetricAlarm> metricAlarms = parse(ref, doGet(url));

        List<String> names = request.getAlarmNames();
        String state = request.getStateValue();
        if (shouldFilter(names) || shouldFilter(state)) {
            List<MetricAlarm> mas = new ArrayList<MetricAlarm>();
            for (MetricAlarm ma : metricAlarms) {
                if (matches(names, ma.getAlarmName()) && matches(state, ma.getStateValue()))
                    mas.add(ma);
            }
            metricAlarms = mas;
        }

        return new DescribeAlarmsResult().withMetricAlarms(metricAlarms);
    } catch (IOException e) {
        throw new AmazonClientException("Faled to parse " + url, e);
    }
}