listAuditTasks method

Future<ListAuditTasksResponse> listAuditTasks({
  1. required DateTime endTime,
  2. required DateTime startTime,
  3. int? maxResults,
  4. String? nextToken,
  5. AuditTaskStatus? taskStatus,
  6. AuditTaskType? taskType,
})

Lists the Device Defender audits that have been performed during a given time period.

May throw InvalidRequestException. May throw ThrottlingException. May throw InternalFailureException.

Parameter endTime : The end of the time period.

Parameter startTime : The beginning of the time period. Audit information is retained for a limited time (90 days). Requesting a start time prior to what is retained results in an "InvalidRequestException".

Parameter maxResults : The maximum number of results to return at one time. The default is 25.

Parameter nextToken : The token for the next set of results.

Parameter taskStatus : A filter to limit the output to audits with the specified completion status: can be one of "IN_PROGRESS", "COMPLETED", "FAILED", or "CANCELED".

Parameter taskType : A filter to limit the output to the specified type of audit: can be one of "ON_DEMAND_AUDIT_TASK" or "SCHEDULED__AUDIT_TASK".

Implementation

Future<ListAuditTasksResponse> listAuditTasks({
  required DateTime endTime,
  required DateTime startTime,
  int? maxResults,
  String? nextToken,
  AuditTaskStatus? taskStatus,
  AuditTaskType? taskType,
}) async {
  ArgumentError.checkNotNull(endTime, 'endTime');
  ArgumentError.checkNotNull(startTime, 'startTime');
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    250,
  );
  final $query = <String, List<String>>{
    'endTime': [_s.iso8601ToJson(endTime).toString()],
    'startTime': [_s.iso8601ToJson(startTime).toString()],
    if (maxResults != null) 'maxResults': [maxResults.toString()],
    if (nextToken != null) 'nextToken': [nextToken],
    if (taskStatus != null) 'taskStatus': [taskStatus.toValue()],
    if (taskType != null) 'taskType': [taskType.toValue()],
  };
  final response = await _protocol.send(
    payload: null,
    method: 'GET',
    requestUri: '/audit/tasks',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return ListAuditTasksResponse.fromJson(response);
}