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

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

Introduction

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

Prototype


public String getStateValue() 

Source Link

Document

The state value to be used in matching 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>>() {
    };//  ww  w.  jav a2s.c  o  m
    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);
    }
}