Skip to content

Commit e2b3929

Browse files
Add shadow client token (#310)
* Added ClientToken to ShadowDeltaUpdated * Add back changing shadow value that was accidentally removed
1 parent c23328c commit e2b3929

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

awsiot/iotshadow.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1187,21 +1187,24 @@ class ShadowDeltaUpdatedEvent(awsiot.ModeledClass):
11871187
All attributes are None by default, and may be set by keyword in the constructor.
11881188
11891189
Keyword Args:
1190+
client_token (str): An opaque token used to correlate requests and responses. Present only if a client token was used in the request.
11901191
metadata (typing.Dict[str, typing.Any]): Timestamps for the shadow properties that were updated.
11911192
state (typing.Dict[str, typing.Any]): Shadow properties that were updated.
11921193
timestamp (datetime.datetime): The time the event was generated by AWS IoT.
11931194
version (int): The current version of the document for the device's shadow.
11941195
11951196
Attributes:
1197+
client_token (str): An opaque token used to correlate requests and responses. Present only if a client token was used in the request.
11961198
metadata (typing.Dict[str, typing.Any]): Timestamps for the shadow properties that were updated.
11971199
state (typing.Dict[str, typing.Any]): Shadow properties that were updated.
11981200
timestamp (datetime.datetime): The time the event was generated by AWS IoT.
11991201
version (int): The current version of the document for the device's shadow.
12001202
"""
12011203

1202-
__slots__ = ['metadata', 'state', 'timestamp', 'version']
1204+
__slots__ = ['client_token', 'metadata', 'state', 'timestamp', 'version']
12031205

12041206
def __init__(self, *args, **kwargs):
1207+
self.client_token = kwargs.get('client_token')
12051208
self.metadata = kwargs.get('metadata')
12061209
self.state = kwargs.get('state')
12071210
self.timestamp = kwargs.get('timestamp')
@@ -1215,6 +1218,9 @@ def __init__(self, *args, **kwargs):
12151218
def from_payload(cls, payload):
12161219
# type: (typing.Dict[str, typing.Any]) -> ShadowDeltaUpdatedEvent
12171220
new = cls()
1221+
val = payload.get('clientToken')
1222+
if val is not None:
1223+
new.client_token = val
12181224
val = payload.get('metadata')
12191225
if val is not None:
12201226
new.metadata = val
@@ -1711,4 +1717,3 @@ def __init__(self, *args, **kwargs):
17111717
# for backwards compatibility, read any arguments that used to be accepted by position
17121718
for key, val in zip(['thing_name'], args):
17131719
setattr(self, key, val)
1714-

samples/shadow.py

+2
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ def on_shadow_delta_updated(delta):
154154
return
155155
else:
156156
print(" Delta reports that desired value is '{}'. Changing local value...".format(value))
157+
if (delta.client_token is not None):
158+
print (" ClientToken is: " + delta.client_token)
157159
change_shadow_value(value)
158160
else:
159161
print(" Delta did not report a change in '{}'".format(shadow_property))

0 commit comments

Comments
 (0)