IoT / Client / create_command

create_command

IoT.Client.create_command(**kwargs)

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

See also: AWS API Documentation

Request Syntax

response = client.create_command(
    commandId='string',
    namespace='AWS-IoT'|'AWS-IoT-FleetWise',
    displayName='string',
    description='string',
    payload={
        'content': b'bytes',
        'contentType': 'string'
    },
    payloadTemplate='string',
    preprocessor={
        'awsJsonSubstitution': {
            'outputFormat': 'JSON'|'CBOR'
        }
    },
    mandatoryParameters=[
        {
            'name': 'string',
            'type': 'STRING'|'INTEGER'|'DOUBLE'|'LONG'|'UNSIGNEDLONG'|'BOOLEAN'|'BINARY',
            'value': {
                'S': 'string',
                'B': True|False,
                'I': 123,
                'L': 123,
                'D': 123.0,
                'BIN': b'bytes',
                'UL': 'string'
            },
            'defaultValue': {
                'S': 'string',
                'B': True|False,
                'I': 123,
                'L': 123,
                'D': 123.0,
                'BIN': b'bytes',
                'UL': 'string'
            },
            'valueConditions': [
                {
                    'comparisonOperator': 'EQUALS'|'NOT_EQUALS'|'LESS_THAN'|'LESS_THAN_EQUALS'|'GREATER_THAN'|'GREATER_THAN_EQUALS'|'IN_SET'|'NOT_IN_SET'|'IN_RANGE'|'NOT_IN_RANGE',
                    'operand': {
                        'number': 'string',
                        'numbers': [
                            'string',
                        ],
                        'string': 'string',
                        'strings': [
                            'string',
                        ],
                        'numberRange': {
                            'min': 'string',
                            'max': 'string'
                        }
                    }
                },
            ],
            'description': 'string'
        },
    ],
    roleArn='string',
    tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ]
)
Parameters:
  • commandId (string) –

    [REQUIRED]

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

  • namespace (string) – The namespace of the command. The MQTT reserved topics and validations will be used for command executions according to the namespace setting.

  • displayName (string) – 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 (string) – A short text decription of the command.

  • payload (dict) –

    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.

    • content (bytes) –

      The static payload file for the command.

    • contentType (string) –

      The content type that specifies the format type of the payload file. This field must use a type/subtype format, such as application/json. For information about various content types, see Common MIME types.

  • payloadTemplate (string) –

    The payload template for the dynamic command.

    Note

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

  • preprocessor (dict) –

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

    Note

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

    • awsJsonSubstitution (dict) –

      Configuration for the JSON substitution preprocessor.

      • outputFormat (string) – [REQUIRED]

        Converts the command preprocessor result to the format defined by this parameter, before sending it to the device.

  • mandatoryParameters (list) –

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

    • (dict) –

      A map of key-value pairs that describe the command.

      • name (string) – [REQUIRED]

        The name of a specific parameter used in a command and command execution.

      • type (string) –

        The type of the command parameter.

      • value (dict) –

        Parameter value that overrides the default value, if set.

        • S (string) –

          An attribute of type String. For example:

          "S": "Hello"

        • B (boolean) –

          An attribute of type Boolean. For example:

          "BOOL": true

        • I (integer) –

          An attribute of type Integer (Thirty-Two Bits).

        • L (integer) –

          An attribute of type Long.

        • D (float) –

          An attribute of type Double (Sixty-Four Bits).

        • BIN (bytes) –

          An attribute of type Binary. For example:

          "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk"

        • UL (string) –

          An attribute of type unsigned long.

      • defaultValue (dict) –

        The default value used to describe the command. This is the value assumed by the parameter if no other value is assigned to it.

        • S (string) –

          An attribute of type String. For example:

          "S": "Hello"

        • B (boolean) –

          An attribute of type Boolean. For example:

          "BOOL": true

        • I (integer) –

          An attribute of type Integer (Thirty-Two Bits).

        • L (integer) –

          An attribute of type Long.

        • D (float) –

          An attribute of type Double (Sixty-Four Bits).

        • BIN (bytes) –

          An attribute of type Binary. For example:

          "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk"

        • UL (string) –

          An attribute of type unsigned long.

      • valueConditions (list) –

        The list of conditions that a command parameter value must satisfy to create a command execution.

        • (dict) –

          A condition for the command parameter that must be evaluated to true for successful creation of a command execution.

          • comparisonOperator (string) – [REQUIRED]

            The comparison operator for the command parameter.

            Note

            IN_RANGE, and NOT_IN_RANGE operators include boundary values.

          • operand (dict) – [REQUIRED]

            The comparison operand for the command parameter.

            • number (string) –

              An operand of number value type, defined as a string.

            • numbers (list) –

              A List of operands of numerical value type, defined as strings.

              • (string) –

            • string (string) –

              An operand of string value type.

            • strings (list) –

              A List of operands of string value type.

              • (string) –

            • numberRange (dict) –

              An operand of numerical range value type.

              • min (string) – [REQUIRED]

                The minimum value of a numerical range of a command parameter value.

              • max (string) – [REQUIRED]

                The maximum value of a numerical range of a command parameter value.

      • description (string) –

        The description of the command parameter.

  • roleArn (string) – 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 (list) –

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

    • (dict) –

      A set of key/value pairs that are used to manage the resource.

      • Key (string) – [REQUIRED]

        The tag’s key.

      • Value (string) –

        The tag’s value.

Return type:

dict

Returns:

Response Syntax

{
    'commandId': 'string',
    'commandArn': 'string'
}

Response Structure

  • (dict) –

    • commandId (string) –

      The unique identifier for the command.

    • commandArn (string) –

      The Amazon Resource Number (ARN) of the command. For example, arn:aws:iot:<region>:<accountid>:command/<commandId>

Exceptions

  • IoT.Client.exceptions.ValidationException

  • IoT.Client.exceptions.ConflictException

  • IoT.Client.exceptions.ServiceQuotaExceededException

  • IoT.Client.exceptions.ThrottlingException

  • IoT.Client.exceptions.InternalServerException