createCloudWatchAlarmTemplate method

Future<CreateCloudWatchAlarmTemplateResponse> createCloudWatchAlarmTemplate({
  1. required CloudWatchAlarmTemplateComparisonOperator comparisonOperator,
  2. required int evaluationPeriods,
  3. required String groupIdentifier,
  4. required String metricName,
  5. required String name,
  6. required int period,
  7. required CloudWatchAlarmTemplateStatistic statistic,
  8. required CloudWatchAlarmTemplateTargetResourceType targetResourceType,
  9. required double threshold,
  10. required CloudWatchAlarmTemplateTreatMissingData treatMissingData,
  11. int? datapointsToAlarm,
  12. String? description,
  13. String? requestId,
  14. Map<String, String>? tags,
})

Creates a cloudwatch alarm template to dynamically generate cloudwatch metric alarms on targeted resource types.

May throw BadRequestException. May throw ConflictException. May throw ForbiddenException. May throw InternalServerErrorException. May throw NotFoundException. May throw TooManyRequestsException.

Parameter evaluationPeriods : The number of periods over which data is compared to the specified threshold.

Parameter groupIdentifier : A cloudwatch alarm template group's identifier. Can be either be its id or current name.

Parameter metricName : The name of the metric associated with the alarm. Must be compatible with targetResourceType.

Parameter name : A resource's name. Names must be unique within the scope of a resource type in a specific region.

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

Parameter threshold : The threshold value to compare with the specified statistic.

Parameter datapointsToAlarm : The number of datapoints within the evaluation period that must be breaching to trigger the alarm.

Parameter description : A resource's optional description.

Parameter requestId : An ID that you assign to a create request. This ID ensures idempotency when creating resources.

Implementation

Future<CreateCloudWatchAlarmTemplateResponse> createCloudWatchAlarmTemplate({
  required CloudWatchAlarmTemplateComparisonOperator comparisonOperator,
  required int evaluationPeriods,
  required String groupIdentifier,
  required String metricName,
  required String name,
  required int period,
  required CloudWatchAlarmTemplateStatistic statistic,
  required CloudWatchAlarmTemplateTargetResourceType targetResourceType,
  required double threshold,
  required CloudWatchAlarmTemplateTreatMissingData treatMissingData,
  int? datapointsToAlarm,
  String? description,
  String? requestId,
  Map<String, String>? tags,
}) async {
  final $payload = <String, dynamic>{
    'comparisonOperator': comparisonOperator.value,
    'evaluationPeriods': evaluationPeriods,
    'groupIdentifier': groupIdentifier,
    'metricName': metricName,
    'name': name,
    'period': period,
    'statistic': statistic.value,
    'targetResourceType': targetResourceType.value,
    'threshold': threshold,
    'treatMissingData': treatMissingData.value,
    if (datapointsToAlarm != null) 'datapointsToAlarm': datapointsToAlarm,
    if (description != null) 'description': description,
    'requestId': requestId ?? _s.generateIdempotencyToken(),
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/prod/cloudwatch-alarm-templates',
    exceptionFnMap: _exceptionFns,
  );
  return CreateCloudWatchAlarmTemplateResponse.fromJson(response);
}