capo-sagemaker-runtime-http2 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. capo_sagemaker_runtime_http2/__init__.py +74 -0
  2. capo_sagemaker_runtime_http2/_async.py +25 -0
  3. capo_sagemaker_runtime_http2/_auth/_identity.py +16 -0
  4. capo_sagemaker_runtime_http2/_auth/_providers.py +886 -0
  5. capo_sagemaker_runtime_http2/_auth/_signers.py +88 -0
  6. capo_sagemaker_runtime_http2/_auth/_sigv4.py +434 -0
  7. capo_sagemaker_runtime_http2/_auth/_zapros_handler.py +80 -0
  8. capo_sagemaker_runtime_http2/_iter.py +113 -0
  9. capo_sagemaker_runtime_http2/_operations/amazon_sage_maker_runtime_http2/invoke_endpoint_with_bidirectional_stream.py +264 -0
  10. capo_sagemaker_runtime_http2/_pagination.py +21 -0
  11. capo_sagemaker_runtime_http2/_protocol/__init__.py +1 -0
  12. capo_sagemaker_runtime_http2/_protocol/errors.py +93 -0
  13. capo_sagemaker_runtime_http2/_protocol/eventstream.py +238 -0
  14. capo_sagemaker_runtime_http2/_protocol/serialize.py +47 -0
  15. capo_sagemaker_runtime_http2/_protocol/xml.py +33 -0
  16. capo_sagemaker_runtime_http2/_rule_engine/__init__.py +0 -0
  17. capo_sagemaker_runtime_http2/_rule_engine/_aws_partition.py +160 -0
  18. capo_sagemaker_runtime_http2/_rule_engine/_endpoint_rule_set.py +560 -0
  19. capo_sagemaker_runtime_http2/_rule_engine/_endpoint_runtime.py +389 -0
  20. capo_sagemaker_runtime_http2/_services/_aws_config.py +160 -0
  21. capo_sagemaker_runtime_http2/_services/_pipeline.py +198 -0
  22. capo_sagemaker_runtime_http2/_services/async_sage_maker_runtime_http2.py +204 -0
  23. capo_sagemaker_runtime_http2/_services/sage_maker_runtime_http2.py +203 -0
  24. capo_sagemaker_runtime_http2/errors/__init__.py +31 -0
  25. capo_sagemaker_runtime_http2/errors/_base.py +94 -0
  26. capo_sagemaker_runtime_http2/errors/input_validation_error.py +53 -0
  27. capo_sagemaker_runtime_http2/errors/internal_server_error.py +51 -0
  28. capo_sagemaker_runtime_http2/errors/internal_stream_failure.py +61 -0
  29. capo_sagemaker_runtime_http2/errors/model_error.py +69 -0
  30. capo_sagemaker_runtime_http2/errors/model_stream_error.py +65 -0
  31. capo_sagemaker_runtime_http2/errors/service_unavailable_error.py +53 -0
  32. capo_sagemaker_runtime_http2/py.typed +0 -0
  33. capo_sagemaker_runtime_http2/types/_prelude/blob.py +12 -0
  34. capo_sagemaker_runtime_http2/types/_prelude/timestamp.py +17 -0
  35. capo_sagemaker_runtime_http2/types/invoke_endpoint_with_bidirectional_stream_input.py +21 -0
  36. capo_sagemaker_runtime_http2/types/invoke_endpoint_with_bidirectional_stream_output.py +15 -0
  37. capo_sagemaker_runtime_http2/types/request_payload_part.py +62 -0
  38. capo_sagemaker_runtime_http2/types/request_stream_event.py +52 -0
  39. capo_sagemaker_runtime_http2/types/response_payload_part.py +62 -0
  40. capo_sagemaker_runtime_http2/types/response_stream_event.py +100 -0
  41. capo_sagemaker_runtime_http2/types/sensitive_blob.py +15 -0
  42. capo_sagemaker_runtime_http2-0.1.0.dist-info/METADATA +108 -0
  43. capo_sagemaker_runtime_http2-0.1.0.dist-info/RECORD +46 -0
  44. capo_sagemaker_runtime_http2-0.1.0.dist-info/WHEEL +5 -0
  45. capo_sagemaker_runtime_http2-0.1.0.dist-info/licenses/LICENSE +21 -0
  46. capo_sagemaker_runtime_http2-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,94 @@
1
+ from typing import Literal
2
+
3
+
4
+ class SageMakerRuntimeHTTP2Error(Exception):
5
+ """Base class for all SageMakerRuntimeHTTP2 service errors."""
6
+
7
+
8
+ class ServiceError(SageMakerRuntimeHTTP2Error):
9
+ """Base class for all modeled service errors.
10
+
11
+ Args:
12
+ fault: ``"client"`` or ``"server"``.
13
+ is_throttling_error: Whether this error is a throttling error.
14
+ is_retryable: Whether this error is retryable.
15
+ code: The wire error code, or ``None``.
16
+ message: The error message, or ``None``.
17
+ """
18
+
19
+ code: str | None = None
20
+
21
+ def __init__(
22
+ self,
23
+ fault: Literal["client", "server"],
24
+ *,
25
+ is_throttling_error: bool,
26
+ is_retryable: bool,
27
+ code: str | None = None,
28
+ message: str | None = None,
29
+ ) -> None:
30
+ super().__init__(f"{code or '<no code>'}: {message or '<no message>'}")
31
+ self.fault = fault
32
+ self.is_throttling_error = is_throttling_error
33
+ self.is_retryable = is_retryable
34
+ self.code = code
35
+ self.message = message
36
+
37
+
38
+ class SerializationError(SageMakerRuntimeHTTP2Error):
39
+ """Raised when a value cannot be serialized."""
40
+
41
+
42
+ class DeserializationError(SageMakerRuntimeHTTP2Error):
43
+ """Raised when a value cannot be deserialized or a required member is missing."""
44
+
45
+
46
+ class UnknownServiceError(ServiceError):
47
+ """Raised when the server returns an error code the client does not model.
48
+
49
+ Args:
50
+ code: ``<Code>`` text from the response body, or ``None`` if absent.
51
+ message: ``<Message>`` text from the response body, or ``None``.
52
+ response: The original HTTP response object, for arbitrary inspection.
53
+ """
54
+
55
+ def __init__(
56
+ self, *, code: str | None, message: str | None, response: object
57
+ ) -> None:
58
+ _status = getattr(response, "status", 500)
59
+ _fault: Literal["client", "server"] = "client" if _status < 500 else "server"
60
+ _throttling = _status == 429
61
+ _retryable = _throttling or _status >= 500
62
+ super().__init__(
63
+ _fault,
64
+ is_throttling_error=_throttling,
65
+ is_retryable=_retryable,
66
+ code=code,
67
+ message=message,
68
+ )
69
+ self.response = response
70
+
71
+
72
+ class WaiterFailedError(SageMakerRuntimeHTTP2Error):
73
+ """Raised when a waiter hits an acceptor with ``state="failure"``.
74
+
75
+ Args:
76
+ waiter_name: snake_case waiter name (e.g. ``bucket_exists``).
77
+ reason: Short description of which acceptor fired.
78
+ """
79
+
80
+ def __init__(self, waiter_name: str, reason: str) -> None:
81
+ super().__init__(f"waiter {waiter_name} failed: {reason}")
82
+ self.waiter_name = waiter_name
83
+ self.reason = reason
84
+
85
+
86
+ class WaiterTimeoutError(SageMakerRuntimeHTTP2Error):
87
+ """Raised when a waiter exhausts ``max_wait_time`` without a terminal acceptor."""
88
+
89
+ def __init__(self, waiter_name: str, max_wait_time: float) -> None:
90
+ super().__init__(
91
+ f"waiter {waiter_name} timed out after {max_wait_time} seconds"
92
+ )
93
+ self.waiter_name = waiter_name
94
+ self.max_wait_time = max_wait_time
@@ -0,0 +1,53 @@
1
+ """Generated from Smithy shape ``com.amazonaws.sagemakerruntimehttp2#InputValidationError``."""
2
+
3
+ from typing_extensions import NotRequired, TypedDict
4
+
5
+ from capo_sagemaker_runtime_http2.errors import ServiceError
6
+
7
+
8
+ class InputValidationError_(TypedDict, closed=True):
9
+ message: NotRequired["str"]
10
+ """<p>Error message.</p>"""
11
+ error_code: NotRequired["str"]
12
+ """<p>Error code.</p>"""
13
+
14
+
15
+ # --- restJson1 ser/de ---
16
+ def serialize_json(value: InputValidationError_) -> dict:
17
+ out: dict = {}
18
+ if "message" in value:
19
+ out["Message"] = value["message"]
20
+ if "error_code" in value:
21
+ out["ErrorCode"] = value["error_code"]
22
+ return out
23
+
24
+
25
+ def deserialize_json(data: dict) -> InputValidationError_:
26
+ out: InputValidationError_ = {} # type: ignore[typeddict-item]
27
+ if data.get("Message") is not None:
28
+ out["message"] = data["Message"]
29
+ if data.get("ErrorCode") is not None:
30
+ out["error_code"] = data["ErrorCode"]
31
+ return out
32
+
33
+
34
+ class InputValidationError(ServiceError):
35
+ """Modeled error for Smithy shape ``com.amazonaws.sagemakerruntimehttp2#InputValidationError``."""
36
+
37
+ code: str | None = "InputValidationError"
38
+
39
+ def __init__(self, data: InputValidationError_, message: str | None = None):
40
+ super().__init__(
41
+ "client",
42
+ is_throttling_error=False,
43
+ is_retryable=False,
44
+ code="InputValidationError",
45
+ message=message,
46
+ )
47
+ self.data = data
48
+
49
+ @classmethod
50
+ def from_json(
51
+ cls, data: dict, message: str | None = None
52
+ ) -> "InputValidationError":
53
+ return cls(deserialize_json(data), message)
@@ -0,0 +1,51 @@
1
+ """Generated from Smithy shape ``com.amazonaws.sagemakerruntimehttp2#InternalServerError``."""
2
+
3
+ from typing_extensions import NotRequired, TypedDict
4
+
5
+ from capo_sagemaker_runtime_http2.errors import ServiceError
6
+
7
+
8
+ class InternalServerError_(TypedDict, closed=True):
9
+ message: NotRequired["str"]
10
+ """<p>Error message.</p>"""
11
+ error_code: NotRequired["str"]
12
+ """<p>Error code.</p>"""
13
+
14
+
15
+ # --- restJson1 ser/de ---
16
+ def serialize_json(value: InternalServerError_) -> dict:
17
+ out: dict = {}
18
+ if "message" in value:
19
+ out["Message"] = value["message"]
20
+ if "error_code" in value:
21
+ out["ErrorCode"] = value["error_code"]
22
+ return out
23
+
24
+
25
+ def deserialize_json(data: dict) -> InternalServerError_:
26
+ out: InternalServerError_ = {} # type: ignore[typeddict-item]
27
+ if data.get("Message") is not None:
28
+ out["message"] = data["Message"]
29
+ if data.get("ErrorCode") is not None:
30
+ out["error_code"] = data["ErrorCode"]
31
+ return out
32
+
33
+
34
+ class InternalServerError(ServiceError):
35
+ """Modeled error for Smithy shape ``com.amazonaws.sagemakerruntimehttp2#InternalServerError``."""
36
+
37
+ code: str | None = "InternalServerError"
38
+
39
+ def __init__(self, data: InternalServerError_, message: str | None = None):
40
+ super().__init__(
41
+ "server",
42
+ is_throttling_error=False,
43
+ is_retryable=False,
44
+ code="InternalServerError",
45
+ message=message,
46
+ )
47
+ self.data = data
48
+
49
+ @classmethod
50
+ def from_json(cls, data: dict, message: str | None = None) -> "InternalServerError":
51
+ return cls(deserialize_json(data), message)
@@ -0,0 +1,61 @@
1
+ """Generated from Smithy shape ``com.amazonaws.sagemakerruntimehttp2#InternalStreamFailure``."""
2
+
3
+ from typing_extensions import NotRequired, TypedDict
4
+
5
+ from capo_sagemaker_runtime_http2._protocol.eventstream import HeaderValue, Message
6
+ from capo_sagemaker_runtime_http2.errors import ServiceError
7
+
8
+
9
+ class InternalStreamFailure_(TypedDict, closed=True):
10
+ message: NotRequired["str"]
11
+ """<p>Error message.</p>"""
12
+
13
+
14
+ # --- restJson1 ser/de ---
15
+ def serialize_json(value: InternalStreamFailure_) -> dict:
16
+ out: dict = {}
17
+ if "message" in value:
18
+ out["Message"] = value["message"]
19
+ return out
20
+
21
+
22
+ def deserialize_json(data: dict) -> InternalStreamFailure_:
23
+ out: InternalStreamFailure_ = {} # type: ignore[typeddict-item]
24
+ if data.get("Message") is not None:
25
+ out["message"] = data["Message"]
26
+ return out
27
+
28
+
29
+ class InternalStreamFailure(ServiceError):
30
+ """Modeled error for Smithy shape ``com.amazonaws.sagemakerruntimehttp2#InternalStreamFailure``."""
31
+
32
+ code: str | None = "InternalStreamFailure"
33
+
34
+ def __init__(self, data: InternalStreamFailure_, message: str | None = None):
35
+ super().__init__(
36
+ "server",
37
+ is_throttling_error=False,
38
+ is_retryable=False,
39
+ code="InternalStreamFailure",
40
+ message=message,
41
+ )
42
+ self.data = data
43
+
44
+ @classmethod
45
+ def from_json(
46
+ cls, data: dict, message: str | None = None
47
+ ) -> "InternalStreamFailure":
48
+ return cls(deserialize_json(data), message)
49
+
50
+
51
+ def serialize_event_json(value: InternalStreamFailure_) -> bytes:
52
+ headers: dict[str, HeaderValue] = {":event-type": "InternalStreamFailure"}
53
+ payload = b""
54
+ return Message(headers=headers, payload=payload).encode()
55
+
56
+
57
+ def deserialize_event_json(message: Message) -> InternalStreamFailure_:
58
+ headers = message.headers # noqa: F841
59
+ payload = message.payload # noqa: F841
60
+ out: InternalStreamFailure_ = {} # type: ignore[typeddict-item]
61
+ return out
@@ -0,0 +1,69 @@
1
+ """Generated from Smithy shape ``com.amazonaws.sagemakerruntimehttp2#ModelError``."""
2
+
3
+ from typing_extensions import NotRequired, TypedDict
4
+
5
+ from capo_sagemaker_runtime_http2.errors import ServiceError
6
+
7
+
8
+ class ModelError_(TypedDict, closed=True):
9
+ message: NotRequired["str"]
10
+ """<p>Error message.</p>"""
11
+ original_status_code: NotRequired["int"]
12
+ """<p>HTTP status code returned by model.</p>"""
13
+ original_message: NotRequired["str"]
14
+ """<p>Original error message from the model.</p>"""
15
+ log_stream_arn: NotRequired["str"]
16
+ """<p>CloudWatch log stream ARN.</p>"""
17
+ error_code: NotRequired["str"]
18
+ """<p>Error code.</p>"""
19
+
20
+
21
+ # --- restJson1 ser/de ---
22
+ def serialize_json(value: ModelError_) -> dict:
23
+ out: dict = {}
24
+ if "message" in value:
25
+ out["Message"] = value["message"]
26
+ if "original_status_code" in value:
27
+ out["OriginalStatusCode"] = value["original_status_code"]
28
+ if "original_message" in value:
29
+ out["OriginalMessage"] = value["original_message"]
30
+ if "log_stream_arn" in value:
31
+ out["LogStreamArn"] = value["log_stream_arn"]
32
+ if "error_code" in value:
33
+ out["ErrorCode"] = value["error_code"]
34
+ return out
35
+
36
+
37
+ def deserialize_json(data: dict) -> ModelError_:
38
+ out: ModelError_ = {} # type: ignore[typeddict-item]
39
+ if data.get("Message") is not None:
40
+ out["message"] = data["Message"]
41
+ if data.get("OriginalStatusCode") is not None:
42
+ out["original_status_code"] = data["OriginalStatusCode"]
43
+ if data.get("OriginalMessage") is not None:
44
+ out["original_message"] = data["OriginalMessage"]
45
+ if data.get("LogStreamArn") is not None:
46
+ out["log_stream_arn"] = data["LogStreamArn"]
47
+ if data.get("ErrorCode") is not None:
48
+ out["error_code"] = data["ErrorCode"]
49
+ return out
50
+
51
+
52
+ class ModelError(ServiceError):
53
+ """Modeled error for Smithy shape ``com.amazonaws.sagemakerruntimehttp2#ModelError``."""
54
+
55
+ code: str | None = "ModelError"
56
+
57
+ def __init__(self, data: ModelError_, message: str | None = None):
58
+ super().__init__(
59
+ "client",
60
+ is_throttling_error=False,
61
+ is_retryable=False,
62
+ code="ModelError",
63
+ message=message,
64
+ )
65
+ self.data = data
66
+
67
+ @classmethod
68
+ def from_json(cls, data: dict, message: str | None = None) -> "ModelError":
69
+ return cls(deserialize_json(data), message)
@@ -0,0 +1,65 @@
1
+ """Generated from Smithy shape ``com.amazonaws.sagemakerruntimehttp2#ModelStreamError``."""
2
+
3
+ from typing_extensions import NotRequired, TypedDict
4
+
5
+ from capo_sagemaker_runtime_http2._protocol.eventstream import HeaderValue, Message
6
+ from capo_sagemaker_runtime_http2.errors import ServiceError
7
+
8
+
9
+ class ModelStreamError_(TypedDict, closed=True):
10
+ message: NotRequired["str"]
11
+ """<p>Error message.</p>"""
12
+ error_code: NotRequired["str"]
13
+ """<p>Error code.</p>"""
14
+
15
+
16
+ # --- restJson1 ser/de ---
17
+ def serialize_json(value: ModelStreamError_) -> dict:
18
+ out: dict = {}
19
+ if "message" in value:
20
+ out["Message"] = value["message"]
21
+ if "error_code" in value:
22
+ out["ErrorCode"] = value["error_code"]
23
+ return out
24
+
25
+
26
+ def deserialize_json(data: dict) -> ModelStreamError_:
27
+ out: ModelStreamError_ = {} # type: ignore[typeddict-item]
28
+ if data.get("Message") is not None:
29
+ out["message"] = data["Message"]
30
+ if data.get("ErrorCode") is not None:
31
+ out["error_code"] = data["ErrorCode"]
32
+ return out
33
+
34
+
35
+ class ModelStreamError(ServiceError):
36
+ """Modeled error for Smithy shape ``com.amazonaws.sagemakerruntimehttp2#ModelStreamError``."""
37
+
38
+ code: str | None = "ModelStreamError"
39
+
40
+ def __init__(self, data: ModelStreamError_, message: str | None = None):
41
+ super().__init__(
42
+ "client",
43
+ is_throttling_error=False,
44
+ is_retryable=False,
45
+ code="ModelStreamError",
46
+ message=message,
47
+ )
48
+ self.data = data
49
+
50
+ @classmethod
51
+ def from_json(cls, data: dict, message: str | None = None) -> "ModelStreamError":
52
+ return cls(deserialize_json(data), message)
53
+
54
+
55
+ def serialize_event_json(value: ModelStreamError_) -> bytes:
56
+ headers: dict[str, HeaderValue] = {":event-type": "ModelStreamError"}
57
+ payload = b""
58
+ return Message(headers=headers, payload=payload).encode()
59
+
60
+
61
+ def deserialize_event_json(message: Message) -> ModelStreamError_:
62
+ headers = message.headers # noqa: F841
63
+ payload = message.payload # noqa: F841
64
+ out: ModelStreamError_ = {} # type: ignore[typeddict-item]
65
+ return out
@@ -0,0 +1,53 @@
1
+ """Generated from Smithy shape ``com.amazonaws.sagemakerruntimehttp2#ServiceUnavailableError``."""
2
+
3
+ from typing_extensions import NotRequired, TypedDict
4
+
5
+ from capo_sagemaker_runtime_http2.errors import ServiceError
6
+
7
+
8
+ class ServiceUnavailableError_(TypedDict, closed=True):
9
+ message: NotRequired["str"]
10
+ """<p>Error message.</p>"""
11
+ error_code: NotRequired["str"]
12
+ """<p>Error code.</p>"""
13
+
14
+
15
+ # --- restJson1 ser/de ---
16
+ def serialize_json(value: ServiceUnavailableError_) -> dict:
17
+ out: dict = {}
18
+ if "message" in value:
19
+ out["Message"] = value["message"]
20
+ if "error_code" in value:
21
+ out["ErrorCode"] = value["error_code"]
22
+ return out
23
+
24
+
25
+ def deserialize_json(data: dict) -> ServiceUnavailableError_:
26
+ out: ServiceUnavailableError_ = {} # type: ignore[typeddict-item]
27
+ if data.get("Message") is not None:
28
+ out["message"] = data["Message"]
29
+ if data.get("ErrorCode") is not None:
30
+ out["error_code"] = data["ErrorCode"]
31
+ return out
32
+
33
+
34
+ class ServiceUnavailableError(ServiceError):
35
+ """Modeled error for Smithy shape ``com.amazonaws.sagemakerruntimehttp2#ServiceUnavailableError``."""
36
+
37
+ code: str | None = "ServiceUnavailableError"
38
+
39
+ def __init__(self, data: ServiceUnavailableError_, message: str | None = None):
40
+ super().__init__(
41
+ "server",
42
+ is_throttling_error=False,
43
+ is_retryable=False,
44
+ code="ServiceUnavailableError",
45
+ message=message,
46
+ )
47
+ self.data = data
48
+
49
+ @classmethod
50
+ def from_json(
51
+ cls, data: dict, message: str | None = None
52
+ ) -> "ServiceUnavailableError":
53
+ return cls(deserialize_json(data), message)
File without changes
@@ -0,0 +1,12 @@
1
+ """Generated from Smithy prelude shape ``smithy.api#Blob``."""
2
+
3
+ import base64
4
+
5
+
6
+ # --- restJson1 ser/de ---
7
+ def serialize_json(value: bytes) -> str:
8
+ return base64.b64encode(value).decode("ascii")
9
+
10
+
11
+ def deserialize_json(data: str) -> bytes:
12
+ return base64.b64decode(data)
@@ -0,0 +1,17 @@
1
+ """Generated from Smithy prelude shape ``smithy.api#Timestamp``."""
2
+
3
+ import datetime
4
+
5
+
6
+ # --- restJson1 ser/de ---
7
+ def serialize_json(value: datetime.datetime) -> float:
8
+ value = (
9
+ value.astimezone(datetime.timezone.utc)
10
+ if value.tzinfo
11
+ else value.replace(tzinfo=datetime.timezone.utc)
12
+ )
13
+ return value.timestamp()
14
+
15
+
16
+ def deserialize_json(data: float) -> datetime.datetime:
17
+ return datetime.datetime.fromtimestamp(float(data), tz=datetime.timezone.utc)
@@ -0,0 +1,21 @@
1
+ """Generated from Smithy shape ``com.amazonaws.sagemakerruntimehttp2#InvokeEndpointWithBidirectionalStreamInput``."""
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from typing_extensions import NotRequired, TypedDict
6
+
7
+ if TYPE_CHECKING:
8
+ import capo_sagemaker_runtime_http2.types.request_stream_event
9
+
10
+
11
+ class InvokeEndpointWithBidirectionalStreamInput(TypedDict, closed=True):
12
+ endpoint_name: "str"
13
+ """<p>The name of the endpoint to invoke.</p>"""
14
+ body: "capo_sagemaker_runtime_http2.types.request_stream_event.RequestStreamEvent"
15
+ """<p>The request payload stream.</p>"""
16
+ target_variant: NotRequired["str"]
17
+ """<p>Target variant for the request.</p>"""
18
+ model_invocation_path: NotRequired["str"]
19
+ """<p>Model invocation path.</p>"""
20
+ model_query_string: NotRequired["str"]
21
+ """<p>Model query string.</p>"""
@@ -0,0 +1,15 @@
1
+ """Generated from Smithy shape ``com.amazonaws.sagemakerruntimehttp2#InvokeEndpointWithBidirectionalStreamOutput``."""
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from typing_extensions import NotRequired, TypedDict
6
+
7
+ if TYPE_CHECKING:
8
+ import capo_sagemaker_runtime_http2.types.response_stream_event
9
+
10
+
11
+ class InvokeEndpointWithBidirectionalStreamOutput(TypedDict, closed=True):
12
+ body: "capo_sagemaker_runtime_http2.types.response_stream_event.ResponseStreamEvent"
13
+ """<p>The response payload stream.</p>"""
14
+ invoked_production_variant: NotRequired["str"]
15
+ """<p>The invoked production variant.</p>"""
@@ -0,0 +1,62 @@
1
+ """Generated from Smithy shape ``com.amazonaws.sagemakerruntimehttp2#RequestPayloadPart``."""
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from typing_extensions import NotRequired, TypedDict
6
+
7
+ from capo_sagemaker_runtime_http2._protocol.eventstream import HeaderValue, Message
8
+
9
+ if TYPE_CHECKING:
10
+ import capo_sagemaker_runtime_http2.types.sensitive_blob
11
+
12
+
13
+ class RequestPayloadPart(TypedDict, closed=True):
14
+ bytes: NotRequired[
15
+ "capo_sagemaker_runtime_http2.types.sensitive_blob.SensitiveBlob"
16
+ ]
17
+ """<p>The payload bytes.</p>"""
18
+ data_type: NotRequired["str"]
19
+ r"""<p>Data type header. Can be one of these possible values: \"UTF8\", \"BINARY\".</p>"""
20
+ completion_state: NotRequired["str"]
21
+ r"""<p>Completion state header. Can be one of these possible values: \"PARTIAL\", \"COMPLETE\".</p>"""
22
+ p: NotRequired["str"]
23
+ """<p>Padding string for alignment.</p>"""
24
+
25
+
26
+ # --- restJson1 ser/de ---
27
+ def serialize_json(value: RequestPayloadPart) -> dict:
28
+ out: dict = {}
29
+ return out
30
+
31
+
32
+ def deserialize_json(data: dict) -> RequestPayloadPart:
33
+ out: RequestPayloadPart = {} # type: ignore[typeddict-item]
34
+ return out
35
+
36
+
37
+ def serialize_event_json(value: RequestPayloadPart) -> bytes:
38
+ headers: dict[str, HeaderValue] = {":event-type": "PayloadPart"}
39
+ payload = b""
40
+ if "data_type" in value:
41
+ headers["DataType"] = value["data_type"]
42
+ if "completion_state" in value:
43
+ headers["CompletionState"] = value["completion_state"]
44
+ if "p" in value:
45
+ headers["P"] = value["p"]
46
+ payload = value["bytes"]
47
+ return Message(headers=headers, payload=payload).encode()
48
+
49
+
50
+ def deserialize_event_json(message: Message) -> RequestPayloadPart:
51
+ headers = message.headers # noqa: F841
52
+ payload = message.payload # noqa: F841
53
+ out: RequestPayloadPart = {} # type: ignore[typeddict-item]
54
+ if "DataType" in headers:
55
+ out["data_type"] = headers["DataType"] # ty: ignore[invalid-assignment]
56
+ if "CompletionState" in headers:
57
+ out["completion_state"] = headers["CompletionState"] # ty: ignore[invalid-assignment]
58
+ if "P" in headers:
59
+ out["p"] = headers["P"] # ty: ignore[invalid-assignment]
60
+ if payload:
61
+ out["bytes"] = payload
62
+ return out
@@ -0,0 +1,52 @@
1
+ """Generated from Smithy shape ``com.amazonaws.sagemakerruntimehttp2#RequestStreamEvent``."""
2
+
3
+ from typing import TYPE_CHECKING, TypeAlias
4
+
5
+ from typing_extensions import TypedDict
6
+
7
+ from capo_sagemaker_runtime_http2._iter import AnyIterator
8
+ from capo_sagemaker_runtime_http2._protocol.eventstream import Message
9
+
10
+ if TYPE_CHECKING:
11
+ import capo_sagemaker_runtime_http2.types.request_payload_part
12
+
13
+
14
+ class _RequestStreamEvent_PayloadPart(TypedDict, closed=True):
15
+ PayloadPart: (
16
+ "capo_sagemaker_runtime_http2.types.request_payload_part.RequestPayloadPart"
17
+ )
18
+
19
+
20
+ _RequestStreamEvent: TypeAlias = _RequestStreamEvent_PayloadPart
21
+ RequestStreamEvent: TypeAlias = AnyIterator[_RequestStreamEvent]
22
+
23
+
24
+ def serialize_event_json(value: _RequestStreamEvent) -> bytes:
25
+ match value:
26
+ case {"PayloadPart": payload}:
27
+ import capo_sagemaker_runtime_http2.types.request_payload_part
28
+
29
+ return capo_sagemaker_runtime_http2.types.request_payload_part.serialize_event_json(
30
+ payload
31
+ )
32
+ case _:
33
+ raise ValueError(f"RequestStreamEvent: unrecognized variant {value!r}")
34
+
35
+
36
+ def deserialize_event_json(message: Message) -> _RequestStreamEvent:
37
+ headers = message.headers
38
+ message_type = headers.get(":message-type", "event") # noqa: F841
39
+ event_type = headers.get(":event-type")
40
+ match event_type:
41
+ case "PayloadPart":
42
+ import capo_sagemaker_runtime_http2.types.request_payload_part
43
+
44
+ return {
45
+ "PayloadPart": capo_sagemaker_runtime_http2.types.request_payload_part.deserialize_event_json(
46
+ message
47
+ )
48
+ }
49
+ case _:
50
+ raise ValueError(
51
+ f"RequestStreamEvent: unrecognized event-type {event_type!r}"
52
+ )