aws-lambda-powertools 3.13.1a1__py3-none-any.whl → 3.13.1a3__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.
- aws_lambda_powertools/event_handler/api_gateway.py +34 -18
- aws_lambda_powertools/event_handler/bedrock_agent.py +1 -0
- aws_lambda_powertools/event_handler/lambda_function_url.py +2 -0
- aws_lambda_powertools/event_handler/vpc_lattice.py +4 -0
- aws_lambda_powertools/shared/version.py +1 -1
- {aws_lambda_powertools-3.13.1a1.dist-info → aws_lambda_powertools-3.13.1a3.dist-info}/METADATA +1 -1
- {aws_lambda_powertools-3.13.1a1.dist-info → aws_lambda_powertools-3.13.1a3.dist-info}/RECORD +9 -9
- {aws_lambda_powertools-3.13.1a1.dist-info → aws_lambda_powertools-3.13.1a3.dist-info}/LICENSE +0 -0
- {aws_lambda_powertools-3.13.1a1.dist-info → aws_lambda_powertools-3.13.1a3.dist-info}/WHEEL +0 -0
@@ -546,20 +546,20 @@ class Route:
|
|
546
546
|
|
547
547
|
return self._body_field
|
548
548
|
|
549
|
-
def _get_openapi_path(
|
549
|
+
def _get_openapi_path( # noqa PLR0912
|
550
550
|
self,
|
551
551
|
*,
|
552
552
|
dependant: Dependant,
|
553
553
|
operation_ids: set[str],
|
554
554
|
model_name_map: dict[TypeModelOrEnum, str],
|
555
555
|
field_mapping: dict[tuple[ModelField, Literal["validation", "serialization"]], JsonSchemaValue],
|
556
|
+
enable_validation: bool = False,
|
556
557
|
) -> tuple[dict[str, Any], dict[str, Any]]:
|
557
558
|
"""
|
558
559
|
Returns the OpenAPI path and definitions for the route.
|
559
560
|
"""
|
560
561
|
from aws_lambda_powertools.event_handler.openapi.dependant import get_flat_params
|
561
562
|
|
562
|
-
path = {}
|
563
563
|
definitions: dict[str, Any] = {}
|
564
564
|
|
565
565
|
# Gather all the route parameters
|
@@ -598,13 +598,18 @@ class Route:
|
|
598
598
|
if request_body_oai:
|
599
599
|
operation["requestBody"] = request_body_oai
|
600
600
|
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
601
|
+
operation_responses: dict[int, OpenAPIResponse] = {}
|
602
|
+
|
603
|
+
if enable_validation:
|
604
|
+
# Validation failure response (422) is added only if Enable Validation feature is true
|
605
|
+
operation_responses = {
|
606
|
+
422: {
|
607
|
+
"description": "Validation Error",
|
608
|
+
"content": {
|
609
|
+
_DEFAULT_CONTENT_TYPE: {"schema": {"$ref": f"{COMPONENT_REF_PREFIX}HTTPValidationError"}},
|
610
|
+
},
|
611
|
+
},
|
612
|
+
}
|
608
613
|
|
609
614
|
# Add custom response validation response, if exists
|
610
615
|
if self.custom_response_validation_http_code:
|
@@ -681,8 +686,7 @@ class Route:
|
|
681
686
|
}
|
682
687
|
|
683
688
|
operation["responses"] = operation_responses
|
684
|
-
path
|
685
|
-
|
689
|
+
path = {self.method.lower(): operation}
|
686
690
|
# Add the validation error schema to the definitions, but only if it hasn't been added yet
|
687
691
|
if "ValidationError" not in definitions:
|
688
692
|
definitions.update(
|
@@ -1575,6 +1579,7 @@ class ApiGatewayResolver(BaseRouter):
|
|
1575
1579
|
strip_prefixes: list[str | Pattern] | None = None,
|
1576
1580
|
enable_validation: bool = False,
|
1577
1581
|
response_validation_error_http_code: HTTPStatus | int | None = None,
|
1582
|
+
json_body_deserializer: Callable[[str], dict] | None = None,
|
1578
1583
|
):
|
1579
1584
|
"""
|
1580
1585
|
Parameters
|
@@ -1596,6 +1601,9 @@ class ApiGatewayResolver(BaseRouter):
|
|
1596
1601
|
Enables validation of the request body against the route schema, by default False.
|
1597
1602
|
response_validation_error_http_code
|
1598
1603
|
Sets the returned status code if response is not validated. enable_validation must be True.
|
1604
|
+
json_body_deserializer: Callable[[str], dict], optional
|
1605
|
+
function to deserialize `str`, `bytes`, `bytearray` containing a JSON document to a Python `dict`,
|
1606
|
+
by default json.loads when integrating with EventSource data class
|
1599
1607
|
"""
|
1600
1608
|
self._proxy_type = proxy_type
|
1601
1609
|
self._dynamic_routes: list[Route] = []
|
@@ -1621,6 +1629,7 @@ class ApiGatewayResolver(BaseRouter):
|
|
1621
1629
|
|
1622
1630
|
# Allow for a custom serializer or a concise json serialization
|
1623
1631
|
self._serializer = serializer or partial(json.dumps, separators=(",", ":"), cls=Encoder)
|
1632
|
+
self._json_body_deserializer = json_body_deserializer
|
1624
1633
|
|
1625
1634
|
if self._enable_validation:
|
1626
1635
|
from aws_lambda_powertools.event_handler.middlewares.openapi_validation import OpenAPIValidationMiddleware
|
@@ -1834,6 +1843,7 @@ class ApiGatewayResolver(BaseRouter):
|
|
1834
1843
|
operation_ids=operation_ids,
|
1835
1844
|
model_name_map=model_name_map,
|
1836
1845
|
field_mapping=field_mapping,
|
1846
|
+
enable_validation=self._enable_validation,
|
1837
1847
|
)
|
1838
1848
|
if result:
|
1839
1849
|
path, path_definitions = self._add_resolver_response_validation_error_response_to_route(result)
|
@@ -2431,24 +2441,24 @@ class ApiGatewayResolver(BaseRouter):
|
|
2431
2441
|
"""Convert the event dict to the corresponding data class"""
|
2432
2442
|
if self._proxy_type == ProxyEventType.APIGatewayProxyEvent:
|
2433
2443
|
logger.debug("Converting event to API Gateway REST API contract")
|
2434
|
-
return APIGatewayProxyEvent(event)
|
2444
|
+
return APIGatewayProxyEvent(event, self._json_body_deserializer)
|
2435
2445
|
if self._proxy_type == ProxyEventType.APIGatewayProxyEventV2:
|
2436
2446
|
logger.debug("Converting event to API Gateway HTTP API contract")
|
2437
|
-
return APIGatewayProxyEventV2(event)
|
2447
|
+
return APIGatewayProxyEventV2(event, self._json_body_deserializer)
|
2438
2448
|
if self._proxy_type == ProxyEventType.BedrockAgentEvent:
|
2439
2449
|
logger.debug("Converting event to Bedrock Agent contract")
|
2440
|
-
return BedrockAgentEvent(event)
|
2450
|
+
return BedrockAgentEvent(event, self._json_body_deserializer)
|
2441
2451
|
if self._proxy_type == ProxyEventType.LambdaFunctionUrlEvent:
|
2442
2452
|
logger.debug("Converting event to Lambda Function URL contract")
|
2443
|
-
return LambdaFunctionUrlEvent(event)
|
2453
|
+
return LambdaFunctionUrlEvent(event, self._json_body_deserializer)
|
2444
2454
|
if self._proxy_type == ProxyEventType.VPCLatticeEvent:
|
2445
2455
|
logger.debug("Converting event to VPC Lattice contract")
|
2446
|
-
return VPCLatticeEvent(event)
|
2456
|
+
return VPCLatticeEvent(event, self._json_body_deserializer)
|
2447
2457
|
if self._proxy_type == ProxyEventType.VPCLatticeEventV2:
|
2448
2458
|
logger.debug("Converting event to VPC LatticeV2 contract")
|
2449
|
-
return VPCLatticeEventV2(event)
|
2459
|
+
return VPCLatticeEventV2(event, self._json_body_deserializer)
|
2450
2460
|
logger.debug("Converting event to ALB contract")
|
2451
|
-
return ALBEvent(event)
|
2461
|
+
return ALBEvent(event, self._json_body_deserializer)
|
2452
2462
|
|
2453
2463
|
def _resolve(self) -> ResponseBuilder:
|
2454
2464
|
"""Resolves the response or return the not found response"""
|
@@ -2865,6 +2875,7 @@ class APIGatewayRestResolver(ApiGatewayResolver):
|
|
2865
2875
|
strip_prefixes: list[str | Pattern] | None = None,
|
2866
2876
|
enable_validation: bool = False,
|
2867
2877
|
response_validation_error_http_code: HTTPStatus | int | None = None,
|
2878
|
+
json_body_deserializer: Callable[[str], dict] | None = None,
|
2868
2879
|
):
|
2869
2880
|
"""Amazon API Gateway REST and HTTP API v1 payload resolver"""
|
2870
2881
|
super().__init__(
|
@@ -2875,6 +2886,7 @@ class APIGatewayRestResolver(ApiGatewayResolver):
|
|
2875
2886
|
strip_prefixes,
|
2876
2887
|
enable_validation,
|
2877
2888
|
response_validation_error_http_code,
|
2889
|
+
json_body_deserializer=json_body_deserializer,
|
2878
2890
|
)
|
2879
2891
|
|
2880
2892
|
def _get_base_path(self) -> str:
|
@@ -2951,6 +2963,7 @@ class APIGatewayHttpResolver(ApiGatewayResolver):
|
|
2951
2963
|
strip_prefixes: list[str | Pattern] | None = None,
|
2952
2964
|
enable_validation: bool = False,
|
2953
2965
|
response_validation_error_http_code: HTTPStatus | int | None = None,
|
2966
|
+
json_body_deserializer: Callable[[str], dict] | None = None,
|
2954
2967
|
):
|
2955
2968
|
"""Amazon API Gateway HTTP API v2 payload resolver"""
|
2956
2969
|
super().__init__(
|
@@ -2961,6 +2974,7 @@ class APIGatewayHttpResolver(ApiGatewayResolver):
|
|
2961
2974
|
strip_prefixes,
|
2962
2975
|
enable_validation,
|
2963
2976
|
response_validation_error_http_code,
|
2977
|
+
json_body_deserializer=json_body_deserializer,
|
2964
2978
|
)
|
2965
2979
|
|
2966
2980
|
def _get_base_path(self) -> str:
|
@@ -2990,6 +3004,7 @@ class ALBResolver(ApiGatewayResolver):
|
|
2990
3004
|
strip_prefixes: list[str | Pattern] | None = None,
|
2991
3005
|
enable_validation: bool = False,
|
2992
3006
|
response_validation_error_http_code: HTTPStatus | int | None = None,
|
3007
|
+
json_body_deserializer: Callable[[str], dict] | None = None,
|
2993
3008
|
):
|
2994
3009
|
"""Amazon Application Load Balancer (ALB) resolver"""
|
2995
3010
|
super().__init__(
|
@@ -3000,6 +3015,7 @@ class ALBResolver(ApiGatewayResolver):
|
|
3000
3015
|
strip_prefixes,
|
3001
3016
|
enable_validation,
|
3002
3017
|
response_validation_error_http_code,
|
3018
|
+
json_body_deserializer=json_body_deserializer,
|
3003
3019
|
)
|
3004
3020
|
|
3005
3021
|
def _get_base_path(self) -> str:
|
@@ -61,6 +61,7 @@ class LambdaFunctionUrlResolver(ApiGatewayResolver):
|
|
61
61
|
strip_prefixes: list[str | Pattern] | None = None,
|
62
62
|
enable_validation: bool = False,
|
63
63
|
response_validation_error_http_code: HTTPStatus | int | None = None,
|
64
|
+
json_body_deserializer: Callable[[str], dict] | None = None,
|
64
65
|
):
|
65
66
|
super().__init__(
|
66
67
|
ProxyEventType.LambdaFunctionUrlEvent,
|
@@ -70,6 +71,7 @@ class LambdaFunctionUrlResolver(ApiGatewayResolver):
|
|
70
71
|
strip_prefixes,
|
71
72
|
enable_validation,
|
72
73
|
response_validation_error_http_code,
|
74
|
+
json_body_deserializer=json_body_deserializer,
|
73
75
|
)
|
74
76
|
|
75
77
|
def _get_base_path(self) -> str:
|
@@ -57,6 +57,7 @@ class VPCLatticeResolver(ApiGatewayResolver):
|
|
57
57
|
strip_prefixes: list[str | Pattern] | None = None,
|
58
58
|
enable_validation: bool = False,
|
59
59
|
response_validation_error_http_code: HTTPStatus | int | None = None,
|
60
|
+
json_body_deserializer: Callable[[str], dict] | None = None,
|
60
61
|
):
|
61
62
|
"""Amazon VPC Lattice resolver"""
|
62
63
|
super().__init__(
|
@@ -67,6 +68,7 @@ class VPCLatticeResolver(ApiGatewayResolver):
|
|
67
68
|
strip_prefixes,
|
68
69
|
enable_validation,
|
69
70
|
response_validation_error_http_code,
|
71
|
+
json_body_deserializer=json_body_deserializer,
|
70
72
|
)
|
71
73
|
|
72
74
|
def _get_base_path(self) -> str:
|
@@ -115,6 +117,7 @@ class VPCLatticeV2Resolver(ApiGatewayResolver):
|
|
115
117
|
strip_prefixes: list[str | Pattern] | None = None,
|
116
118
|
enable_validation: bool = False,
|
117
119
|
response_validation_error_http_code: HTTPStatus | int | None = None,
|
120
|
+
json_body_deserializer: Callable[[str], dict] | None = None,
|
118
121
|
):
|
119
122
|
"""Amazon VPC Lattice resolver"""
|
120
123
|
super().__init__(
|
@@ -125,6 +128,7 @@ class VPCLatticeV2Resolver(ApiGatewayResolver):
|
|
125
128
|
strip_prefixes,
|
126
129
|
enable_validation,
|
127
130
|
response_validation_error_http_code,
|
131
|
+
json_body_deserializer=json_body_deserializer,
|
128
132
|
)
|
129
133
|
|
130
134
|
def _get_base_path(self) -> str:
|
{aws_lambda_powertools-3.13.1a1.dist-info → aws_lambda_powertools-3.13.1a3.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: aws_lambda_powertools
|
3
|
-
Version: 3.13.
|
3
|
+
Version: 3.13.1a3
|
4
4
|
Summary: Powertools for AWS Lambda (Python) is a developer toolkit to implement Serverless best practices and increase developer velocity.
|
5
5
|
License: MIT
|
6
6
|
Keywords: aws_lambda_powertools,aws,tracing,logging,lambda,powertools,feature_flags,idempotency,middleware
|
{aws_lambda_powertools-3.13.1a1.dist-info → aws_lambda_powertools-3.13.1a3.dist-info}/RECORD
RENAMED
@@ -1,8 +1,8 @@
|
|
1
1
|
aws_lambda_powertools/__init__.py,sha256=o4iEHU0MfWC0_TfVmisxi0VOAUw5uQfqLQWr0t29ZaE,676
|
2
2
|
aws_lambda_powertools/event_handler/__init__.py,sha256=rbT-fYV_Lz8bcoecrtqkk0ZXh5-ccrWr1qvNecRCloc,1070
|
3
|
-
aws_lambda_powertools/event_handler/api_gateway.py,sha256=
|
3
|
+
aws_lambda_powertools/event_handler/api_gateway.py,sha256=XD51QGNfdq8ihkCu7YX-OAa6-Ny2Mr2j_-SXwBfLa7g,121997
|
4
4
|
aws_lambda_powertools/event_handler/appsync.py,sha256=MNUlaM-4Ioaejei4L5hoW_DuDgOkQWAtMmKZU_Jwce4,18530
|
5
|
-
aws_lambda_powertools/event_handler/bedrock_agent.py,sha256=
|
5
|
+
aws_lambda_powertools/event_handler/bedrock_agent.py,sha256=j3pKSDUmfb5MNcanqm78s9THh7bvh40LKKgnov95JcU,15146
|
6
6
|
aws_lambda_powertools/event_handler/content_types.py,sha256=0MKsKNu-SSrxbULVKnUjwgK-lVXhVD7BBjZ4Js0kEsI,163
|
7
7
|
aws_lambda_powertools/event_handler/events_appsync/__init__.py,sha256=_SkA-qYoSdpDhPFHLxpFz8RacjMRMY6R8FFElQ3Otzs,144
|
8
8
|
aws_lambda_powertools/event_handler/events_appsync/_registry.py,sha256=pzFQfv662Y0DPZQXCgJgabYZq-1gfasV5Mdl_aC9FBc,3071
|
@@ -19,7 +19,7 @@ aws_lambda_powertools/event_handler/graphql_appsync/_registry.py,sha256=cKbu_6Zq
|
|
19
19
|
aws_lambda_powertools/event_handler/graphql_appsync/base.py,sha256=xbU2sLWyTjfNpbOK_NjQszDf2LgVRhozRt9HysLI3oM,5422
|
20
20
|
aws_lambda_powertools/event_handler/graphql_appsync/exceptions.py,sha256=vTayCG3teb2XBfAhCMtTBDOOF1LJYs4uijY9GwQ5a-s,221
|
21
21
|
aws_lambda_powertools/event_handler/graphql_appsync/router.py,sha256=zMyJ63Ck1ySqv3PofmpQs8lexJKiEkoEZATeLzu9aiI,2253
|
22
|
-
aws_lambda_powertools/event_handler/lambda_function_url.py,sha256=
|
22
|
+
aws_lambda_powertools/event_handler/lambda_function_url.py,sha256=uNJY36nGLwyuuGNPmbyrcvOKGt-5UIMgJKPdRzgnskM,2471
|
23
23
|
aws_lambda_powertools/event_handler/middlewares/__init__.py,sha256=3R5XptoCT8owm4swcAEG0lsV_zbL4X-gU5nv8eJ0jQs,158
|
24
24
|
aws_lambda_powertools/event_handler/middlewares/base.py,sha256=llr1_sGaAsyMY9Gn4zKUDxePQ5X7ClcqgjqPesg5FJw,3724
|
25
25
|
aws_lambda_powertools/event_handler/middlewares/openapi_validation.py,sha256=L7QjXgRT9c_PsKNVwk08uCFYGdf0htu5D_warAM2N34,16091
|
@@ -43,7 +43,7 @@ aws_lambda_powertools/event_handler/openapi/types.py,sha256=qIUSazCYnMu2GKwXrih-
|
|
43
43
|
aws_lambda_powertools/event_handler/router.py,sha256=cxL3MtN2Q8_RkPndNtAAcjJSqDJ4WN02dro_O83nxAM,980
|
44
44
|
aws_lambda_powertools/event_handler/types.py,sha256=yppbl_2wdyXSK_oTkSnkwPdAlJibc-uTm1IWmlB1RfU,177
|
45
45
|
aws_lambda_powertools/event_handler/util.py,sha256=MQvqlA1Cf7SkoEJbPP-0VVIYyBCSGFWLSbo5nAB5vaY,3217
|
46
|
-
aws_lambda_powertools/event_handler/vpc_lattice.py,sha256=
|
46
|
+
aws_lambda_powertools/event_handler/vpc_lattice.py,sha256=RTOgGxc-cVCZ7-4XsLEoZXn6N2SVfUVJ9JT4Yojzjyg,3945
|
47
47
|
aws_lambda_powertools/exceptions/__init__.py,sha256=bv7fiO8Cj5xbHOTlDpWpM3pIkbdSB74Nt_mHbzLzYDw,163
|
48
48
|
aws_lambda_powertools/logging/__init__.py,sha256=G5MTkVqaQvpfa7k3fGkj4QN0KU6nFfP0_SLF_47G_VE,72
|
49
49
|
aws_lambda_powertools/logging/buffer/__init__.py,sha256=2sdmJToRBp6QJI2VQuvgjuxsJkTMd4dL3TYp6dASiOQ,109
|
@@ -97,7 +97,7 @@ aws_lambda_powertools/shared/json_encoder.py,sha256=JQeWNu-4M7_xI_hqYExrxsb3OcEH
|
|
97
97
|
aws_lambda_powertools/shared/lazy_import.py,sha256=TbXQm2bcwXdZrYdBaJJXIswyLlumM85RJ_A_0w-h-GU,2019
|
98
98
|
aws_lambda_powertools/shared/types.py,sha256=EZ_tbX3F98LA4Zcra1hTEjzRacpZAtggK957Zcv1oKg,135
|
99
99
|
aws_lambda_powertools/shared/user_agent.py,sha256=DrCMFQuT4a4iIrpcWpAIjY37EFqR9-QxlxDGD-Nn9Gg,7081
|
100
|
-
aws_lambda_powertools/shared/version.py,sha256=
|
100
|
+
aws_lambda_powertools/shared/version.py,sha256=u2MIsLNOjSGxlp_F3zJ-Yk1ky9w9W4GtisE0lpA9q_8,85
|
101
101
|
aws_lambda_powertools/tracing/__init__.py,sha256=f4bMThOPBPWTPVcYqcAIErAJPerMsf3H_Z4gCXCsK9I,141
|
102
102
|
aws_lambda_powertools/tracing/base.py,sha256=WSO986XGBOe9K0F2SnG6ustJokIrtO0m0mcL8N7mfno,4544
|
103
103
|
aws_lambda_powertools/tracing/extensions.py,sha256=APOfXOq-hRBKaK5WyfIyrd_6M1_9SWJZ3zxLA9jDZzU,492
|
@@ -269,7 +269,7 @@ aws_lambda_powertools/utilities/validation/envelopes.py,sha256=YD5HOFx6IClQgii0n
|
|
269
269
|
aws_lambda_powertools/utilities/validation/exceptions.py,sha256=PKy_19zQMBJGCMMFl-sMkcm-cc0v3zZBn_bhGE4wKNo,2084
|
270
270
|
aws_lambda_powertools/utilities/validation/validator.py,sha256=khCqFhACSdn0nKyYRRPiC5Exht956hTfSfhlV3IRmpg,10099
|
271
271
|
aws_lambda_powertools/warnings/__init__.py,sha256=vqDVeZz8wGtD8WGYNSkQE7AHwqtIrPGRxuoJR_BBnSs,1193
|
272
|
-
aws_lambda_powertools-3.13.
|
273
|
-
aws_lambda_powertools-3.13.
|
274
|
-
aws_lambda_powertools-3.13.
|
275
|
-
aws_lambda_powertools-3.13.
|
272
|
+
aws_lambda_powertools-3.13.1a3.dist-info/LICENSE,sha256=vMHS2eBgmwPUIMPb7LQ4p7ib_FPVQXarVjAasflrTwo,951
|
273
|
+
aws_lambda_powertools-3.13.1a3.dist-info/METADATA,sha256=pCZjV6CbL9oSDzVHAOZuW4IgXzEuoXEPSzsI_TPcuMs,11273
|
274
|
+
aws_lambda_powertools-3.13.1a3.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
275
|
+
aws_lambda_powertools-3.13.1a3.dist-info/RECORD,,
|
{aws_lambda_powertools-3.13.1a1.dist-info → aws_lambda_powertools-3.13.1a3.dist-info}/LICENSE
RENAMED
File without changes
|
File without changes
|