ListAuditTasksCommand

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

Requires permission to access the ListAuditTasks  action.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { IoTClient, ListAuditTasksCommand } from "@aws-sdk/client-iot"; // ES Modules import
// const { IoTClient, ListAuditTasksCommand } = require("@aws-sdk/client-iot"); // CommonJS import
const client = new IoTClient(config);
const input = { // ListAuditTasksRequest
  startTime: new Date("TIMESTAMP"), // required
  endTime: new Date("TIMESTAMP"), // required
  taskType: "ON_DEMAND_AUDIT_TASK" || "SCHEDULED_AUDIT_TASK",
  taskStatus: "IN_PROGRESS" || "COMPLETED" || "FAILED" || "CANCELED",
  nextToken: "STRING_VALUE",
  maxResults: Number("int"),
};
const command = new ListAuditTasksCommand(input);
const response = await client.send(command);
// { // ListAuditTasksResponse
//   tasks: [ // AuditTaskMetadataList
//     { // AuditTaskMetadata
//       taskId: "STRING_VALUE",
//       taskStatus: "IN_PROGRESS" || "COMPLETED" || "FAILED" || "CANCELED",
//       taskType: "ON_DEMAND_AUDIT_TASK" || "SCHEDULED_AUDIT_TASK",
//     },
//   ],
//   nextToken: "STRING_VALUE",
// };

ListAuditTasksCommand Input

See ListAuditTasksCommandInput for more details

Parameter
Type
Description
endTime
Required
Date | undefined

The end of the time period.

startTime
Required
Date | undefined

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".

maxResults
number | undefined

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

nextToken
string | undefined

The token for the next set of results.

taskStatus
AuditTaskStatus | undefined

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

taskType
AuditTaskType | undefined

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

ListAuditTasksCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
nextToken
string | undefined

A token that can be used to retrieve the next set of results, or null if there are no additional results.

tasks
AuditTaskMetadata[] | undefined

The audits that were performed during the specified time period.

Throws

Name
Fault
Details
InternalFailureException
server

An unexpected error has occurred.

InvalidRequestException
client

The request is not valid.

ThrottlingException
client

The rate exceeds the limit.

IoTServiceException
Base exception class for all service exceptions from IoT service.