diff --git a/awsiot/iotshadow.py b/awsiot/iotshadow.py index a6c28ef7..61b3c6ca 100644 --- a/awsiot/iotshadow.py +++ b/awsiot/iotshadow.py @@ -1187,21 +1187,24 @@ class ShadowDeltaUpdatedEvent(awsiot.ModeledClass): All attributes are None by default, and may be set by keyword in the constructor. Keyword Args: + client_token (str): An opaque token used to correlate requests and responses. Present only if a client token was used in the request. metadata (typing.Dict[str, typing.Any]): Timestamps for the shadow properties that were updated. state (typing.Dict[str, typing.Any]): Shadow properties that were updated. timestamp (datetime.datetime): The time the event was generated by AWS IoT. version (int): The current version of the document for the device's shadow. Attributes: + client_token (str): An opaque token used to correlate requests and responses. Present only if a client token was used in the request. metadata (typing.Dict[str, typing.Any]): Timestamps for the shadow properties that were updated. state (typing.Dict[str, typing.Any]): Shadow properties that were updated. timestamp (datetime.datetime): The time the event was generated by AWS IoT. version (int): The current version of the document for the device's shadow. """ - __slots__ = ['metadata', 'state', 'timestamp', 'version'] + __slots__ = ['client_token', 'metadata', 'state', 'timestamp', 'version'] def __init__(self, *args, **kwargs): + self.client_token = kwargs.get('client_token') self.metadata = kwargs.get('metadata') self.state = kwargs.get('state') self.timestamp = kwargs.get('timestamp') @@ -1215,6 +1218,9 @@ def __init__(self, *args, **kwargs): def from_payload(cls, payload): # type: (typing.Dict[str, typing.Any]) -> ShadowDeltaUpdatedEvent new = cls() + val = payload.get('clientToken') + if val is not None: + new.client_token = val val = payload.get('metadata') if val is not None: new.metadata = val @@ -1711,4 +1717,3 @@ def __init__(self, *args, **kwargs): # for backwards compatibility, read any arguments that used to be accepted by position for key, val in zip(['thing_name'], args): setattr(self, key, val) - diff --git a/samples/shadow.py b/samples/shadow.py index 9e0f9bf8..2b390361 100644 --- a/samples/shadow.py +++ b/samples/shadow.py @@ -154,6 +154,8 @@ def on_shadow_delta_updated(delta): return else: print(" Delta reports that desired value is '{}'. Changing local value...".format(value)) + if (delta.client_token is not None): + print (" ClientToken is: " + delta.client_token) change_shadow_value(value) else: print(" Delta did not report a change in '{}'".format(shadow_property))