GetCommandExecutionCommand

Gets information about the specific command execution on a single device.

Example Syntax

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

import { IoTClient, GetCommandExecutionCommand } from "@aws-sdk/client-iot"; // ES Modules import
// const { IoTClient, GetCommandExecutionCommand } = require("@aws-sdk/client-iot"); // CommonJS import
const client = new IoTClient(config);
const input = { // GetCommandExecutionRequest
  executionId: "STRING_VALUE", // required
  targetArn: "STRING_VALUE", // required
  includeResult: true || false,
};
const command = new GetCommandExecutionCommand(input);
const response = await client.send(command);
// { // GetCommandExecutionResponse
//   executionId: "STRING_VALUE",
//   commandArn: "STRING_VALUE",
//   targetArn: "STRING_VALUE",
//   status: "CREATED" || "IN_PROGRESS" || "SUCCEEDED" || "FAILED" || "REJECTED" || "TIMED_OUT",
//   statusReason: { // StatusReason
//     reasonCode: "STRING_VALUE", // required
//     reasonDescription: "STRING_VALUE",
//   },
//   result: { // CommandExecutionResultMap
//     "<keys>": { // CommandExecutionResult
//       S: "STRING_VALUE",
//       B: true || false,
//       BIN: new Uint8Array(),
//     },
//   },
//   parameters: { // CommandExecutionParameterMap
//     "<keys>": { // CommandParameterValue
//       S: "STRING_VALUE",
//       B: true || false,
//       I: Number("int"),
//       L: Number("long"),
//       D: Number("double"),
//       BIN: new Uint8Array(),
//       UL: "STRING_VALUE",
//     },
//   },
//   executionTimeoutSeconds: Number("long"),
//   createdAt: new Date("TIMESTAMP"),
//   lastUpdatedAt: new Date("TIMESTAMP"),
//   startedAt: new Date("TIMESTAMP"),
//   completedAt: new Date("TIMESTAMP"),
//   timeToLive: new Date("TIMESTAMP"),
// };

GetCommandExecutionCommand Input

See GetCommandExecutionCommandInput for more details

Parameter
Type
Description
executionId
Required
string | undefined

The unique identifier for the command execution. This information is returned as a response of the StartCommandExecution API request.

targetArn
Required
string | undefined

The Amazon Resource Number (ARN) of the device on which the command execution is being performed.

includeResult
boolean | undefined

Can be used to specify whether to include the result of the command execution in the GetCommandExecution API response. Your device can use this field to provide additional information about the command execution. You only need to specify this field when using the AWS-IoT namespace.

GetCommandExecutionCommand Output

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

The Amazon Resource Number (ARN) of the command. For example, arn:aws:iot:::command/

completedAt
Date | undefined

The timestamp, when the command execution was completed.

createdAt
Date | undefined

The timestamp, when the command execution was created.

executionId
string | undefined

The unique identifier of the command execution.

executionTimeoutSeconds
number | undefined

Specifies the amount of time in seconds that the device can take to finish a command execution. A timer starts when the command execution is created. If the command execution status is not set to another terminal state before the timer expires, it will automatically update to TIMED_OUT.

lastUpdatedAt
Date | undefined

The timestamp, when the command execution was last updated.

parameters
Record<string, CommandParameterValue> | undefined

The list of parameters that the StartCommandExecution API used when performing the command on the device.

result
Record<string, CommandExecutionResult> | undefined

The result value for the current state of the command execution. The status provides information about the progress of the command execution. The device can use the result field to share additional details about the execution such as a return value of a remote function call.

If you use the AWS-IoT-FleetWise namespace, then this field is not applicable in the API response.

startedAt
Date | undefined

The timestamp, when the command execution was started.

status
CommandExecutionStatus | undefined

The status of the command execution. After your devices receive the command and start performing the operations specified in the command, it can use the UpdateCommandExecution MQTT API to update the status information.

statusReason
StatusReason | undefined

Your devices can use this parameter to provide additional context about the status of a command execution using a reason code and description.

targetArn
string | undefined

The Amazon Resource Number (ARN) of the device on which the command execution is being performed.

timeToLive
Date | undefined

The time to live (TTL) parameter that indicates the duration for which executions will be retained in your account. The default value is six months.

Throws

Name
Fault
Details
InternalServerException
server

Internal error from the service that indicates an unexpected error or that the service is unavailable.

ResourceNotFoundException
client

The specified resource does not exist.

ThrottlingException
client

The rate exceeds the limit.

ValidationException
client

The request is not valid.

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