createCommand method

Future<CreateCommandResponse> createCommand({
  1. required String commandId,
  2. String? description,
  3. String? displayName,
  4. List<CommandParameter>? mandatoryParameters,
  5. CommandNamespace? namespace,
  6. CommandPayload? payload,
  7. String? payloadTemplate,
  8. CommandPreprocessor? preprocessor,
  9. String? roleArn,
  10. List<Tag>? tags,
})

Creates a command. A command contains reusable configurations that can be applied before they are sent to the devices.

May throw ConflictException. May throw InternalServerException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter commandId : A unique identifier for the command. We recommend using UUID. Alpha-numeric characters, hyphens, and underscores are valid for use here.

Parameter description : A short text decription of the command.

Parameter displayName : The user-friendly name in the console for the command. This name doesn't have to be unique. You can update the user-friendly name after you define it.

Parameter mandatoryParameters : A list of parameters that are used by StartCommandExecution API for execution payload generation.

Parameter namespace : The namespace of the command. The MQTT reserved topics and validations will be used for command executions according to the namespace setting.

Parameter payload : The payload object for the static command.

You can upload a static payload file from your local storage that contains the instructions for the device to process. The payload file can use any format. To make sure that the device correctly interprets the payload, we recommend you to specify the payload content type.

Parameter payloadTemplate : The payload template for the dynamic command.

Parameter preprocessor : Configuration that determines how payloadTemplate is processed to generate command execution payload.

Parameter roleArn : The IAM role that you must provide when using the AWS-IoT-FleetWise namespace. The role grants IoT Device Management the permission to access IoT FleetWise resources for generating the payload for the command. This field is not supported when you use the AWS-IoT namespace.

Parameter tags : Name-value pairs that are used as metadata to manage a command.

Implementation

Future<CreateCommandResponse> createCommand({
  required String commandId,
  String? description,
  String? displayName,
  List<CommandParameter>? mandatoryParameters,
  CommandNamespace? namespace,
  CommandPayload? payload,
  String? payloadTemplate,
  CommandPreprocessor? preprocessor,
  String? roleArn,
  List<Tag>? tags,
}) async {
  final $payload = <String, dynamic>{
    if (description != null) 'description': description,
    if (displayName != null) 'displayName': displayName,
    if (mandatoryParameters != null)
      'mandatoryParameters': mandatoryParameters,
    if (namespace != null) 'namespace': namespace.value,
    if (payload != null) 'payload': payload,
    if (payloadTemplate != null) 'payloadTemplate': payloadTemplate,
    if (preprocessor != null) 'preprocessor': preprocessor,
    if (roleArn != null) 'roleArn': roleArn,
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri: '/commands/${Uri.encodeComponent(commandId)}',
    exceptionFnMap: _exceptionFns,
  );
  return CreateCommandResponse.fromJson(response);
}