Skip to content

Add shadow client token #310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions awsiot/iotshadow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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
Expand Down Expand Up @@ -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)

2 changes: 2 additions & 0 deletions samples/shadow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down