Skip to content

Commit 6682f1d

Browse files
committed
Update scenario_iot_basics.py
1 parent 97aa075 commit 6682f1d

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

python/example_code/iot/scenario_iot_basics.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,18 @@ def run_scenario(self, thing_name, rule_name):
124124
print(f"Created thing: {response['thingName']}")
125125
print(f"Thing ARN: {response['thingArn']}")
126126

127+
input("\nNext, we'll list things. Press Enter to continue...") if self.is_interactive else None
128+
print("\n" + "-" * 88)
129+
print("2. List things")
130+
print("-" * 88)
131+
things = self.iot_wrapper.list_things()
132+
print(f"Found {len(things)} thing(s) in your account")
133+
for thing in things[:5]: # Show first 5
134+
print(f" Thing name: {thing['thingName']}")
135+
127136
input("\nNext, we'll generate a device certificate. Press Enter to continue...") if self.is_interactive else None
128137
print("\n" + "-" * 88)
129-
print("2. Generate a device certificate")
138+
print("3. Generate a device certificate")
130139
print("-" * 88)
131140
cert_response = self.iot_wrapper.create_keys_and_certificate()
132141
self.certificate_arn = cert_response["certificateArn"]
@@ -135,22 +144,22 @@ def run_scenario(self, thing_name, rule_name):
135144

136145
input("\nNext, we'll attach the certificate to the thing. Press Enter to continue...") if self.is_interactive else None
137146
print("\n" + "-" * 88)
138-
print("3. Attach the certificate to the thing")
147+
print("4. Attach the certificate to the thing")
139148
print("-" * 88)
140149
self.iot_wrapper.attach_thing_principal(thing_name, self.certificate_arn)
141150
print(f"Attached certificate to thing: {thing_name}")
142151

143152
input("\nNext, we'll update the thing shadow. Press Enter to continue...") if self.is_interactive else None
144153
print("\n" + "-" * 88)
145-
print("4. Update the thing shadow")
154+
print("5. Update the thing shadow")
146155
print("-" * 88)
147156
shadow_state = {"state": {"reported": {"temperature": 25, "humidity": 50}}}
148157
self.iot_wrapper.update_thing_shadow(thing_name, shadow_state)
149158
print(f"Updated shadow for thing: {thing_name}")
150159

151160
input("\nNext, we'll get the thing shadow. Press Enter to continue...") if self.is_interactive else None
152161
print("\n" + "-" * 88)
153-
print("5. Get the thing shadow")
162+
print("6. Get the thing shadow")
154163
print("-" * 88)
155164
shadow = self.iot_wrapper.get_thing_shadow(thing_name)
156165
print(f"Shadow state: {json.dumps(shadow['state'], indent=2)}")
@@ -164,7 +173,7 @@ def run_scenario(self, thing_name, rule_name):
164173

165174
input("\nNext, we'll list certificates. Press Enter to continue...") if self.is_interactive else None
166175
print("\n" + "-" * 88)
167-
print("7. List certificates")
176+
print("8. List certificates")
168177
print("-" * 88)
169178
certificates = self.iot_wrapper.list_certificates()
170179
print(f"Found {len(certificates)} certificate(s)")
@@ -175,7 +184,7 @@ def run_scenario(self, thing_name, rule_name):
175184

176185
input("\nNext, we'll create a topic rule. Press Enter to continue...") if self.is_interactive else None
177186
print("\n" + "-" * 88)
178-
print("8. Create a topic rule")
187+
print("9. Create a topic rule")
179188
print("-" * 88)
180189
self.iot_wrapper.create_topic_rule(
181190
rule_name, f"device/{thing_name}/data", sns_topic_arn, role_arn
@@ -184,7 +193,7 @@ def run_scenario(self, thing_name, rule_name):
184193

185194
input("\nNext, we'll list topic rules. Press Enter to continue...") if self.is_interactive else None
186195
print("\n" + "-" * 88)
187-
print("9. List topic rules")
196+
print("10. List topic rules")
188197
print("-" * 88)
189198
rules = self.iot_wrapper.list_topic_rules()
190199
print(f"Found {len(rules)} topic rule(s)")
@@ -194,7 +203,7 @@ def run_scenario(self, thing_name, rule_name):
194203

195204
input("\nNext, we'll configure thing indexing. Press Enter to continue...") if self.is_interactive else None
196205
print("\n" + "-" * 88)
197-
print("10. Configure thing indexing")
206+
print("11. Configure thing indexing")
198207
print("-" * 88)
199208
self.iot_wrapper.update_indexing_configuration()
200209
print("Enabled thing indexing")
@@ -203,7 +212,7 @@ def run_scenario(self, thing_name, rule_name):
203212

204213
input("\nNext, we'll search for things. Press Enter to continue...") if self.is_interactive else None
205214
print("\n" + "-" * 88)
206-
print("11. Search for things")
215+
print("12. Search for things")
207216
print("-" * 88)
208217
try:
209218
things = self.iot_wrapper.search_index(f"thingName:{thing_name}")

0 commit comments

Comments
 (0)