Skip to content

create_command

create_command(
    command_id: CommandId,
    *,
    config_overrides: Optional[IoTClientConfig] = None,
    namespace: Optional[CommandNamespace] = None,
    display_name: Optional[DisplayName] = None,
    description: Optional[CommandDescription] = None,
    payload: Optional[CommandPayload] = None,
    payload_template: Optional[CommandPayloadTemplateString] = None,
    preprocessor: Optional[CommandPreprocessor] = None,
    mandatory_parameters: Optional[CommandParameterList] = None,
    role_arn: Optional[RoleArn] = None,
    tags: Optional[TagList] = None,
) -> CreateCommandResponse

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

Parameters:

  • command_id (CommandId) –

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

  • namespace (Optional[CommandNamespace], default: None ) –

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

  • display_name (Optional[DisplayName], default: None ) –

    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.

  • description (Optional[CommandDescription], default: None ) –

    A short text decription of the command.

  • payload (Optional[CommandPayload], default: None ) –

    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.

  • payload_template (Optional[CommandPayloadTemplateString], default: None ) –

    The payload template for the dynamic command.

    This parameter is required for dynamic commands where the command execution placeholders are supplied either from mandatoryParameters or when StartCommandExecution is invoked.

  • preprocessor (Optional[CommandPreprocessor], default: None ) –

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

    This parameter is required for dynamic commands, along with payloadTemplate, and mandatoryParameters.

  • mandatory_parameters (Optional[CommandParameterList], default: None ) –

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

  • role_arn (Optional[RoleArn], default: None ) –

    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.

  • tags (Optional[TagList], default: None ) –

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

Raises:

Source code in docs_src/capo_iot/_services/io_t.py
def create_command(
    self,
    command_id: "capo_iot.types.command_id.CommandId",
    *,
    config_overrides: Optional[IoTClientConfig] = None,
    namespace: Optional["capo_iot.types.command_namespace.CommandNamespace"] = None,
    display_name: Optional["capo_iot.types.display_name.DisplayName"] = None,
    description: Optional[
        "capo_iot.types.command_description.CommandDescription"
    ] = None,
    payload: Optional["capo_iot.types.command_payload.CommandPayload"] = None,
    payload_template: Optional[
        "capo_iot.types.command_payload_template_string.CommandPayloadTemplateString"
    ] = None,
    preprocessor: Optional[
        "capo_iot.types.command_preprocessor.CommandPreprocessor"
    ] = None,
    mandatory_parameters: Optional[
        "capo_iot.types.command_parameter_list.CommandParameterList"
    ] = None,
    role_arn: Optional["capo_iot.types.role_arn.RoleArn"] = None,
    tags: Optional["capo_iot.types.tag_list.TagList"] = None,
) -> "capo_iot.types.create_command_response.CreateCommandResponse":
    """<p>Creates a command. A command contains reusable configurations that can be applied before they are sent to the devices.</p>

    Args:
        command_id: <p>A unique identifier for the command. We recommend using UUID. Alpha-numeric characters, hyphens, and underscores are valid for use here.</p>
        namespace: <p>The namespace of the command. The MQTT reserved topics and validations will be used for command executions according to the namespace setting.</p>
        display_name: <p>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.</p>
        description: <p>A short text decription of the command.</p>
        payload: <p>The payload object for the static command.</p> <p>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.</p>
        payload_template: <p>The payload template for the dynamic command.</p> <note> <p>This parameter is required for dynamic commands where the command execution placeholders are supplied either from <code>mandatoryParameters</code> or when <code>StartCommandExecution</code> is invoked.</p> </note>
        preprocessor: <p>Configuration that determines how <code>payloadTemplate</code> is processed to generate command execution payload.</p> <note> <p>This parameter is required for dynamic commands, along with <code>payloadTemplate</code>, and <code>mandatoryParameters</code>.</p> </note>
        mandatory_parameters: <p>A list of parameters that are used by <code>StartCommandExecution</code> API for execution payload generation.</p>
        role_arn: <p>The IAM role that you must provide when using the <code>AWS-IoT-FleetWise</code> 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 <code>AWS-IoT</code> namespace.</p>
        tags: <p>Name-value pairs that are used as metadata to manage a command.</p>

    Raises:
        capo_iot.errors.conflict_exception.ConflictException: <p>The request conflicts with the current state of the resource.</p>
        capo_iot.errors.internal_server_exception.InternalServerException: <p>Internal error from the service that indicates an unexpected error or that the service is unavailable.</p>
        capo_iot.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>Service quota has been exceeded.</p>
        capo_iot.errors.throttling_exception.ThrottlingException: <p>The rate exceeds the limit.</p>
        capo_iot.errors.validation_exception.ValidationException: <p>The request is not valid.</p>
        capo_iot.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_iot.types.create_command_request.CreateCommandRequest]",
    ) -> OperationResponse[
        "capo_iot.types.create_command_response.CreateCommandResponse"
    ]:
        import capo_iot._operations.aws_iot_service.create_command

        output, http_response = (
            capo_iot._operations.aws_iot_service.create_command.create_command(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateCommand")
    )
    input_: capo_iot.types.create_command_request.CreateCommandRequest = {
        "command_id": command_id
    }
    if namespace is not None:
        input_["namespace"] = namespace
    if display_name is not None:
        input_["display_name"] = display_name
    if description is not None:
        input_["description"] = description
    if payload is not None:
        input_["payload"] = payload
    if payload_template is not None:
        input_["payload_template"] = payload_template
    if preprocessor is not None:
        input_["preprocessor"] = preprocessor
    if mandatory_parameters is not None:
        input_["mandatory_parameters"] = mandatory_parameters
    if role_arn is not None:
        input_["role_arn"] = role_arn
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output