|
| 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 | + def activate(self, request: model.GetAllProductsRequest) -> concurrent.futures.Future: |
| 13 | + """ |
| 14 | + Activate this operation by sending the initial model.GetAllProductsRequest message. |
| 15 | +
|
| 16 | + Returns a Future which completes with a result of None if the |
| 17 | + request is successfully written to the wire, or an exception if |
| 18 | + the request fails to send. |
| 19 | + """ |
| 20 | + return self._activate(request) |
| 21 | + |
| 22 | + def get_response(self) -> concurrent.futures.Future: |
| 23 | + """ |
| 24 | + Returns a Future which completes with a result of model.GetAllProductsResponse, |
| 25 | + or an exception. |
| 26 | + """ |
| 27 | + return self._get_response() |
| 28 | + |
| 29 | + def close(self) -> concurrent.futures.Future: |
| 30 | + """ |
| 31 | + Close the operation, whether or not it has completed. |
| 32 | +
|
| 33 | + Returns a Future which completes with a result of None |
| 34 | + when the operation has closed. |
| 35 | + """ |
| 36 | + return super().close() |
| 37 | + |
| 38 | + |
| 39 | +class CauseServiceErrorOperation(model._CauseServiceErrorOperation): |
| 40 | + def activate(self, request: model.CauseServiceErrorRequest) -> concurrent.futures.Future: |
| 41 | + """ |
| 42 | + Activate this operation by sending the initial model.CauseServiceErrorRequest message. |
| 43 | +
|
| 44 | + Returns a Future which completes with a result of None if the |
| 45 | + request is successfully written to the wire, or an exception if |
| 46 | + the request fails to send. |
| 47 | + """ |
| 48 | + return self._activate(request) |
| 49 | + |
| 50 | + def get_response(self) -> concurrent.futures.Future: |
| 51 | + """ |
| 52 | + Returns a Future which completes with a result of model.CauseServiceErrorResponse, |
| 53 | + or an exception. |
| 54 | + """ |
| 55 | + return self._get_response() |
| 56 | + |
| 57 | + def close(self) -> concurrent.futures.Future: |
| 58 | + """ |
| 59 | + Close the operation, whether or not it has completed. |
| 60 | +
|
| 61 | + Returns a Future which completes with a result of None |
| 62 | + when the operation has closed. |
| 63 | + """ |
| 64 | + return super().close() |
| 65 | + |
| 66 | + |
| 67 | +class CauseStreamServiceToErrorStreamHandler(rpc.StreamResponseHandler): |
| 68 | + """ |
| 69 | + Inherit from this class and override methods to handle operation events. |
| 70 | + """ |
| 71 | + |
| 72 | + def on_stream_event(self, event: model.EchoStreamingMessage) -> None: |
| 73 | + """ |
| 74 | + Invoked when a model.EchoStreamingMessage is received. |
| 75 | + """ |
| 76 | + pass |
| 77 | + |
| 78 | + def on_stream_error(self, error: Exception) -> bool: |
| 79 | + """ |
| 80 | + Invoked when an error occurs on the operation stream. |
| 81 | +
|
| 82 | + Return True if operation should close as a result of this error, |
| 83 | + """ |
| 84 | + return True |
| 85 | + |
| 86 | + def on_stream_closed(self) -> None: |
| 87 | + """ |
| 88 | + Invoked when the stream for this operation is closed. |
| 89 | + """ |
| 90 | + pass |
| 91 | + |
| 92 | + |
| 93 | +class CauseStreamServiceToErrorOperation(model._CauseStreamServiceToErrorOperation): |
| 94 | + def activate(self, request: model.EchoStreamingRequest) -> concurrent.futures.Future: |
| 95 | + """ |
| 96 | + Activate this operation by sending the initial model.EchoStreamingRequest message. |
| 97 | +
|
| 98 | + Returns a Future which completes with a result of None if the |
| 99 | + request is successfully written to the wire, or an exception if |
| 100 | + the request fails to send. |
| 101 | + """ |
| 102 | + return self._activate(request) |
| 103 | + |
| 104 | + def send_stream_event(self, event: model.EchoStreamingMessage) -> concurrent.futures.Future: |
| 105 | + """ |
| 106 | + Send next stream event. |
| 107 | +
|
| 108 | + activate() must be called before send_stream_event(). |
| 109 | +
|
| 110 | + Returns a Future which completes with a result of None if the |
| 111 | + event is successfully written to the wire, or an exception if |
| 112 | + the event fails to send. |
| 113 | + """ |
| 114 | + return self._send_stream_event(event) |
| 115 | + |
| 116 | + def get_response(self) -> concurrent.futures.Future: |
| 117 | + """ |
| 118 | + Returns a Future which completes with a result of model.EchoStreamingResponse, |
| 119 | + or an exception. |
| 120 | + """ |
| 121 | + return self._get_response() |
| 122 | + |
| 123 | + def close(self) -> concurrent.futures.Future: |
| 124 | + """ |
| 125 | + Close the operation, whether or not it has completed. |
| 126 | +
|
| 127 | + Returns a Future which completes with a result of None |
| 128 | + when the operation has closed. |
| 129 | + """ |
| 130 | + return super().close() |
| 131 | + |
| 132 | + |
| 133 | +class EchoStreamMessagesStreamHandler(rpc.StreamResponseHandler): |
| 134 | + """ |
| 135 | + Inherit from this class and override methods to handle operation events. |
| 136 | + """ |
| 137 | + |
| 138 | + def on_stream_event(self, event: model.EchoStreamingMessage) -> None: |
| 139 | + """ |
| 140 | + Invoked when a model.EchoStreamingMessage is received. |
| 141 | + """ |
| 142 | + pass |
| 143 | + |
| 144 | + def on_stream_error(self, error: Exception) -> bool: |
| 145 | + """ |
| 146 | + Invoked when an error occurs on the operation stream. |
| 147 | +
|
| 148 | + Return True if operation should close as a result of this error, |
| 149 | + """ |
| 150 | + return True |
| 151 | + |
| 152 | + def on_stream_closed(self) -> None: |
| 153 | + """ |
| 154 | + Invoked when the stream for this operation is closed. |
| 155 | + """ |
| 156 | + pass |
| 157 | + |
| 158 | + |
| 159 | +class EchoStreamMessagesOperation(model._EchoStreamMessagesOperation): |
| 160 | + def activate(self, request: model.EchoStreamingRequest) -> concurrent.futures.Future: |
| 161 | + """ |
| 162 | + Activate this operation by sending the initial model.EchoStreamingRequest message. |
| 163 | +
|
| 164 | + Returns a Future which completes with a result of None if the |
| 165 | + request is successfully written to the wire, or an exception if |
| 166 | + the request fails to send. |
| 167 | + """ |
| 168 | + return self._activate(request) |
| 169 | + |
| 170 | + def send_stream_event(self, event: model.EchoStreamingMessage) -> concurrent.futures.Future: |
| 171 | + """ |
| 172 | + Send next stream event. |
| 173 | +
|
| 174 | + activate() must be called before send_stream_event(). |
| 175 | +
|
| 176 | + Returns a Future which completes with a result of None if the |
| 177 | + event is successfully written to the wire, or an exception if |
| 178 | + the event fails to send. |
| 179 | + """ |
| 180 | + return self._send_stream_event(event) |
| 181 | + |
| 182 | + def get_response(self) -> concurrent.futures.Future: |
| 183 | + """ |
| 184 | + Returns a Future which completes with a result of model.EchoStreamingResponse, |
| 185 | + or an exception. |
| 186 | + """ |
| 187 | + return self._get_response() |
| 188 | + |
| 189 | + def close(self) -> concurrent.futures.Future: |
| 190 | + """ |
| 191 | + Close the operation, whether or not it has completed. |
| 192 | +
|
| 193 | + Returns a Future which completes with a result of None |
| 194 | + when the operation has closed. |
| 195 | + """ |
| 196 | + return super().close() |
| 197 | + |
| 198 | + |
| 199 | +class EchoMessageOperation(model._EchoMessageOperation): |
| 200 | + def activate(self, request: model.EchoMessageRequest) -> concurrent.futures.Future: |
| 201 | + """ |
| 202 | + Activate this operation by sending the initial model.EchoMessageRequest message. |
| 203 | +
|
| 204 | + Returns a Future which completes with a result of None if the |
| 205 | + request is successfully written to the wire, or an exception if |
| 206 | + the request fails to send. |
| 207 | + """ |
| 208 | + return self._activate(request) |
| 209 | + |
| 210 | + def get_response(self) -> concurrent.futures.Future: |
| 211 | + """ |
| 212 | + Returns a Future which completes with a result of model.EchoMessageResponse, |
| 213 | + or an exception. |
| 214 | + """ |
| 215 | + return self._get_response() |
| 216 | + |
| 217 | + def close(self) -> concurrent.futures.Future: |
| 218 | + """ |
| 219 | + Close the operation, whether or not it has completed. |
| 220 | +
|
| 221 | + Returns a Future which completes with a result of None |
| 222 | + when the operation has closed. |
| 223 | + """ |
| 224 | + return super().close() |
| 225 | + |
| 226 | + |
| 227 | +class GetAllCustomersOperation(model._GetAllCustomersOperation): |
| 228 | + def activate(self, request: model.GetAllCustomersRequest) -> concurrent.futures.Future: |
| 229 | + """ |
| 230 | + Activate this operation by sending the initial model.GetAllCustomersRequest message. |
| 231 | +
|
| 232 | + Returns a Future which completes with a result of None if the |
| 233 | + request is successfully written to the wire, or an exception if |
| 234 | + the request fails to send. |
| 235 | + """ |
| 236 | + return self._activate(request) |
| 237 | + |
| 238 | + def get_response(self) -> concurrent.futures.Future: |
| 239 | + """ |
| 240 | + Returns a Future which completes with a result of model.GetAllCustomersResponse, |
| 241 | + or an exception. |
| 242 | + """ |
| 243 | + return self._get_response() |
| 244 | + |
| 245 | + def close(self) -> concurrent.futures.Future: |
| 246 | + """ |
| 247 | + Close the operation, whether or not it has completed. |
| 248 | +
|
| 249 | + Returns a Future which completes with a result of None |
| 250 | + when the operation has closed. |
| 251 | + """ |
| 252 | + return super().close() |
| 253 | + |
| 254 | + |
| 255 | +class EchoTestRPCClient(rpc.Client): |
| 256 | + |
| 257 | + def __init__(self, connection: rpc.Connection): |
| 258 | + super().__init__(connection, model.SHAPE_INDEX) |
| 259 | + |
| 260 | + def new_get_all_products(self) -> GetAllProductsOperation: |
| 261 | + return self._new_operation(GetAllProductsOperation) |
| 262 | + |
| 263 | + def new_cause_service_error(self) -> CauseServiceErrorOperation: |
| 264 | + return self._new_operation(CauseServiceErrorOperation) |
| 265 | + |
| 266 | + def new_cause_stream_service_to_error(self, stream_handler: CauseStreamServiceToErrorStreamHandler) -> CauseStreamServiceToErrorOperation: |
| 267 | + return self._new_operation(CauseStreamServiceToErrorOperation, stream_handler) |
| 268 | + |
| 269 | + def new_echo_stream_messages(self, stream_handler: EchoStreamMessagesStreamHandler) -> EchoStreamMessagesOperation: |
| 270 | + return self._new_operation(EchoStreamMessagesOperation, stream_handler) |
| 271 | + |
| 272 | + def new_echo_message(self) -> EchoMessageOperation: |
| 273 | + return self._new_operation(EchoMessageOperation) |
| 274 | + |
| 275 | + def new_get_all_customers(self) -> GetAllCustomersOperation: |
| 276 | + return self._new_operation(GetAllCustomersOperation) |
0 commit comments