startCommandExecution method
Using the command created with the CreateCommand API, start a
command execution on a specific device.
May throw ConflictException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter commandArn :
The Amazon Resource Number (ARN) of the command. For example,
arn:aws:iot:
Parameter targetArn :
The Amazon Resource Number (ARN) of the device where the command execution
is occurring.
Parameter clientToken :
The client token is used to implement idempotency. It ensures that the
request completes no more than one time. If you retry a request with the
same token and the same parameters, the request will complete
successfully. However, if you retry the request using the same token but
different parameters, an HTTP 409 conflict occurs. If you omit this value,
Amazon Web Services SDKs will automatically generate a unique client
request.
Parameter executionTimeoutSeconds :
Specifies the amount of time in second the device has to finish the
command execution. A timer is started as soon as 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.
Parameter parameters :
A list of parameters that are required by the
StartCommandExecution API when performing the command on a
device.
Implementation
Future<StartCommandExecutionResponse> startCommandExecution({
required String commandArn,
required String targetArn,
String? clientToken,
int? executionTimeoutSeconds,
Map<String, CommandParameterValue>? parameters,
}) async {
_s.validateNumRange(
'executionTimeoutSeconds',
executionTimeoutSeconds,
1,
1152921504606846976,
);
final $payload = <String, dynamic>{
'commandArn': commandArn,
'targetArn': targetArn,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (executionTimeoutSeconds != null)
'executionTimeoutSeconds': executionTimeoutSeconds,
if (parameters != null) 'parameters': parameters,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/command-executions',
exceptionFnMap: _exceptionFns,
);
return StartCommandExecutionResponse.fromJson(response);
}