listDeviceEvents method
Using a device ID, returns a DeviceEventsResponse object containing an array of events for the device.
May throw ResourceNotFoundException. May throw RangeNotSatisfiableException. May throw InvalidRequestException. May throw InternalFailureException.
Parameter deviceId
:
The unique identifier of the device.
Parameter fromTimeStamp
:
The start date for the device event query, in ISO8061 format. For example,
2018-03-28T15:45:12.880Z
Parameter toTimeStamp
:
The end date for the device event query, in ISO8061 format. For example,
2018-03-28T15:45:12.880Z
Parameter maxResults
:
The maximum number of results to return per request. If not set, a default
value of
100 is used.
Parameter nextToken
:
The token to retrieve the next set of results.
Implementation
Future<ListDeviceEventsResponse> listDeviceEvents({
required String deviceId,
required DateTime fromTimeStamp,
required DateTime toTimeStamp,
int? maxResults,
String? nextToken,
}) async {
ArgumentError.checkNotNull(deviceId, 'deviceId');
ArgumentError.checkNotNull(fromTimeStamp, 'fromTimeStamp');
ArgumentError.checkNotNull(toTimeStamp, 'toTimeStamp');
_s.validateNumRange(
'maxResults',
maxResults,
1,
250,
);
final $query = <String, List<String>>{
'fromTimeStamp': [_s.iso8601ToJson(fromTimeStamp).toString()],
'toTimeStamp': [_s.iso8601ToJson(toTimeStamp).toString()],
if (maxResults != null) 'maxResults': [maxResults.toString()],
if (nextToken != null) 'nextToken': [nextToken],
};
final response = await _protocol.send(
payload: null,
method: 'GET',
requestUri: '/devices/${Uri.encodeComponent(deviceId)}/events',
queryParams: $query,
exceptionFnMap: _exceptionFns,
);
return ListDeviceEventsResponse.fromJson(response);
}