|
1 | 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
2 | 2 | # SPDX-License-Identifier: Apache-2.0 |
3 | 3 | from collections.abc import AsyncIterable |
4 | | -from typing import Protocol, runtime_checkable, TYPE_CHECKING, Any |
| 4 | +from typing import Protocol, runtime_checkable, TYPE_CHECKING, Any, Callable |
5 | 5 |
|
| 6 | +from ...exceptions import UnsupportedStreamException |
6 | 7 | from ...interfaces import URI, Endpoint, TypedProperties |
7 | 8 | from ...interfaces import StreamingBlob as SyncStreamingBlob |
8 | 9 |
|
| 10 | +from .eventstream import EventPublisher, EventReceiver |
| 11 | + |
9 | 12 |
|
10 | 13 | if TYPE_CHECKING: |
11 | 14 | from ...schemas import APIOperation |
12 | 15 | from ...shapes import ShapeID |
13 | 16 | from ...serializers import SerializeableShape |
14 | | - from ...deserializers import DeserializeableShape |
| 17 | + from ...deserializers import DeserializeableShape, ShapeDeserializer |
15 | 18 |
|
16 | 19 |
|
17 | 20 | @runtime_checkable |
@@ -138,3 +141,49 @@ async def deserialize_response[ |
138 | 141 | :param context: A context bag for the request. |
139 | 142 | """ |
140 | 143 | ... |
| 144 | + |
| 145 | + def create_event_publisher[ |
| 146 | + OperationInput: "SerializeableShape", |
| 147 | + OperationOutput: "DeserializeableShape", |
| 148 | + Event: "SerializeableShape", |
| 149 | + ]( |
| 150 | + self, |
| 151 | + *, |
| 152 | + operation: "APIOperation[OperationInput, OperationOutput]", |
| 153 | + request: I, |
| 154 | + event_type: type[Event], |
| 155 | + context: TypedProperties, |
| 156 | + ) -> EventPublisher[Event]: |
| 157 | + """Creates an event publisher for a protocol event stream. |
| 158 | +
|
| 159 | + :param operation: The event stream operation. |
| 160 | + :param request: The transport request that was sent for this stream. |
| 161 | + :param event_type: The type of event to publish. |
| 162 | + :param context: A context bag for the request. |
| 163 | + """ |
| 164 | + raise UnsupportedStreamException() |
| 165 | + |
| 166 | + def create_event_receiver[ |
| 167 | + OperationInput: "SerializeableShape", |
| 168 | + OperationOutput: "DeserializeableShape", |
| 169 | + Event: "DeserializeableShape", |
| 170 | + ]( |
| 171 | + self, |
| 172 | + *, |
| 173 | + operation: "APIOperation[OperationInput, OperationOutput]", |
| 174 | + request: I, |
| 175 | + response: O, |
| 176 | + event_type: type[Event], |
| 177 | + event_deserializer: Callable[["ShapeDeserializer"], Event], |
| 178 | + context: TypedProperties, |
| 179 | + ) -> EventReceiver[Event]: |
| 180 | + """Creates an event receiver for a protocol event stream. |
| 181 | +
|
| 182 | + :param operation: The event stream operation. |
| 183 | + :param request: The transport request that was sent for this stream. |
| 184 | + :param response: The transport response that was received for this stream. |
| 185 | + :param event_type: The type of event to publish. |
| 186 | + :param event_deserializer: The deserializer to be used to deserialize events. |
| 187 | + :param context: A context bag for the request. |
| 188 | + """ |
| 189 | + raise UnsupportedStreamException() |
0 commit comments