GeezerVison is showing github.com — docs(api): migrating the event handler utility to mkdocstrings (#6023) · aks3213/powertools-lambda-python@b66abf5
File treeExpand file treeCollapse file tree Open diff view settings docs/api_doc/event_handler
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: aws_lambda_powertools/event_handler/api_gateway.py +10-2Lines changed: 10 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -313,10 +313,10 @@ def __init__( | 313 | 313 | middlewares: list[Callable[..., Response]] | None = None, | 314 | 314 | ): | 315 | 315 | """ | | 316 | + Internally used Route Configuration | 316 | 317 |
| 317 | 318 | Parameters | 318 | 319 | ---------- | 319 | | -
| 320 | 320 | method: str | 321 | 321 | The HTTP method, example "GET" | 322 | 322 | path: str | @@ -908,6 +908,8 @@ def build(self, event: ResponseEventT, cors: CORSConfig | None = None) -> dict[s | 908 | 908 |
| 909 | 909 |
| 910 | 910 | class BaseRouter(ABC): | | 911 | + """Base class for Routing""" | | 912 | + | 911 | 913 | current_event: BaseProxyEvent | 912 | 914 | lambda_context: LambdaContext | 913 | 915 | context: dict | @@ -1459,7 +1461,7 @@ def _registered_api_adapter(app: ApiGatewayResolver, next_middleware: Callable[. | 1459 | 1461 |
| 1460 | 1462 |
| 1461 | 1463 | class ApiGatewayResolver(BaseRouter): | 1462 | | - """API Gateway and ALB proxy resolver | | 1464 | + """API Gateway, VPC Laticce, Bedrock and ALB proxy resolver | 1463 | 1465 |
| 1464 | 1466 | Examples | 1465 | 1467 | -------- | @@ -2570,6 +2572,8 @@ def register_exception_handler(func: Callable): | 2570 | 2572 |
| 2571 | 2573 |
| 2572 | 2574 | class APIGatewayRestResolver(ApiGatewayResolver): | | 2575 | + """Amazon API Gateway REST and HTTP API v1 payload resolver""" | | 2576 | + | 2573 | 2577 | current_event: APIGatewayProxyEvent | 2574 | 2578 |
| 2575 | 2579 | def __init__( | @@ -2650,6 +2654,8 @@ def _compile_regex(rule: str, base_regex: str = _ROUTE_REGEX): | 2650 | 2654 |
| 2651 | 2655 |
| 2652 | 2656 | class APIGatewayHttpResolver(ApiGatewayResolver): | | 2657 | + """Amazon API Gateway HTTP API v2 payload resolver""" | | 2658 | + | 2653 | 2659 | current_event: APIGatewayProxyEventV2 | 2654 | 2660 |
| 2655 | 2661 | def __init__( | @@ -2685,6 +2691,8 @@ def _get_base_path(self) -> str: | 2685 | 2691 |
| 2686 | 2692 |
| 2687 | 2693 | class ALBResolver(ApiGatewayResolver): | | 2694 | + """Amazon Application Load Balancer (ALB) resolver""" | | 2695 | + | 2688 | 2696 | current_event: ALBEvent | 2689 | 2697 |
| 2690 | 2698 | def __init__( | |
Collapse file Copy file name to clipboardExpand all lines: aws_lambda_powertools/event_handler/middlewares/base.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -26,7 +26,7 @@ class BaseMiddlewareHandler(Generic[EventHandlerInstance], ABC): | 26 | 26 | This is the middleware handler function where middleware logic is implemented. | 27 | 27 | The next middleware handler is represented by `next_middleware`, returning a Response object. | 28 | 28 |
| 29 | | - Examples | | 29 | + Example | 30 | 30 | -------- | 31 | 31 |
| 32 | 32 | **Correlation ID Middleware** | |
Collapse file Copy file name to clipboardExpand all lines: aws_lambda_powertools/event_handler/middlewares/openapi_validation.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -37,7 +37,7 @@ class OpenAPIValidationMiddleware(BaseMiddlewareHandler): | 37 | 37 | Lambda handler. It also validates the response against the OpenAPI schema defined by the Lambda handler. It | 38 | 38 | should not be used directly, but rather through the `enable_validation` parameter of the `ApiGatewayResolver`. | 39 | 39 |
| 40 | | - Examples | | 40 | + Example | 41 | 41 | -------- | 42 | 42 |
| 43 | 43 | ```python | |
Collapse file Copy file name to clipboardExpand all lines: aws_lambda_powertools/event_handler/middlewares/schema_validation.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 18 | 18 | class SchemaValidationMiddleware(BaseMiddlewareHandler): | 19 | 19 | """Middleware to validate API request and response against JSON Schema using the [Validation utility](https://docs.powertools.aws.dev/lambda/python/latest/utilities/validation/). | 20 | 20 |
| 21 | | - Examples | | 21 | + Example | 22 | 22 | -------- | 23 | 23 | **Validating incoming event** | 24 | 24 |
| |
Collapse file Copy file name to clipboardExpand all lines: aws_lambda_powertools/event_handler/openapi/params.py +4-5Lines changed: 4 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -879,8 +879,6 @@ def get_flat_dependant( | 879 | 879 | ---------- | 880 | 880 | dependant: Dependant | 881 | 881 | The dependant model to flatten | 882 | | - skip_repeats: bool | 883 | | - If True, child Dependents already visited will be skipped to avoid duplicates | 884 | 882 | visited: list[CacheKey], optional | 885 | 883 | Keeps track of visited Dependents to avoid infinite recursion. Defaults to empty list. | 886 | 884 |
| @@ -932,8 +930,9 @@ def analyze_param( | 932 | 930 | ModelField | None | 933 | 931 | The type annotation and the Pydantic field representing the parameter | 934 | 932 | """ | 935 | | - field_info, type_annotation = \ | 936 | | - get_field_info_and_type_annotation(annotation, value, is_path_param, is_response_param) | | 933 | + field_info, type_annotation = get_field_info_and_type_annotation( | | 934 | + annotation, value, is_path_param, is_response_param, | | 935 | + ) | 937 | 936 |
| 938 | 937 | # If the value is a FieldInfo, we use it as the FieldInfo for the parameter | 939 | 938 | if isinstance(value, FieldInfo): | @@ -964,7 +963,7 @@ def analyze_param( | 964 | 963 |
| 965 | 964 |
| 966 | 965 | def get_field_info_and_type_annotation( | 967 | | - annotation, value, is_path_param: bool, is_response_param: bool | | 966 | + annotation, value, is_path_param: bool, is_response_param: bool, | 968 | 967 | ) -> tuple[FieldInfo | None, Any]: | 969 | 968 | """ | 970 | 969 | Get the FieldInfo and type annotation from an annotation and value. | |
Collapse file Copy file name to clipboardExpand all lines: aws_lambda_powertools/event_handler/openapi/swagger_ui/html.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -22,7 +22,7 @@ def generate_swagger_html( | 22 | 22 | spec: str | 23 | 23 | The OpenAPI spec | 24 | 24 | swagger_js: str | 25 | | - Swagger UI JavaScript source code or URL | | 25 | + Swagger UI JavaScript source code or URL | 26 | 26 | swagger_css: str | 27 | 27 | Swagger UI CSS source code or URL | 28 | 28 | swagger_base_url: str | |
Collapse file Copy file name to clipboardExpand all lines: aws_lambda_powertools/logging/exceptions.py +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,4 +2,5 @@ class InvalidLoggerSamplingRateError(Exception): | 2 | 2 | """ | 3 | 3 | Logger configured with Invalid Sampling value | 4 | 4 | """ | | 5 | + | 5 | 6 | pass |
Collapse file Copy file name to clipboardExpand all lines: aws_lambda_powertools/logging/logger.py +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | !!! abstract "Usage Documentation" | 4 | 4 | [`Logger`](../../core/logger.md) | 5 | 5 | """ | | 6 | + | 6 | 7 | from __future__ import annotations | 7 | 8 |
| 8 | 9 | import functools | |
Collapse file Copy file name to clipboardExpand all lines: aws_lambda_powertools/metrics/provider/datadog/datadog.py -4Lines changed: 0 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -87,10 +87,6 @@ def add_metric( | 87 | 87 | Timestamp in int for the metrics, default = time.time() | 88 | 88 | tags: list[str] | 89 | 89 | In format like ["tag:value", "tag2:value2"] | 90 | | - args: Any | 91 | | - extra args will be dropped for compatibility | 92 | | - kwargs: Any | 93 | | - extra kwargs will be converted into tags, e.g., add_metrics(sales=sam) -> tags=['sales:sam'] | 94 | 90 |
| 95 | 91 | Examples | 96 | 92 | -------- | |
Collapse file Copy file name to clipboardExpand all lines: aws_lambda_powertools/tracing/base.py +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | !!! abstract "Usage Documentation" | 4 | 4 | [`Tracer`](../../core/tracer.md) | 5 | 5 | """ | | 6 | + | 6 | 7 | from __future__ import annotations | 7 | 8 |
| 8 | 9 | import abc | |
|