describeAlarmsForMetric method

Future<DescribeAlarmsForMetricOutput> describeAlarmsForMetric({
  1. required String metricName,
  2. required String namespace,
  3. List<Dimension>? dimensions,
  4. String? extendedStatistic,
  5. int? period,
  6. Statistic? statistic,
  7. StandardUnit? unit,
})

Retrieves the alarms for the specified metric. To filter the results, specify a statistic, period, or unit.

This operation retrieves only standard alarms that are based on the specified metric. It does not return alarms based on math expressions that use the specified metric, or composite alarms that use the specified metric.

Parameter metricName : The name of the metric.

Parameter namespace : The namespace of the metric.

Parameter dimensions : The dimensions associated with the metric. If the metric has any associated dimensions, you must specify them in order for the call to succeed.

Parameter extendedStatistic : The percentile statistic for the metric. Specify a value between p0.0 and p100.

Parameter period : The period, in seconds, over which the statistic is applied.

Parameter statistic : The statistic for the metric, other than percentiles. For percentile statistics, use ExtendedStatistics.

Parameter unit : The unit for the metric.

Implementation

Future<DescribeAlarmsForMetricOutput> describeAlarmsForMetric({
  required String metricName,
  required String namespace,
  List<Dimension>? dimensions,
  String? extendedStatistic,
  int? period,
  Statistic? statistic,
  StandardUnit? unit,
}) async {
  ArgumentError.checkNotNull(metricName, 'metricName');
  _s.validateStringLength(
    'metricName',
    metricName,
    1,
    255,
    isRequired: true,
  );
  ArgumentError.checkNotNull(namespace, 'namespace');
  _s.validateStringLength(
    'namespace',
    namespace,
    1,
    255,
    isRequired: true,
  );
  _s.validateNumRange(
    'period',
    period,
    1,
    1152921504606846976,
  );
  final $request = <String, dynamic>{};
  $request['MetricName'] = metricName;
  $request['Namespace'] = namespace;
  dimensions?.also((arg) => $request['Dimensions'] = arg);
  extendedStatistic?.also((arg) => $request['ExtendedStatistic'] = arg);
  period?.also((arg) => $request['Period'] = arg);
  statistic?.also((arg) => $request['Statistic'] = arg.toValue());
  unit?.also((arg) => $request['Unit'] = arg.toValue());
  final $result = await _protocol.send(
    $request,
    action: 'DescribeAlarmsForMetric',
    version: '2010-08-01',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    shape: shapes['DescribeAlarmsForMetricInput'],
    shapes: shapes,
    resultWrapper: 'DescribeAlarmsForMetricResult',
  );
  return DescribeAlarmsForMetricOutput.fromXml($result);
}