Skip to content

Commit aa85ac5

Browse files
authored
Python: IoT Basics Backfill (#7700)
1 parent 860ce56 commit aa85ac5

11 files changed

Lines changed: 1293 additions & 1 deletion

File tree

.doc_gen/metadata/iot-data_metadata.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ iot-data-plane_GetThingShadow:
99
- description:
1010
snippet_tags:
1111
- iot.dotnetv4.GetThingShadow
12+
Python:
13+
versions:
14+
- sdk_version: 3
15+
github: python/example_code/iot
16+
excerpts:
17+
- description:
18+
snippet_tags:
19+
- python.example_code.iot.IoTWrapper.decl
20+
- python.example_code.iot.GetThingShadow
1221
Kotlin:
1322
versions:
1423
- sdk_version: 1
@@ -46,6 +55,15 @@ iot-data-plane_UpdateThingShadow:
4655
- description:
4756
snippet_tags:
4857
- iot.dotnetv4.UpdateThingShadow
58+
Python:
59+
versions:
60+
- sdk_version: 3
61+
github: python/example_code/iot
62+
excerpts:
63+
- description:
64+
snippet_tags:
65+
- python.example_code.iot.IoTWrapper.decl
66+
- python.example_code.iot.UpdateThingShadow
4967
Kotlin:
5068
versions:
5169
- sdk_version: 1

.doc_gen/metadata/iot_metadata.yaml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ iot_Hello:
4242
- description: Code for the hello_iot.cpp source file.
4343
snippet_tags:
4444
- cpp.example_code.iot.hello_iot
45+
Python:
46+
versions:
47+
- sdk_version: 3
48+
github: python/example_code/iot
49+
excerpts:
50+
- description:
51+
snippet_tags:
52+
- python.example_code.iot.Hello
4553
services:
4654
iot: {listThings}
4755
iot_DescribeEndpoint:
@@ -87,6 +95,15 @@ iot_DescribeEndpoint:
8795
- description:
8896
snippet_tags:
8997
- cpp.example_code.iot.DescribeEndpoint
98+
Python:
99+
versions:
100+
- sdk_version: 3
101+
github: python/example_code/iot
102+
excerpts:
103+
- description:
104+
snippet_tags:
105+
- python.example_code.iot.IoTWrapper.decl
106+
- python.example_code.iot.DescribeEndpoint
90107
services:
91108
iot: {DescribeEndpoint}
92109
iot_ListThings:
@@ -107,6 +124,15 @@ iot_ListThings:
107124
- description:
108125
snippet_tags:
109126
- iot.rust.list-things
127+
Python:
128+
versions:
129+
- sdk_version: 3
130+
github: python/example_code/iot
131+
excerpts:
132+
- description:
133+
snippet_tags:
134+
- python.example_code.iot.IoTWrapper.decl
135+
- python.example_code.iot.ListThings
110136
services:
111137
iot: {ListThings}
112138
iot_ListCertificates:
@@ -144,6 +170,15 @@ iot_ListCertificates:
144170
- description:
145171
snippet_tags:
146172
- cpp.example_code.iot.ListCertificates
173+
Python:
174+
versions:
175+
- sdk_version: 3
176+
github: python/example_code/iot
177+
excerpts:
178+
- description:
179+
snippet_tags:
180+
- python.example_code.iot.IoTWrapper.decl
181+
- python.example_code.iot.ListCertificates
147182
services:
148183
iot: {ListCertificates}
149184
iot_CreateKeysAndCertificate:
@@ -181,6 +216,15 @@ iot_CreateKeysAndCertificate:
181216
- description:
182217
snippet_tags:
183218
- cpp.example_code.iot.CreateKeysAndCertificate
219+
Python:
220+
versions:
221+
- sdk_version: 3
222+
github: python/example_code/iot
223+
excerpts:
224+
- description:
225+
snippet_tags:
226+
- python.example_code.iot.IoTWrapper.decl
227+
- python.example_code.iot.CreateKeysAndCertificate
184228
services:
185229
iot: {CreateKeysAndCertificate}
186230
iot_DeleteCertificate:
@@ -218,6 +262,15 @@ iot_DeleteCertificate:
218262
- description:
219263
snippet_tags:
220264
- cpp.example_code.iot.DeleteCertificate
265+
Python:
266+
versions:
267+
- sdk_version: 3
268+
github: python/example_code/iot
269+
excerpts:
270+
- description:
271+
snippet_tags:
272+
- python.example_code.iot.IoTWrapper.decl
273+
- python.example_code.iot.DeleteCertificate
221274
services:
222275
iot: {DeleteCertificate}
223276
iot_SearchIndex:
@@ -255,6 +308,15 @@ iot_SearchIndex:
255308
- description:
256309
snippet_tags:
257310
- cpp.example_code.iot.SearchIndex
311+
Python:
312+
versions:
313+
- sdk_version: 3
314+
github: python/example_code/iot
315+
excerpts:
316+
- description:
317+
snippet_tags:
318+
- python.example_code.iot.IoTWrapper.decl
319+
- python.example_code.iot.SearchIndex
258320
services:
259321
iot: {SearchIndex}
260322
iot_UpdateIndexingConfiguration:
@@ -267,6 +329,15 @@ iot_UpdateIndexingConfiguration:
267329
- description:
268330
snippet_tags:
269331
- cpp.example_code.iot.UpdateIndexingConfiguration
332+
Python:
333+
versions:
334+
- sdk_version: 3
335+
github: python/example_code/iot
336+
excerpts:
337+
- description:
338+
snippet_tags:
339+
- python.example_code.iot.IoTWrapper.decl
340+
- python.example_code.iot.UpdateIndexingConfiguration
270341
services:
271342
iot: {UpdateIndexingConfiguration}
272343
iot_DeleteThing:
@@ -304,6 +375,15 @@ iot_DeleteThing:
304375
- description:
305376
snippet_tags:
306377
- cpp.example_code.iot.DeleteThing
378+
Python:
379+
versions:
380+
- sdk_version: 3
381+
github: python/example_code/iot
382+
excerpts:
383+
- description:
384+
snippet_tags:
385+
- python.example_code.iot.IoTWrapper.decl
386+
- python.example_code.iot.DeleteThing
307387
services:
308388
iot: {DeleteThing}
309389
iot_DescribeThing:
@@ -370,6 +450,15 @@ iot_AttachThingPrincipal:
370450
- description:
371451
snippet_tags:
372452
- cpp.example_code.iot.AttachThingPrincipal
453+
Python:
454+
versions:
455+
- sdk_version: 3
456+
github: python/example_code/iot
457+
excerpts:
458+
- description:
459+
snippet_tags:
460+
- python.example_code.iot.IoTWrapper.decl
461+
- python.example_code.iot.AttachThingPrincipal
373462
services:
374463
iot: {AttachThingPrincipal}
375464
iot_DetachThingPrincipal:
@@ -407,6 +496,15 @@ iot_DetachThingPrincipal:
407496
- description:
408497
snippet_tags:
409498
- cpp.example_code.iot.DetachThingPrincipal
499+
Python:
500+
versions:
501+
- sdk_version: 3
502+
github: python/example_code/iot
503+
excerpts:
504+
- description:
505+
snippet_tags:
506+
- python.example_code.iot.IoTWrapper.decl
507+
- python.example_code.iot.DetachThingPrincipal
410508
services:
411509
iot: {DetachThingPrincipal}
412510
iot_UpdateThing:
@@ -473,6 +571,15 @@ iot_CreateTopicRule:
473571
- description:
474572
snippet_tags:
475573
- cpp.example_code.iot.CreateTopicRule
574+
Python:
575+
versions:
576+
- sdk_version: 3
577+
github: python/example_code/iot
578+
excerpts:
579+
- description:
580+
snippet_tags:
581+
- python.example_code.iot.IoTWrapper.decl
582+
- python.example_code.iot.CreateTopicRule
476583
services:
477584
iot: {CreateTopicRule}
478585
iot_DeleteTopicRule:
@@ -485,6 +592,15 @@ iot_DeleteTopicRule:
485592
- description:
486593
snippet_tags:
487594
- cpp.example_code.iot.DeleteTopicRule
595+
Python:
596+
versions:
597+
- sdk_version: 3
598+
github: python/example_code/iot
599+
excerpts:
600+
- description:
601+
snippet_tags:
602+
- python.example_code.iot.IoTWrapper.decl
603+
- python.example_code.iot.DeleteTopicRule
488604
services:
489605
iot: {DeleteTopicRule}
490606
iot_CreateThing:
@@ -522,6 +638,15 @@ iot_CreateThing:
522638
- description:
523639
snippet_tags:
524640
- cpp.example_code.iot.CreateThing
641+
Python:
642+
versions:
643+
- sdk_version: 3
644+
github: python/example_code/iot
645+
excerpts:
646+
- description:
647+
snippet_tags:
648+
- python.example_code.iot.IoTWrapper.decl
649+
- python.example_code.iot.CreateThing
525650
services:
526651
iot: {CreateThing}
527652
iot_Scenario:
@@ -611,5 +736,16 @@ iot_Scenario:
611736
- cpp.example_code.iot.DeleteCertificate
612737
- cpp.example_code.iot.DeleteTopicRule
613738
- cpp.example_code.iot.DeleteThing
739+
Python:
740+
versions:
741+
- sdk_version: 3
742+
github: python/example_code/iot
743+
excerpts:
744+
- description: Create an IoT wrapper class to manage operations.
745+
snippet_tags:
746+
- python.example_code.iot.IoTWrapper
747+
- description: Run an interactive scenario demonstrating IoT basics.
748+
snippet_tags:
749+
- python.example_code.iot.Scenario_GettingStarted
614750
services:
615751
iot: {}

python/example_code/iot/README.md

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,37 @@ python -m pip install -r requirements.txt
3434
<!--custom.prerequisites.start-->
3535
<!--custom.prerequisites.end-->
3636

37+
### Get started
38+
39+
- [Hello AWS IoT](iot_hello.py#L14) (`listThings`)
40+
41+
42+
### Basics
43+
44+
Code examples that show you how to perform the essential operations within a service.
45+
46+
- [Learn the basics](iot_wrapper.py)
47+
48+
49+
### Single actions
50+
51+
Code excerpts that show you how to call individual service functions.
52+
53+
- [AttachThingPrincipal](iot_wrapper.py#L119)
54+
- [CreateKeysAndCertificate](iot_wrapper.py#L94)
55+
- [CreateThing](iot_wrapper.py#L39)
56+
- [CreateTopicRule](iot_wrapper.py#L250)
57+
- [DeleteCertificate](iot_wrapper.py#L224)
58+
- [DeleteThing](iot_wrapper.py#L358)
59+
- [DeleteTopicRule](iot_wrapper.py#L381)
60+
- [DescribeEndpoint](iot_wrapper.py#L145)
61+
- [DetachThingPrincipal](iot_wrapper.py#L198)
62+
- [ListCertificates](iot_wrapper.py#L171)
63+
- [ListThings](iot_wrapper.py#L66)
64+
- [SearchIndex](iot_wrapper.py#L312)
65+
- [UpdateIndexingConfiguration](iot_wrapper.py#L338)
66+
67+
3768
<!--custom.examples.start-->
3869
<!--custom.examples.end-->
3970

@@ -45,6 +76,42 @@ python -m pip install -r requirements.txt
4576
<!--custom.instructions.start-->
4677
<!--custom.instructions.end-->
4778

79+
#### Hello AWS IoT
80+
81+
This example shows you how to get started using AWS IoT.
82+
83+
```
84+
python iot_hello.py
85+
```
86+
87+
#### Learn the basics
88+
89+
This example shows you how to do the following:
90+
91+
- Create an AWS IoT Thing.
92+
- Generate a device certificate.
93+
- Update an AWS IoT Thing with Attributes.
94+
- Return a unique endpoint.
95+
- List your AWS IoT certificates.
96+
- Update an AWS IoT shadow.
97+
- Write out state information.
98+
- Creates a rule.
99+
- List your rules.
100+
- Search things using the Thing name.
101+
- Delete an AWS IoT Thing.
102+
103+
<!--custom.basic_prereqs.iot_Scenario.start-->
104+
<!--custom.basic_prereqs.iot_Scenario.end-->
105+
106+
Start the example by running the following at a command prompt:
107+
108+
```
109+
python iot_wrapper.py
110+
```
111+
112+
113+
<!--custom.basics.iot_Scenario.start-->
114+
<!--custom.basics.iot_Scenario.end-->
48115

49116

50117
### Tests
@@ -73,4 +140,4 @@ in the `python` folder.
73140

74141
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
75142

76-
SPDX-License-Identifier: Apache-2.0
143+
SPDX-License-Identifier: Apache-2.0

0 commit comments

Comments
 (0)