AWS IoT Data Plane

2021/08/24 - AWS IoT Data Plane - 2 new 1 updated api methods

Changes  Updated Publish with support for new Retain flag and added two new API operations: GetRetainedMessage, ListRetainedMessages.

ListRetainedMessages (new) Link ¶

Lists summary information about the retained messages stored for the account.

This action returns only the topic names of the retained messages. It doesn't return any message payloads. Although this action doesn't return a message payload, it can still incur messaging costs.

To get the message payload of a retained message, call GetRetainedMessage with the topic name of the retained message.

Requires permission to access the ListRetainedMessages action.

For more information about messaging costs, see IoT Core pricing - Messaging.

See also: AWS API Documentation

Request Syntax

client.list_retained_messages(
    nextToken='string',
    maxResults=123
)
type nextToken

string

param nextToken

To retrieve the next set of results, the nextToken value from a previous response; otherwise null to receive the first set of results.

type maxResults

integer

param maxResults

The maximum number of results to return at one time.

rtype

dict

returns

Response Syntax

{
    'retainedTopics': [
        {
            'topic': 'string',
            'payloadSize': 123,
            'qos': 123,
            'lastModifiedTime': 123
        },
    ],
    'nextToken': 'string'
}

Response Structure

  • (dict) --

    • retainedTopics (list) --

      A summary list the account's retained messages. The information returned doesn't include the message payloads of the retained messages.

      • (dict) --

        Information about a single retained message.

        • topic (string) --

          The topic name to which the retained message was published.

        • payloadSize (integer) --

          The size of the retained message's payload in bytes.

        • qos (integer) --

          The quality of service (QoS) level used to publish the retained message.

        • lastModifiedTime (integer) --

          The Epoch date and time, in milliseconds, when the retained message was stored by IoT.

    • nextToken (string) --

      The token for the next set of results, or null if there are no additional results.

GetRetainedMessage (new) Link ¶

Gets the details of a single retained message for the specified topic.

This action returns the message payload of the retained message, which can incur messaging costs. To list only the topic names of the retained messages, call ListRetainedMessages.

Requires permission to access the GetRetainedMessage action.

For more information about messaging costs, see IoT Core pricing - Messaging.

See also: AWS API Documentation

Request Syntax

client.get_retained_message(
    topic='string'
)
type topic

string

param topic

[REQUIRED]

The topic name of the retained message to retrieve.

rtype

dict

returns

Response Syntax

{
    'topic': 'string',
    'payload': b'bytes',
    'qos': 123,
    'lastModifiedTime': 123
}

Response Structure

  • (dict) --

    The output from the GetRetainedMessage operation.

    • topic (string) --

      The topic name to which the retained message was published.

    • payload (bytes) --

      The Base64-encoded message payload of the retained message body.

    • qos (integer) --

      The quality of service (QoS) level used to publish the retained message.

    • lastModifiedTime (integer) --

      The Epoch date and time, in milliseconds, when the retained message was stored by IoT.

Publish (updated) Link ¶
Changes (request)
{'retain': 'boolean'}

Publishes an MQTT message.

Requires permission to access the Publish action.

For more information about MQTT messages, see MQTT Protocol in the IoT Developer Guide.

For more information about messaging costs, see IoT Core pricing - Messaging.

See also: AWS API Documentation

Request Syntax

client.publish(
    topic='string',
    qos=123,
    retain=True|False,
    payload=b'bytes'|file
)
type topic

string

param topic

[REQUIRED]

The name of the MQTT topic.

type qos

integer

param qos

The Quality of Service (QoS) level.

type retain

boolean

param retain

A Boolean value that determines whether to set the RETAIN flag when the message is published.

Setting the RETAIN flag causes the message to be retained and sent to new subscribers to the topic.

Valid values: true | false

Default value: false

type payload

bytes or seekable file-like object

param payload

The message body. MQTT accepts text, binary, and empty (null) message payloads.

Publishing an empty (null) payload with retain = true deletes the retained message identified by topic from IoT Core.

returns

None