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

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

Introduction

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

Prototype


public String getAlarmNamePrefix() 

Source Link

Document

The alarm name prefix.

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 ww.j  av a 2s .com*/
    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);
    }
}