listDeviceEvents method

Future<ListDeviceEventsResponse> listDeviceEvents({
  1. required String deviceArn,
  2. DeviceEventType? eventType,
  3. int? maxResults,
  4. String? nextToken,
})

Lists the device event history, including device connection status, for up to 30 days.

May throw NotFoundException.

Parameter deviceArn : The ARN of a device.

Parameter eventType : The event type to filter device events. If EventType isn't specified, this returns a list of all device events in reverse chronological order. If EventType is specified, this returns a list of device events for that EventType in reverse chronological order.

Parameter maxResults : The maximum number of results to include in the response. The default value is 50. If more results exist than the specified MaxResults value, a token is included in the response so that the remaining results can be retrieved.

Parameter nextToken : An optional token returned from a prior request. Use this token for pagination of results from this action. If this parameter is specified, the response only includes results beyond the token, up to the value specified by MaxResults. When the end of results is reached, the response has a value of null.

Implementation

Future<ListDeviceEventsResponse> listDeviceEvents({
  required String deviceArn,
  DeviceEventType? eventType,
  int? maxResults,
  String? nextToken,
}) async {
  ArgumentError.checkNotNull(deviceArn, 'deviceArn');
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    50,
  );
  _s.validateStringLength(
    'nextToken',
    nextToken,
    1,
    1100,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AlexaForBusiness.ListDeviceEvents'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'DeviceArn': deviceArn,
      if (eventType != null) 'EventType': eventType.toValue(),
      if (maxResults != null) 'MaxResults': maxResults,
      if (nextToken != null) 'NextToken': nextToken,
    },
  );

  return ListDeviceEventsResponse.fromJson(jsonResponse.body);
}