Skip to content

Commit f153874

Browse files
authored
Greengrass Client V2 (#266)
- The V2 client differentiates between APIs which require a streaming response and those that do not. Those that don't, do not have a parameter to register a callback. - We now generate both sync and async overloads for all calls. The sync version will block on the future and throw any service errors. - The client doesn't use request objects, instead using keyword arguments which are then provided to the request object constructor. - The client now also accepts str in place of bytes and then calls .encode('utf-8') on it for ease of use. - Client has overloads with the old StreamHandler object as well as options for providing a simple callback for stream events, errors, and closing. Optionally (default is true), an executor will be used to run the stream event callback when the callback is provided as a callback. This prevents users from accidentally blocking the event loop. - I've updated the data model setters to return this so that we can now chain calls. - Streaming APIs return the operation so that the user can close the operation/handler
1 parent 6ffff8c commit f153874

23 files changed

+3297
-528
lines changed

awsiot/greengrasscoreipc/client.py

Lines changed: 86 additions & 84 deletions
Large diffs are not rendered by default.

awsiot/greengrasscoreipc/clientv2.py

Lines changed: 980 additions & 0 deletions
Large diffs are not rendered by default.

awsiot/greengrasscoreipc/model.py

Lines changed: 624 additions & 15 deletions
Large diffs are not rendered by default.

docs/_sources/awsiot/greengrasscoreipc.rst.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ awsiot.greengrasscoreipc
55

66
.. automodule:: awsiot.greengrasscoreipc.client
77

8+
.. automodule:: awsiot.greengrasscoreipc.clientv2
9+
810
.. automodule:: awsiot.greengrasscoreipc.model

docs/_static/basic.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Sphinx stylesheet -- basic theme.
66
*
7-
* :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
7+
* :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
88
* :license: BSD, see LICENSE for details.
99
*
1010
*/
@@ -757,6 +757,7 @@ span.pre {
757757
-ms-hyphens: none;
758758
-webkit-hyphens: none;
759759
hyphens: none;
760+
white-space: nowrap;
760761
}
761762

762763
div[class*="highlight-"] {

docs/_static/doctools.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Sphinx JavaScript utilities for all documentation.
66
*
7-
* :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
7+
* :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
88
* :license: BSD, see LICENSE for details.
99
*
1010
*/
@@ -264,6 +264,9 @@ var Documentation = {
264264
hideSearchWords : function() {
265265
$('#searchbox .highlight-link').fadeOut(300);
266266
$('span.highlighted').removeClass('highlighted');
267+
var url = new URL(window.location);
268+
url.searchParams.delete('highlight');
269+
window.history.replaceState({}, '', url);
267270
},
268271

269272
/**

docs/_static/language_data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* This script contains the language-specific data used by searchtools.js,
66
* namely the list of stopwords, stemmer, scorer and splitter.
77
*
8-
* :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
8+
* :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
99
* :license: BSD, see LICENSE for details.
1010
*
1111
*/

docs/_static/searchtools.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Sphinx JavaScript utilities for the full-text search.
66
*
7-
* :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
7+
* :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
88
* :license: BSD, see LICENSE for details.
99
*
1010
*/

docs/awsiot/awsiot.html

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,16 @@ <h3>Navigation</h3>
104104
</div>
105105
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
106106
<div class="sphinxsidebarwrapper">
107-
<h4>Previous topic</h4>
108-
<p class="topless"><a href="../index.html"
109-
title="previous chapter">AWS IoT Device SDK v2 for Python</a></p>
110-
<h4>Next topic</h4>
111-
<p class="topless"><a href="eventstreamrpc.html"
112-
title="next chapter">awsiot.eventstreamrpc</a></p>
107+
<div>
108+
<h4>Previous topic</h4>
109+
<p class="topless"><a href="../index.html"
110+
title="previous chapter">AWS IoT Device SDK v2 for Python</a></p>
111+
</div>
112+
<div>
113+
<h4>Next topic</h4>
114+
<p class="topless"><a href="eventstreamrpc.html"
115+
title="next chapter">awsiot.eventstreamrpc</a></p>
116+
</div>
113117
<div role="note" aria-label="source link">
114118
<h3>This Page</h3>
115119
<ul class="this-page-menu">
@@ -152,7 +156,7 @@ <h3>Navigation</h3>
152156
</div>
153157
<div class="footer" role="contentinfo">
154158
&#169; Copyright 2022, Amazon Web Services, Inc.
155-
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
159+
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.4.0.
156160
</div>
157161
</body>
158162
</html>

docs/awsiot/eventstreamrpc.html

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ <h3>Navigation</h3>
138138
This will not be invoked if the connection attempt failed.</p>
139139
<dl class="field-list simple">
140140
<dt class="field-odd">Parameters</dt>
141-
<dd class="field-odd"><p><strong>reason</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/exceptions.html#Exception" title="(in Python v3.10)"><em>Exception</em></a><em>]</em>) – Reason will be <cite>None</cite> if the user initiated the shutdown,
141+
<dd class="field-odd"><p><strong>reason</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.10)"><em>Optional</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/exceptions.html#Exception" title="(in Python v3.10)"><em>Exception</em></a><em>]</em>) – Reason will be <cite>None</cite> if the user initiated the shutdown,
142142
otherwise the reason will be an Exception.</p>
143143
</dd>
144144
</dl>
@@ -172,7 +172,7 @@ <h3>Navigation</h3>
172172
<dl class="field-list simple">
173173
<dt class="field-odd">Parameters</dt>
174174
<dd class="field-odd"><ul class="simple">
175-
<li><p><strong>headers</strong> (<em>Sequence</em><em>[</em><a class="reference external" href="https://awslabs.github.io/aws-crt-python/api/eventstream.html#awscrt.eventstream.Header" title="(in awscrt)"><em>awscrt.eventstream.Header</em></a><em>]</em>) – </p></li>
175+
<li><p><strong>headers</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Sequence" title="(in Python v3.10)"><em>Sequence</em></a><em>[</em><a class="reference external" href="https://awslabs.github.io/aws-crt-python/api/eventstream.html#awscrt.eventstream.Header" title="(in awscrt)"><em>awscrt.eventstream.Header</em></a><em>]</em>) – </p></li>
176176
<li><p><strong>payload</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#bytes" title="(in Python v3.10)"><em>bytes</em></a>) – </p></li>
177177
</ul>
178178
</dd>
@@ -189,8 +189,8 @@ <h3>Navigation</h3>
189189
<dl class="field-list simple">
190190
<dt class="field-odd">Parameters</dt>
191191
<dd class="field-odd"><ul class="simple">
192-
<li><p><strong>headers</strong> (<em>Optional</em><em>[</em><em>Sequence</em><em>[</em><a class="reference external" href="https://awslabs.github.io/aws-crt-python/api/eventstream.html#awscrt.eventstream.Header" title="(in awscrt)"><em>awscrt.eventstream.Header</em></a><em>]</em><em>]</em>) – Headers to add (optional)</p></li>
193-
<li><p><strong>payload</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#bytes" title="(in Python v3.10)"><em>bytes</em></a><em>]</em>) – Binary payload data (optional)</p></li>
192+
<li><p><strong>headers</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.10)"><em>Optional</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Sequence" title="(in Python v3.10)"><em>Sequence</em></a><em>[</em><a class="reference external" href="https://awslabs.github.io/aws-crt-python/api/eventstream.html#awscrt.eventstream.Header" title="(in awscrt)"><em>awscrt.eventstream.Header</em></a><em>]</em><em>]</em>) – Headers to add (optional)</p></li>
193+
<li><p><strong>payload</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.10)"><em>Optional</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#bytes" title="(in Python v3.10)"><em>bytes</em></a><em>]</em>) – Binary payload data (optional)</p></li>
194194
</ul>
195195
</dd>
196196
</dl>
@@ -221,7 +221,7 @@ <h3>Navigation</h3>
221221
<cite>connect_message_amender</cite> init arg.</p>
222222
</dd>
223223
<dt class="field-odd">Return type</dt>
224-
<dd class="field-odd"><p>Callable[[], <a class="reference internal" href="#awsiot.eventstreamrpc.MessageAmendment" title="awsiot.eventstreamrpc.MessageAmendment">awsiot.eventstreamrpc.MessageAmendment</a>]</p>
224+
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Callable" title="(in Python v3.10)"><em>Callable</em></a>[[], <a class="reference internal" href="#awsiot.eventstreamrpc.MessageAmendment" title="awsiot.eventstreamrpc.MessageAmendment">awsiot.eventstreamrpc.MessageAmendment</a>]</p>
225225
</dd>
226226
</dl>
227227
</dd></dl>
@@ -245,12 +245,12 @@ <h3>Navigation</h3>
245245
<li><p><strong>host_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – Remote host name.</p></li>
246246
<li><p><strong>port</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – Remote port.</p></li>
247247
<li><p><strong>bootstrap</strong> (<a class="reference external" href="https://awslabs.github.io/aws-crt-python/api/io.html#awscrt.io.ClientBootstrap" title="(in awscrt)"><em>awscrt.io.ClientBootstrap</em></a>) – ClientBootstrap to use when initiating socket connection.</p></li>
248-
<li><p><strong>socket_options</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://awslabs.github.io/aws-crt-python/api/io.html#awscrt.io.SocketOptions" title="(in awscrt)"><em>awscrt.io.SocketOptions</em></a><em>]</em>) – Optional socket options.
248+
<li><p><strong>socket_options</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.10)"><em>Optional</em></a><em>[</em><a class="reference external" href="https://awslabs.github.io/aws-crt-python/api/io.html#awscrt.io.SocketOptions" title="(in awscrt)"><em>awscrt.io.SocketOptions</em></a><em>]</em>) – Optional socket options.
249249
If None is provided, the default options are used.</p></li>
250-
<li><p><strong>tls_connection_options</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://awslabs.github.io/aws-crt-python/api/io.html#awscrt.io.TlsConnectionOptions" title="(in awscrt)"><em>awscrt.io.TlsConnectionOptions</em></a><em>]</em>) – Optional TLS connection options.
250+
<li><p><strong>tls_connection_options</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.10)"><em>Optional</em></a><em>[</em><a class="reference external" href="https://awslabs.github.io/aws-crt-python/api/io.html#awscrt.io.TlsConnectionOptions" title="(in awscrt)"><em>awscrt.io.TlsConnectionOptions</em></a><em>]</em>) – Optional TLS connection options.
251251
If None is provided, then the connection will be attempted over
252252
plain-text.</p></li>
253-
<li><p><strong>connect_message_amender</strong> (<em>Optional</em><em>[</em><em>Callable</em><em>[</em><em>[</em><em>]</em><em>, </em><a class="reference internal" href="#awsiot.eventstreamrpc.MessageAmendment" title="awsiot.eventstreamrpc.MessageAmendment"><em>awsiot.eventstreamrpc.MessageAmendment</em></a><em>]</em><em>]</em>) – Optional callable that should return a
253+
<li><p><strong>connect_message_amender</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.10)"><em>Optional</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Callable" title="(in Python v3.10)"><em>Callable</em></a><em>[</em><em>[</em><em>]</em><em>, </em><a class="reference internal" href="#awsiot.eventstreamrpc.MessageAmendment" title="awsiot.eventstreamrpc.MessageAmendment"><em>awsiot.eventstreamrpc.MessageAmendment</em></a><em>]</em><em>]</em>) – Optional callable that should return a
254254
<a class="reference internal" href="#awsiot.eventstreamrpc.MessageAmendment" title="awsiot.eventstreamrpc.MessageAmendment"><code class="xref py py-class docutils literal notranslate"><span class="pre">MessageAmendment</span></code></a> for the
255255
<a class="reference external" href="https://awslabs.github.io/aws-crt-python/api/eventstream.html#awscrt.eventstream.rpc.MessageType.CONNECT" title="(in awscrt)"><code class="xref py py-attr docutils literal notranslate"><span class="pre">CONNECT</span></code></a> message.
256256
This callable will be invoked whenever a network connection is
@@ -292,7 +292,7 @@ <h3>Navigation</h3>
292292
is already closed or closing.</p>
293293
<dl class="field-list simple">
294294
<dt class="field-odd">Parameters</dt>
295-
<dd class="field-odd"><p><strong>reason</strong> (<em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/exceptions.html#Exception" title="(in Python v3.10)"><em>Exception</em></a><em>]</em>) – If set, the connection will
295+
<dd class="field-odd"><p><strong>reason</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.10)"><em>Optional</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/exceptions.html#Exception" title="(in Python v3.10)"><em>Exception</em></a><em>]</em>) – If set, the connection will
296296
close with this error as the reason (unless
297297
it was already closing for another reason).</p>
298298
</dd>
@@ -331,7 +331,7 @@ <h3>Navigation</h3>
331331
<p>Catalog of all shapes serialized by this service</p>
332332
<dl class="field-list simple">
333333
<dt class="field-odd">Parameters</dt>
334-
<dd class="field-odd"><p><strong>shape_types</strong> (<em>Sequence</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#type" title="(in Python v3.10)"><em>type</em></a><em>]</em>) – </p>
334+
<dd class="field-odd"><p><strong>shape_types</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Sequence" title="(in Python v3.10)"><em>Sequence</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#type" title="(in Python v3.10)"><em>type</em></a><em>]</em>) – </p>
335335
</dd>
336336
</dl>
337337
<dl class="py method">
@@ -409,12 +409,16 @@ <h3>Navigation</h3>
409409
</div>
410410
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
411411
<div class="sphinxsidebarwrapper">
412-
<h4>Previous topic</h4>
413-
<p class="topless"><a href="awsiot.html"
414-
title="previous chapter">awsiot</a></p>
415-
<h4>Next topic</h4>
416-
<p class="topless"><a href="greengrasscoreipc.html"
417-
title="next chapter">awsiot.greengrasscoreipc</a></p>
412+
<div>
413+
<h4>Previous topic</h4>
414+
<p class="topless"><a href="awsiot.html"
415+
title="previous chapter">awsiot</a></p>
416+
</div>
417+
<div>
418+
<h4>Next topic</h4>
419+
<p class="topless"><a href="greengrasscoreipc.html"
420+
title="next chapter">awsiot.greengrasscoreipc</a></p>
421+
</div>
418422
<div role="note" aria-label="source link">
419423
<h3>This Page</h3>
420424
<ul class="this-page-menu">
@@ -457,7 +461,7 @@ <h3>Navigation</h3>
457461
</div>
458462
<div class="footer" role="contentinfo">
459463
&#169; Copyright 2022, Amazon Web Services, Inc.
460-
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
464+
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.4.0.
461465
</div>
462466
</body>
463467
</html>

0 commit comments

Comments
 (0)