Skip to content

Commit ea98597

Browse files
New Greengrass IPC client added (#136)
Added Greengrass IPC client upgrade to awscrt 0.9.15 Co-authored-by: Michael Graeb <[email protected]>
1 parent 844bf38 commit ea98597

File tree

9 files changed

+7886
-3
lines changed

9 files changed

+7886
-3
lines changed

awsiot/eventstreamrpc.py

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

awsiot/greengrasscoreipc/__init__.py

Whitespace-only changes.

awsiot/greengrasscoreipc/client.py

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

awsiot/greengrasscoreipc/model.py

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

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
44
# SPDX-License-Identifier: Apache-2.0.
55

6-
from setuptools import setup
6+
from setuptools import setup, find_packages
77

88
setup(
99
name='awsiotsdk',
1010
version='1.0.0-dev',
1111
description='AWS IoT SDK based on the AWS Common Runtime',
1212
author='AWS SDK Common Runtime Team',
1313
url='https://github.com/aws/aws-iot-device-sdk-python-v2',
14-
packages=['awsiot'],
14+
packages=find_packages(include=['awsiot*']),
1515
install_requires=[
16-
'awscrt==0.9.10',
16+
'awscrt==0.9.15',
1717
],
1818
python_requires='>=3.5',
1919
)

test/echotestrpc/__init__.py

Whitespace-only changes.

test/echotestrpc/client.py

Lines changed: 374 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,374 @@
1+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0.
3+
4+
# This file is generated
5+
6+
from . import model
7+
import awsiot.eventstreamrpc as rpc
8+
import concurrent.futures
9+
10+
11+
class GetAllProductsOperation(model._GetAllProductsOperation):
12+
"""
13+
GetAllProductsOperation
14+
15+
Create with EchoTestRPCClient.new_get_all_products()
16+
"""
17+
18+
def activate(self, request: model.GetAllProductsRequest) -> concurrent.futures.Future:
19+
"""
20+
Activate this operation by sending the initial GetAllProductsRequest message.
21+
22+
Returns a Future which completes with a result of None if the
23+
request is successfully written to the wire, or an exception if
24+
the request fails to send.
25+
"""
26+
return self._activate(request)
27+
28+
def get_response(self) -> concurrent.futures.Future:
29+
"""
30+
Returns a Future which completes with a result of GetAllProductsResponse,
31+
when the initial response is received, or an exception.
32+
"""
33+
return self._get_response()
34+
35+
def close(self) -> concurrent.futures.Future:
36+
"""
37+
Close the operation, whether or not it has completed.
38+
39+
Returns a Future which completes with a result of None
40+
when the operation has closed.
41+
"""
42+
return super().close()
43+
44+
45+
class CauseServiceErrorOperation(model._CauseServiceErrorOperation):
46+
"""
47+
CauseServiceErrorOperation
48+
49+
Create with EchoTestRPCClient.new_cause_service_error()
50+
"""
51+
52+
def activate(self, request: model.CauseServiceErrorRequest) -> concurrent.futures.Future:
53+
"""
54+
Activate this operation by sending the initial CauseServiceErrorRequest message.
55+
56+
Returns a Future which completes with a result of None if the
57+
request is successfully written to the wire, or an exception if
58+
the request fails to send.
59+
"""
60+
return self._activate(request)
61+
62+
def get_response(self) -> concurrent.futures.Future:
63+
"""
64+
Returns a Future which completes with a result of CauseServiceErrorResponse,
65+
when the initial response is received, or an exception.
66+
"""
67+
return self._get_response()
68+
69+
def close(self) -> concurrent.futures.Future:
70+
"""
71+
Close the operation, whether or not it has completed.
72+
73+
Returns a Future which completes with a result of None
74+
when the operation has closed.
75+
"""
76+
return super().close()
77+
78+
79+
class CauseStreamServiceToErrorStreamHandler(rpc.StreamResponseHandler):
80+
"""
81+
Event handler for CauseStreamServiceToErrorOperation
82+
83+
Inherit from this class and override methods to handle
84+
stream events during a CauseStreamServiceToErrorOperation.
85+
"""
86+
87+
def on_stream_event(self, event: model.EchoStreamingMessage) -> None:
88+
"""
89+
Invoked when a EchoStreamingMessage is received.
90+
"""
91+
pass
92+
93+
def on_stream_error(self, error: Exception) -> bool:
94+
"""
95+
Invoked when an error occurs on the operation stream.
96+
97+
Return True if operation should close as a result of this error,
98+
"""
99+
return True
100+
101+
def on_stream_closed(self) -> None:
102+
"""
103+
Invoked when the stream for this operation is closed.
104+
"""
105+
pass
106+
107+
108+
class CauseStreamServiceToErrorOperation(model._CauseStreamServiceToErrorOperation):
109+
"""
110+
CauseStreamServiceToErrorOperation
111+
112+
Create with EchoTestRPCClient.new_cause_stream_service_to_error()
113+
"""
114+
115+
def activate(self, request: model.EchoStreamingRequest) -> concurrent.futures.Future:
116+
"""
117+
Activate this operation by sending the initial EchoStreamingRequest message.
118+
119+
Returns a Future which completes with a result of None if the
120+
request is successfully written to the wire, or an exception if
121+
the request fails to send.
122+
"""
123+
return self._activate(request)
124+
125+
def send_stream_event(self, event: model.EchoStreamingMessage) -> concurrent.futures.Future:
126+
"""
127+
Send next EchoStreamingMessage stream event.
128+
129+
activate() must be called before send_stream_event().
130+
131+
Returns a Future which completes with a result of None if the
132+
event is successfully written to the wire, or an exception if
133+
the event fails to send.
134+
"""
135+
return self._send_stream_event(event)
136+
137+
def get_response(self) -> concurrent.futures.Future:
138+
"""
139+
Returns a Future which completes with a result of EchoStreamingResponse,
140+
when the initial response is received, or an exception.
141+
"""
142+
return self._get_response()
143+
144+
def close(self) -> concurrent.futures.Future:
145+
"""
146+
Close the operation, whether or not it has completed.
147+
148+
Returns a Future which completes with a result of None
149+
when the operation has closed.
150+
"""
151+
return super().close()
152+
153+
154+
class EchoStreamMessagesStreamHandler(rpc.StreamResponseHandler):
155+
"""
156+
Event handler for EchoStreamMessagesOperation
157+
158+
Inherit from this class and override methods to handle
159+
stream events during a EchoStreamMessagesOperation.
160+
"""
161+
162+
def on_stream_event(self, event: model.EchoStreamingMessage) -> None:
163+
"""
164+
Invoked when a EchoStreamingMessage is received.
165+
"""
166+
pass
167+
168+
def on_stream_error(self, error: Exception) -> bool:
169+
"""
170+
Invoked when an error occurs on the operation stream.
171+
172+
Return True if operation should close as a result of this error,
173+
"""
174+
return True
175+
176+
def on_stream_closed(self) -> None:
177+
"""
178+
Invoked when the stream for this operation is closed.
179+
"""
180+
pass
181+
182+
183+
class EchoStreamMessagesOperation(model._EchoStreamMessagesOperation):
184+
"""
185+
EchoStreamMessagesOperation
186+
187+
Create with EchoTestRPCClient.new_echo_stream_messages()
188+
"""
189+
190+
def activate(self, request: model.EchoStreamingRequest) -> concurrent.futures.Future:
191+
"""
192+
Activate this operation by sending the initial EchoStreamingRequest message.
193+
194+
Returns a Future which completes with a result of None if the
195+
request is successfully written to the wire, or an exception if
196+
the request fails to send.
197+
"""
198+
return self._activate(request)
199+
200+
def send_stream_event(self, event: model.EchoStreamingMessage) -> concurrent.futures.Future:
201+
"""
202+
Send next EchoStreamingMessage stream event.
203+
204+
activate() must be called before send_stream_event().
205+
206+
Returns a Future which completes with a result of None if the
207+
event is successfully written to the wire, or an exception if
208+
the event fails to send.
209+
"""
210+
return self._send_stream_event(event)
211+
212+
def get_response(self) -> concurrent.futures.Future:
213+
"""
214+
Returns a Future which completes with a result of EchoStreamingResponse,
215+
when the initial response is received, or an exception.
216+
"""
217+
return self._get_response()
218+
219+
def close(self) -> concurrent.futures.Future:
220+
"""
221+
Close the operation, whether or not it has completed.
222+
223+
Returns a Future which completes with a result of None
224+
when the operation has closed.
225+
"""
226+
return super().close()
227+
228+
229+
class EchoMessageOperation(model._EchoMessageOperation):
230+
"""
231+
EchoMessageOperation
232+
233+
Create with EchoTestRPCClient.new_echo_message()
234+
"""
235+
236+
def activate(self, request: model.EchoMessageRequest) -> concurrent.futures.Future:
237+
"""
238+
Activate this operation by sending the initial EchoMessageRequest message.
239+
240+
Returns a Future which completes with a result of None if the
241+
request is successfully written to the wire, or an exception if
242+
the request fails to send.
243+
"""
244+
return self._activate(request)
245+
246+
def get_response(self) -> concurrent.futures.Future:
247+
"""
248+
Returns a Future which completes with a result of EchoMessageResponse,
249+
when the initial response is received, or an exception.
250+
"""
251+
return self._get_response()
252+
253+
def close(self) -> concurrent.futures.Future:
254+
"""
255+
Close the operation, whether or not it has completed.
256+
257+
Returns a Future which completes with a result of None
258+
when the operation has closed.
259+
"""
260+
return super().close()
261+
262+
263+
class GetAllCustomersOperation(model._GetAllCustomersOperation):
264+
"""
265+
GetAllCustomersOperation
266+
267+
Create with EchoTestRPCClient.new_get_all_customers()
268+
"""
269+
270+
def activate(self, request: model.GetAllCustomersRequest) -> concurrent.futures.Future:
271+
"""
272+
Activate this operation by sending the initial GetAllCustomersRequest message.
273+
274+
Returns a Future which completes with a result of None if the
275+
request is successfully written to the wire, or an exception if
276+
the request fails to send.
277+
"""
278+
return self._activate(request)
279+
280+
def get_response(self) -> concurrent.futures.Future:
281+
"""
282+
Returns a Future which completes with a result of GetAllCustomersResponse,
283+
when the initial response is received, or an exception.
284+
"""
285+
return self._get_response()
286+
287+
def close(self) -> concurrent.futures.Future:
288+
"""
289+
Close the operation, whether or not it has completed.
290+
291+
Returns a Future which completes with a result of None
292+
when the operation has closed.
293+
"""
294+
return super().close()
295+
296+
297+
class EchoTestRPCClient(rpc.Client):
298+
"""
299+
Client for the EchoTestRPC service.
300+
301+
Args:
302+
connection: Connection that this client will use.
303+
"""
304+
305+
def __init__(self, connection: rpc.Connection):
306+
super().__init__(connection, model.SHAPE_INDEX)
307+
308+
def new_get_all_products(self) -> GetAllProductsOperation:
309+
"""
310+
Create a new GetAllProductsOperation.
311+
312+
This operation will not send or receive any data until activate()
313+
is called. Call activate() when you're ready for callbacks and
314+
events to fire.
315+
"""
316+
return self._new_operation(GetAllProductsOperation)
317+
318+
def new_cause_service_error(self) -> CauseServiceErrorOperation:
319+
"""
320+
Create a new CauseServiceErrorOperation.
321+
322+
This operation will not send or receive any data until activate()
323+
is called. Call activate() when you're ready for callbacks and
324+
events to fire.
325+
"""
326+
return self._new_operation(CauseServiceErrorOperation)
327+
328+
def new_cause_stream_service_to_error(self, stream_handler: CauseStreamServiceToErrorStreamHandler) -> CauseStreamServiceToErrorOperation:
329+
"""
330+
Create a new CauseStreamServiceToErrorOperation.
331+
332+
This operation will not send or receive any data until activate()
333+
is called. Call activate() when you're ready for callbacks and
334+
events to fire.
335+
336+
Args:
337+
stream_handler: Methods on this object will be called as
338+
stream events happen on this operation.
339+
"""
340+
return self._new_operation(CauseStreamServiceToErrorOperation, stream_handler)
341+
342+
def new_echo_stream_messages(self, stream_handler: EchoStreamMessagesStreamHandler) -> EchoStreamMessagesOperation:
343+
"""
344+
Create a new EchoStreamMessagesOperation.
345+
346+
This operation will not send or receive any data until activate()
347+
is called. Call activate() when you're ready for callbacks and
348+
events to fire.
349+
350+
Args:
351+
stream_handler: Methods on this object will be called as
352+
stream events happen on this operation.
353+
"""
354+
return self._new_operation(EchoStreamMessagesOperation, stream_handler)
355+
356+
def new_echo_message(self) -> EchoMessageOperation:
357+
"""
358+
Create a new EchoMessageOperation.
359+
360+
This operation will not send or receive any data until activate()
361+
is called. Call activate() when you're ready for callbacks and
362+
events to fire.
363+
"""
364+
return self._new_operation(EchoMessageOperation)
365+
366+
def new_get_all_customers(self) -> GetAllCustomersOperation:
367+
"""
368+
Create a new GetAllCustomersOperation.
369+
370+
This operation will not send or receive any data until activate()
371+
is called. Call activate() when you're ready for callbacks and
372+
events to fire.
373+
"""
374+
return self._new_operation(GetAllCustomersOperation)

0 commit comments

Comments
 (0)