describeAlarmHistory method
Retrieves the history for the specified alarm. You can filter the results by date range or item type. If an alarm name is not specified, the histories for either all metric alarms or all composite alarms are returned.
CloudWatch retains the history of an alarm even if you delete the alarm.
To use this operation and return information about a composite alarm, you
must be signed on with the cloudwatch:DescribeAlarmHistory
permission that is scoped to *. You can't return information
about composite alarms if your
cloudwatch:DescribeAlarmHistory permission has a narrower
scope.
May throw InvalidNextToken.
Parameter alarmContributorId :
The unique identifier of a specific alarm contributor to filter the alarm
history results.
Parameter alarmName :
The name of the alarm.
Parameter alarmTypes :
Use this parameter to specify whether you want the operation to return
metric alarms or composite alarms. If you omit this parameter, only metric
alarms are returned.
Parameter endDate :
The ending date to retrieve alarm history.
Parameter historyItemType :
The type of alarm histories to retrieve.
Parameter maxRecords :
The maximum number of alarm history records to retrieve.
Parameter nextToken :
The token returned by a previous call to indicate that there is more data
available.
Parameter scanBy :
Specified whether to return the newest or oldest alarm history first.
Specify TimestampDescending to have the newest event history
returned first, and specify TimestampAscending to have the
oldest history returned first.
Parameter startDate :
The starting date to retrieve alarm history.
Implementation
Future<DescribeAlarmHistoryOutput> describeAlarmHistory({
String? alarmContributorId,
String? alarmName,
List<AlarmType>? alarmTypes,
DateTime? endDate,
HistoryItemType? historyItemType,
int? maxRecords,
String? nextToken,
ScanBy? scanBy,
DateTime? startDate,
}) async {
_s.validateNumRange(
'maxRecords',
maxRecords,
1,
100,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.0',
'X-Amz-Target': 'GraniteServiceVersion20100801.DescribeAlarmHistory'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
if (alarmContributorId != null)
'AlarmContributorId': alarmContributorId,
if (alarmName != null) 'AlarmName': alarmName,
if (alarmTypes != null)
'AlarmTypes': alarmTypes.map((e) => e.value).toList(),
if (endDate != null) 'EndDate': unixTimestampToJson(endDate),
if (historyItemType != null) 'HistoryItemType': historyItemType.value,
if (maxRecords != null) 'MaxRecords': maxRecords,
if (nextToken != null) 'NextToken': nextToken,
if (scanBy != null) 'ScanBy': scanBy.value,
if (startDate != null) 'StartDate': unixTimestampToJson(startDate),
},
);
return DescribeAlarmHistoryOutput.fromJson(jsonResponse.body);
}