Skip to content

Commit 309a699

Browse files
Update Greengrass V2 IPC models (#325)
Co-authored-by: TwistedTwigleg <[email protected]>
1 parent 514ebcc commit 309a699

File tree

5 files changed

+1792
-181
lines changed

5 files changed

+1792
-181
lines changed

awsiot/greengrasscoreipc/client.py

Lines changed: 210 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,40 @@
88
import concurrent.futures
99

1010

11+
class AuthorizeClientDeviceActionOperation(model._AuthorizeClientDeviceActionOperation):
12+
"""
13+
AuthorizeClientDeviceActionOperation
14+
15+
Create with GreengrassCoreIPCClient.new_authorize_client_device_action()
16+
"""
17+
18+
def activate(self, request: model.AuthorizeClientDeviceActionRequest): # type: (...) -> concurrent.futures.Future[None]
19+
"""
20+
Activate this operation by sending the initial AuthorizeClientDeviceActionRequest 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): # type: (...) -> concurrent.futures.Future[model.AuthorizeClientDeviceActionResponse]
29+
"""
30+
Returns a Future which completes with a result of AuthorizeClientDeviceActionResponse,
31+
when the initial response is received, or an exception.
32+
"""
33+
return self._get_response()
34+
35+
def close(self): # type: (...) -> concurrent.futures.Future[None]
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+
1145
class CreateDebugPasswordOperation(model._CreateDebugPasswordOperation):
1246
"""
1347
CreateDebugPasswordOperation
@@ -144,6 +178,40 @@ def close(self): # type: (...) -> concurrent.futures.Future[None]
144178
return super().close()
145179

146180

181+
class GetClientDeviceAuthTokenOperation(model._GetClientDeviceAuthTokenOperation):
182+
"""
183+
GetClientDeviceAuthTokenOperation
184+
185+
Create with GreengrassCoreIPCClient.new_get_client_device_auth_token()
186+
"""
187+
188+
def activate(self, request: model.GetClientDeviceAuthTokenRequest): # type: (...) -> concurrent.futures.Future[None]
189+
"""
190+
Activate this operation by sending the initial GetClientDeviceAuthTokenRequest message.
191+
192+
Returns a Future which completes with a result of None if the
193+
request is successfully written to the wire, or an exception if
194+
the request fails to send.
195+
"""
196+
return self._activate(request)
197+
198+
def get_response(self): # type: (...) -> concurrent.futures.Future[model.GetClientDeviceAuthTokenResponse]
199+
"""
200+
Returns a Future which completes with a result of GetClientDeviceAuthTokenResponse,
201+
when the initial response is received, or an exception.
202+
"""
203+
return self._get_response()
204+
205+
def close(self): # type: (...) -> concurrent.futures.Future[None]
206+
"""
207+
Close the operation, whether or not it has completed.
208+
209+
Returns a Future which completes with a result of None
210+
when the operation has closed.
211+
"""
212+
return super().close()
213+
214+
147215
class GetComponentDetailsOperation(model._GetComponentDetailsOperation):
148216
"""
149217
GetComponentDetailsOperation
@@ -654,6 +722,69 @@ def close(self): # type: (...) -> concurrent.futures.Future[None]
654722
return super().close()
655723

656724

725+
class SubscribeToCertificateUpdatesStreamHandler(rpc.StreamResponseHandler):
726+
"""
727+
Event handler for SubscribeToCertificateUpdatesOperation
728+
729+
Inherit from this class and override methods to handle
730+
stream events during a SubscribeToCertificateUpdatesOperation.
731+
"""
732+
733+
def on_stream_event(self, event: model.CertificateUpdateEvent) -> None:
734+
"""
735+
Invoked when a CertificateUpdateEvent is received.
736+
"""
737+
pass
738+
739+
def on_stream_error(self, error: Exception) -> bool:
740+
"""
741+
Invoked when an error occurs on the operation stream.
742+
743+
Return True if operation should close as a result of this error,
744+
"""
745+
return True
746+
747+
def on_stream_closed(self) -> None:
748+
"""
749+
Invoked when the stream for this operation is closed.
750+
"""
751+
pass
752+
753+
754+
class SubscribeToCertificateUpdatesOperation(model._SubscribeToCertificateUpdatesOperation):
755+
"""
756+
SubscribeToCertificateUpdatesOperation
757+
758+
Create with GreengrassCoreIPCClient.new_subscribe_to_certificate_updates()
759+
"""
760+
761+
def activate(self, request: model.SubscribeToCertificateUpdatesRequest): # type: (...) -> concurrent.futures.Future[None]
762+
"""
763+
Activate this operation by sending the initial SubscribeToCertificateUpdatesRequest message.
764+
765+
Returns a Future which completes with a result of None if the
766+
request is successfully written to the wire, or an exception if
767+
the request fails to send.
768+
"""
769+
return self._activate(request)
770+
771+
def get_response(self): # type: (...) -> concurrent.futures.Future[model.SubscribeToCertificateUpdatesResponse]
772+
"""
773+
Returns a Future which completes with a result of SubscribeToCertificateUpdatesResponse,
774+
when the initial response is received, or an exception.
775+
"""
776+
return self._get_response()
777+
778+
def close(self): # type: (...) -> concurrent.futures.Future[None]
779+
"""
780+
Close the operation, whether or not it has completed.
781+
782+
Returns a Future which completes with a result of None
783+
when the operation has closed.
784+
"""
785+
return super().close()
786+
787+
657788
class SubscribeToComponentUpdatesStreamHandler(rpc.StreamResponseHandler):
658789
"""
659790
Event handler for SubscribeToComponentUpdatesOperation
@@ -1105,10 +1236,44 @@ def close(self): # type: (...) -> concurrent.futures.Future[None]
11051236
return super().close()
11061237

11071238

1239+
class VerifyClientDeviceIdentityOperation(model._VerifyClientDeviceIdentityOperation):
1240+
"""
1241+
VerifyClientDeviceIdentityOperation
1242+
1243+
Create with GreengrassCoreIPCClient.new_verify_client_device_identity()
1244+
"""
1245+
1246+
def activate(self, request: model.VerifyClientDeviceIdentityRequest): # type: (...) -> concurrent.futures.Future[None]
1247+
"""
1248+
Activate this operation by sending the initial VerifyClientDeviceIdentityRequest message.
1249+
1250+
Returns a Future which completes with a result of None if the
1251+
request is successfully written to the wire, or an exception if
1252+
the request fails to send.
1253+
"""
1254+
return self._activate(request)
1255+
1256+
def get_response(self): # type: (...) -> concurrent.futures.Future[model.VerifyClientDeviceIdentityResponse]
1257+
"""
1258+
Returns a Future which completes with a result of VerifyClientDeviceIdentityResponse,
1259+
when the initial response is received, or an exception.
1260+
"""
1261+
return self._get_response()
1262+
1263+
def close(self): # type: (...) -> concurrent.futures.Future[None]
1264+
"""
1265+
Close the operation, whether or not it has completed.
1266+
1267+
Returns a Future which completes with a result of None
1268+
when the operation has closed.
1269+
"""
1270+
return super().close()
1271+
1272+
11081273
class GreengrassCoreIPCClient(rpc.Client):
11091274
"""
11101275
Client for the GreengrassCoreIPC service.
1111-
There is a new V2 client available for testing in developer preview.
1276+
There is a new V2 client which should be preferred.
11121277
See the GreengrassCoreIPCClientV2 class in the clientv2 subpackage.
11131278
11141279
Args:
@@ -1118,6 +1283,16 @@ class GreengrassCoreIPCClient(rpc.Client):
11181283
def __init__(self, connection: rpc.Connection):
11191284
super().__init__(connection, model.SHAPE_INDEX)
11201285

1286+
def new_authorize_client_device_action(self) -> AuthorizeClientDeviceActionOperation:
1287+
"""
1288+
Create a new AuthorizeClientDeviceActionOperation.
1289+
1290+
This operation will not send or receive any data until activate()
1291+
is called. Call activate() when you're ready for callbacks and
1292+
events to fire.
1293+
"""
1294+
return self._new_operation(AuthorizeClientDeviceActionOperation)
1295+
11211296
def new_create_debug_password(self) -> CreateDebugPasswordOperation:
11221297
"""
11231298
Create a new CreateDebugPasswordOperation.
@@ -1158,6 +1333,16 @@ def new_delete_thing_shadow(self) -> DeleteThingShadowOperation:
11581333
"""
11591334
return self._new_operation(DeleteThingShadowOperation)
11601335

1336+
def new_get_client_device_auth_token(self) -> GetClientDeviceAuthTokenOperation:
1337+
"""
1338+
Create a new GetClientDeviceAuthTokenOperation.
1339+
1340+
This operation will not send or receive any data until activate()
1341+
is called. Call activate() when you're ready for callbacks and
1342+
events to fire.
1343+
"""
1344+
return self._new_operation(GetClientDeviceAuthTokenOperation)
1345+
11611346
def new_get_component_details(self) -> GetComponentDetailsOperation:
11621347
"""
11631348
Create a new GetComponentDetailsOperation.
@@ -1308,6 +1493,20 @@ def new_stop_component(self) -> StopComponentOperation:
13081493
"""
13091494
return self._new_operation(StopComponentOperation)
13101495

1496+
def new_subscribe_to_certificate_updates(self, stream_handler: SubscribeToCertificateUpdatesStreamHandler) -> SubscribeToCertificateUpdatesOperation:
1497+
"""
1498+
Create a new SubscribeToCertificateUpdatesOperation.
1499+
1500+
This operation will not send or receive any data until activate()
1501+
is called. Call activate() when you're ready for callbacks and
1502+
events to fire.
1503+
1504+
Args:
1505+
stream_handler: Methods on this object will be called as
1506+
stream events happen on this operation.
1507+
"""
1508+
return self._new_operation(SubscribeToCertificateUpdatesOperation, stream_handler)
1509+
13111510
def new_subscribe_to_component_updates(self, stream_handler: SubscribeToComponentUpdatesStreamHandler) -> SubscribeToComponentUpdatesOperation:
13121511
"""
13131512
Create a new SubscribeToComponentUpdatesOperation.
@@ -1417,3 +1616,13 @@ def new_validate_authorization_token(self) -> ValidateAuthorizationTokenOperatio
14171616
events to fire.
14181617
"""
14191618
return self._new_operation(ValidateAuthorizationTokenOperation)
1619+
1620+
def new_verify_client_device_identity(self) -> VerifyClientDeviceIdentityOperation:
1621+
"""
1622+
Create a new VerifyClientDeviceIdentityOperation.
1623+
1624+
This operation will not send or receive any data until activate()
1625+
is called. Call activate() when you're ready for callbacks and
1626+
events to fire.
1627+
"""
1628+
return self._new_operation(VerifyClientDeviceIdentityOperation)

0 commit comments

Comments
 (0)