Serialization
MODULE | DESCRIPTION |
---|---|
base |
Serialization for supporting idempotency |
custom_dict |
|
dataclass |
|
functions |
|
no_op |
|
pydantic |
|
base ¶
Serialization for supporting idempotency
CLASS | DESCRIPTION |
---|---|
BaseIdempotencyModelSerializer |
Abstract Base Class for Idempotency serialization layer, for using a model as data object representation. |
BaseIdempotencySerializer |
Abstract Base Class for Idempotency serialization layer, supporting dict operations. |
BaseIdempotencyModelSerializer ¶
Bases: BaseIdempotencySerializer
Abstract Base Class for Idempotency serialization layer, for using a model as data object representation.
METHOD | DESCRIPTION |
---|---|
instantiate |
Creates an instance of a serializer based on a provided model type. |
instantiate
abstractmethod
classmethod
¶
instantiate(model_type: Any) -> BaseIdempotencySerializer
Creates an instance of a serializer based on a provided model type.
In case the model_type is unknown, None will be sent as model_type
.
It's on the implementer to verify that:
- None is handled correctly
- A model type not matching the expected types is handled
PARAMETER | DESCRIPTION |
---|---|
model_type
|
The model type to instantiate the class for
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BaseIdempotencySerializer
|
Instance of the serializer class |
Source code in aws_lambda_powertools/utilities/idempotency/serialization/base.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
custom_dict ¶
CLASS | DESCRIPTION |
---|---|
CustomDictSerializer |
|
CustomDictSerializer ¶
CustomDictSerializer(
to_dict: Callable[[Any], dict],
from_dict: Callable[[dict], Any],
)
Bases: BaseIdempotencySerializer
Source code in aws_lambda_powertools/utilities/idempotency/serialization/custom_dict.py
9 10 11 12 13 14 15 16 17 18 19 |
|
dataclass ¶
CLASS | DESCRIPTION |
---|---|
DataclassSerializer |
A serializer class for transforming data between dataclass objects and dictionaries. |
DataclassSerializer ¶
DataclassSerializer(model: type[DataClass])
Bases: BaseIdempotencyModelSerializer
A serializer class for transforming data between dataclass objects and dictionaries.
Source code in aws_lambda_powertools/utilities/idempotency/serialization/dataclass.py
24 25 26 27 28 29 30 31 |
|
functions ¶
FUNCTION | DESCRIPTION |
---|---|
get_actual_type |
Extract the actual type from a potentially Optional or Union type. |
get_actual_type ¶
get_actual_type(model_type: Any) -> Any
Extract the actual type from a potentially Optional or Union type. This function handles types that may be wrapped in Optional or Union, including the Python 3.10+ Union syntax (Type | None).
PARAMETER | DESCRIPTION |
---|---|
model_type
|
The type to analyze. Can be a simple type, Optional[Type], BaseModel, dataclass
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
The actual type without Optional or Union wrappers.
|
|
Raises
|
TYPE:
|
Source code in aws_lambda_powertools/utilities/idempotency/serialization/functions.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
no_op ¶
CLASS | DESCRIPTION |
---|---|
NoOpSerializer |
|
NoOpSerializer ¶
NoOpSerializer()
Bases: BaseIdempotencySerializer
Default serializer, does not transform data
Source code in aws_lambda_powertools/utilities/idempotency/serialization/no_op.py
7 8 9 10 11 12 |
|
pydantic ¶
CLASS | DESCRIPTION |
---|---|
PydanticSerializer |
Pydantic serializer for idempotency models |
PydanticSerializer ¶
PydanticSerializer(model: type[BaseModel])
Bases: BaseIdempotencyModelSerializer
Pydantic serializer for idempotency models
Source code in aws_lambda_powertools/utilities/idempotency/serialization/pydantic.py
21 22 23 24 25 26 27 28 |
|