Skip to content

Commit f88ca79

Browse files
leandrodamascenasinofseven
authored andcommitted
docs(api): migrating the event handler utility to mkdocstrings (aws-powertools#6023)
Mkdocstrings - Event handler
1 parent a95c8c7 commit f88ca79

File tree

15 files changed

+34
-15
lines changed

15 files changed

+34
-15
lines changed

Diff for: aws_lambda_powertools/event_handler/api_gateway.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,10 @@ def __init__(
313313
middlewares: list[Callable[..., Response]] | None = None,
314314
):
315315
"""
316+
Internally used Route Configuration
316317
317318
Parameters
318319
----------
319-
320320
method: str
321321
The HTTP method, example "GET"
322322
path: str
@@ -908,6 +908,8 @@ def build(self, event: ResponseEventT, cors: CORSConfig | None = None) -> dict[s
908908

909909

910910
class BaseRouter(ABC):
911+
"""Base class for Routing"""
912+
911913
current_event: BaseProxyEvent
912914
lambda_context: LambdaContext
913915
context: dict
@@ -1459,7 +1461,7 @@ def _registered_api_adapter(app: ApiGatewayResolver, next_middleware: Callable[.
14591461

14601462

14611463
class ApiGatewayResolver(BaseRouter):
1462-
"""API Gateway and ALB proxy resolver
1464+
"""API Gateway, VPC Laticce, Bedrock and ALB proxy resolver
14631465
14641466
Examples
14651467
--------
@@ -2570,6 +2572,8 @@ def register_exception_handler(func: Callable):
25702572

25712573

25722574
class APIGatewayRestResolver(ApiGatewayResolver):
2575+
"""Amazon API Gateway REST and HTTP API v1 payload resolver"""
2576+
25732577
current_event: APIGatewayProxyEvent
25742578

25752579
def __init__(
@@ -2650,6 +2654,8 @@ def _compile_regex(rule: str, base_regex: str = _ROUTE_REGEX):
26502654

26512655

26522656
class APIGatewayHttpResolver(ApiGatewayResolver):
2657+
"""Amazon API Gateway HTTP API v2 payload resolver"""
2658+
26532659
current_event: APIGatewayProxyEventV2
26542660

26552661
def __init__(
@@ -2685,6 +2691,8 @@ def _get_base_path(self) -> str:
26852691

26862692

26872693
class ALBResolver(ApiGatewayResolver):
2694+
"""Amazon Application Load Balancer (ALB) resolver"""
2695+
26882696
current_event: ALBEvent
26892697

26902698
def __init__(

Diff for: aws_lambda_powertools/event_handler/middlewares/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class BaseMiddlewareHandler(Generic[EventHandlerInstance], ABC):
2626
This is the middleware handler function where middleware logic is implemented.
2727
The next middleware handler is represented by `next_middleware`, returning a Response object.
2828
29-
Examples
29+
Example
3030
--------
3131
3232
**Correlation ID Middleware**

Diff for: aws_lambda_powertools/event_handler/middlewares/openapi_validation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class OpenAPIValidationMiddleware(BaseMiddlewareHandler):
3737
Lambda handler. It also validates the response against the OpenAPI schema defined by the Lambda handler. It
3838
should not be used directly, but rather through the `enable_validation` parameter of the `ApiGatewayResolver`.
3939
40-
Examples
40+
Example
4141
--------
4242
4343
```python

Diff for: aws_lambda_powertools/event_handler/middlewares/schema_validation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class SchemaValidationMiddleware(BaseMiddlewareHandler):
1919
"""Middleware to validate API request and response against JSON Schema using the [Validation utility](https://docs.powertools.aws.dev/lambda/python/latest/utilities/validation/).
2020
21-
Examples
21+
Example
2222
--------
2323
**Validating incoming event**
2424

Diff for: aws_lambda_powertools/event_handler/openapi/params.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -879,8 +879,6 @@ def get_flat_dependant(
879879
----------
880880
dependant: Dependant
881881
The dependant model to flatten
882-
skip_repeats: bool
883-
If True, child Dependents already visited will be skipped to avoid duplicates
884882
visited: list[CacheKey], optional
885883
Keeps track of visited Dependents to avoid infinite recursion. Defaults to empty list.
886884
@@ -932,8 +930,9 @@ def analyze_param(
932930
ModelField | None
933931
The type annotation and the Pydantic field representing the parameter
934932
"""
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+
)
937936

938937
# If the value is a FieldInfo, we use it as the FieldInfo for the parameter
939938
if isinstance(value, FieldInfo):
@@ -964,7 +963,7 @@ def analyze_param(
964963

965964

966965
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,
968967
) -> tuple[FieldInfo | None, Any]:
969968
"""
970969
Get the FieldInfo and type annotation from an annotation and value.

Diff for: aws_lambda_powertools/event_handler/openapi/swagger_ui/html.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def generate_swagger_html(
2222
spec: str
2323
The OpenAPI spec
2424
swagger_js: str
25-
Swagger UI JavaScript source code or URL
25+
Swagger UI JavaScript source code or URL
2626
swagger_css: str
2727
Swagger UI CSS source code or URL
2828
swagger_base_url: str

Diff for: aws_lambda_powertools/logging/exceptions.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ class InvalidLoggerSamplingRateError(Exception):
22
"""
33
Logger configured with Invalid Sampling value
44
"""
5+
56
pass

Diff for: aws_lambda_powertools/logging/logger.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
!!! abstract "Usage Documentation"
44
[`Logger`](../../core/logger.md)
55
"""
6+
67
from __future__ import annotations
78

89
import functools

Diff for: aws_lambda_powertools/metrics/provider/datadog/datadog.py

-4
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ def add_metric(
8787
Timestamp in int for the metrics, default = time.time()
8888
tags: list[str]
8989
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']
9490
9591
Examples
9692
--------

Diff for: aws_lambda_powertools/tracing/base.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
!!! abstract "Usage Documentation"
44
[`Tracer`](../../core/tracer.md)
55
"""
6+
67
from __future__ import annotations
78

89
import abc

Diff for: docs/api_doc/event_handler/api_gateway.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!-- markdownlint-disable MD043 MD041 -->
2+
::: aws_lambda_powertools.event_handler.api_gateway

Diff for: docs/api_doc/event_handler/appsync.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!-- markdownlint-disable MD043 MD041 -->
2+
::: aws_lambda_powertools.event_handler.appsync

Diff for: docs/api_doc/event_handler/middleware.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!-- markdownlint-disable MD043 MD041 -->
2+
::: aws_lambda_powertools.event_handler.middlewares

Diff for: docs/api_doc/event_handler/openapi.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!-- markdownlint-disable MD043 MD041 -->
2+
::: aws_lambda_powertools.event_handler.openapi

Diff for: mkdocs.yml

+5
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ nav:
7272
- Base: api_doc/data_masking/base.md
7373
- Exception: api_doc/data_masking/exceptions.md
7474
- Provider: api_doc/data_masking/provider.md
75+
- Event Handler:
76+
- AppSync: api_doc/event_handler/appsync.md
77+
- Middleware: api_doc/event_handler/middleware.md
78+
- OpenAPI: api_doc/event_handler/openapi.md
79+
- REST: api_doc/event_handler/api_gateway.md
7580
- Feature Flags:
7681
- AppConfig: api_doc/feature_flags/appconfig.md
7782
- Base: api_doc/feature_flags/base.md

0 commit comments

Comments
 (0)