Skip to content

Commit 01e597e

Browse files
Merge branch 'develop' into fix_transform_and_cache_get_parameters_response
2 parents 81f598e + e34a8a8 commit 01e597e

10 files changed

Lines changed: 742 additions & 567 deletions

File tree

CHANGELOG.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,35 @@
88

99
* **event_handler:** split OpenAPI validation to respect middleware returns ([#7050](https://github.com/aws-powertools/powertools-lambda-python/issues/7050))
1010

11+
## Code Refactoring
12+
13+
* **parser:** Improve Kinesis models with examples and descriptions ([#7092](https://github.com/aws-powertools/powertools-lambda-python/issues/7092))
14+
* **parser:** Improve EventBridge models with examples and descriptions ([#7090](https://github.com/aws-powertools/powertools-lambda-python/issues/7090))
15+
16+
## Features
17+
18+
* **parameters:** add support for retrieving batch of secrets ([#7058](https://github.com/aws-powertools/powertools-lambda-python/issues/7058))
19+
1120
## Maintenance
1221

22+
* **ci:** new pre-release 3.18.1a2 ([#7085](https://github.com/aws-powertools/powertools-lambda-python/issues/7085))
1323
* **ci:** new pre-release 3.18.1a0 ([#7068](https://github.com/aws-powertools/powertools-lambda-python/issues/7068))
1424
* **ci:** new pre-release 3.18.1a1 ([#7077](https://github.com/aws-powertools/powertools-lambda-python/issues/7077))
25+
* **deps:** bump mkdocs-material from 9.6.15 to 9.6.16 ([#7065](https://github.com/aws-powertools/powertools-lambda-python/issues/7065))
1526
* **deps:** bump mkdocs-material from 9.6.15 to 9.6.16 in /docs ([#7060](https://github.com/aws-powertools/powertools-lambda-python/issues/7060))
1627
* **deps:** bump aws-powertools/actions from 1.1.0 to 1.3.0 ([#7061](https://github.com/aws-powertools/powertools-lambda-python/issues/7061))
17-
* **deps:** bump mkdocs-material from 9.6.15 to 9.6.16 ([#7065](https://github.com/aws-powertools/powertools-lambda-python/issues/7065))
1828
* **deps:** bump squidfunk/mkdocs-material from `0bfdba4` to `bb7b015` in /docs ([#7059](https://github.com/aws-powertools/powertools-lambda-python/issues/7059))
29+
* **deps-dev:** bump cfn-lint from 1.38.0 to 1.38.1 ([#7080](https://github.com/aws-powertools/powertools-lambda-python/issues/7080))
30+
* **deps-dev:** bump mypy from 1.17.0 to 1.17.1 ([#7081](https://github.com/aws-powertools/powertools-lambda-python/issues/7081))
1931
* **deps-dev:** bump aws-cdk from 2.1022.0 to 2.1023.0 ([#7067](https://github.com/aws-powertools/powertools-lambda-python/issues/7067))
2032
* **deps-dev:** bump boto3-stubs from 1.39.16 to 1.39.17 ([#7072](https://github.com/aws-powertools/powertools-lambda-python/issues/7072))
33+
* **deps-dev:** bump sentry-sdk from 2.33.2 to 2.34.0 ([#7064](https://github.com/aws-powertools/powertools-lambda-python/issues/7064))
2134
* **deps-dev:** bump boto3-stubs from 1.39.14 to 1.39.16 ([#7066](https://github.com/aws-powertools/powertools-lambda-python/issues/7066))
2235
* **deps-dev:** bump coverage from 7.10.0 to 7.10.1 ([#7063](https://github.com/aws-powertools/powertools-lambda-python/issues/7063))
2336
* **deps-dev:** bump ruff from 0.12.5 to 0.12.7 ([#7073](https://github.com/aws-powertools/powertools-lambda-python/issues/7073))
2437
* **deps-dev:** bump aws-cdk-aws-lambda-python-alpha from 2.207.0a0 to 2.208.0a0 ([#7062](https://github.com/aws-powertools/powertools-lambda-python/issues/7062))
2538
* **deps-dev:** bump sentry-sdk from 2.34.0 to 2.34.1 ([#7075](https://github.com/aws-powertools/powertools-lambda-python/issues/7075))
26-
* **deps-dev:** bump sentry-sdk from 2.33.2 to 2.34.0 ([#7064](https://github.com/aws-powertools/powertools-lambda-python/issues/7064))
39+
* **deps-dev:** bump mypy-boto3-appconfigdata from 1.39.0 to 1.40.0 in the boto-typing group ([#7079](https://github.com/aws-powertools/powertools-lambda-python/issues/7079))
2740

2841

2942
<a name="v3.17.1"></a>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Exposes version constant to avoid circular dependencies."""
22

3-
VERSION = "3.18.1a1"
3+
VERSION = "3.18.1a3"

aws_lambda_powertools/utilities/parser/models/event_bridge.py

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,53 @@
99
class EventBridgeModel(BaseModel):
1010
model_config = ConfigDict(populate_by_name=True)
1111

12-
version: str
13-
id: str # noqa: A003,VNE003
14-
source: str
15-
account: str
16-
time: datetime
17-
region: str
18-
resources: List[str]
19-
detail_type: str = Field(..., alias="detail-type")
20-
detail: RawDictOrModel
21-
replay_name: Optional[str] = Field(None, alias="replay-name")
12+
version: str = Field(description="By default, this is set to 0 (zero) in all events.", examples=["0"])
13+
id: str = Field( # noqa: A003,VNE003
14+
description="A Version 4 UUID generated for every event.",
15+
examples=["6a7e8feb-b491-4cf7-a9f1-bf3703467718"],
16+
)
17+
source: str = Field(
18+
description="Identifies the service that sourced the event. \
19+
All events sourced from within AWS begin with 'aws.'",
20+
examples=["aws.ec2", "aws.s3", "aws.events", "aws.scheduler"],
21+
)
22+
account: str = Field(
23+
description="The 12-digit AWS account ID of the owner of the service emitting the event.",
24+
examples=["111122223333", "123456789012"],
25+
)
26+
time: datetime = Field(
27+
description="The event timestamp, which can be specified by the service originating the event.",
28+
examples=["2017-12-22T18:43:48Z", "2023-01-15T10:30:00Z"],
29+
)
30+
region: str = Field(
31+
description="Identifies the AWS region where the event originated.",
32+
examples=["us-east-1", "us-west-2", "eu-west-1"],
33+
)
34+
resources: List[str] = Field(
35+
description="A JSON array that contains ARNs that identify resources involved in the event. "
36+
"Inclusion of these ARNs is at the discretion of the service.",
37+
examples=[
38+
["arn:aws:ec2:us-west-1:123456789012:instance/i-1234567890abcdef0"],
39+
["arn:aws:s3:::my-bucket/my-key"],
40+
["arn:aws:events:us-east-1:123456789012:rule/MyRule"],
41+
],
42+
)
43+
detail_type: str = Field(
44+
...,
45+
alias="detail-type",
46+
description="Identifies, in combination with the source field, \
47+
the fields and values that appear in the detail field.",
48+
examples=["EC2 Instance State-change Notification", "Object Created", "Scheduled Event"],
49+
)
50+
detail: RawDictOrModel = Field(
51+
description="A JSON object, whose content is at the discretion of the service originating the event.",
52+
)
53+
replay_name: Optional[str] = Field(
54+
None,
55+
alias="replay-name",
56+
description="Identifies whether the event is being replayed and what is the name of the replay.",
57+
examples=["replay_archive", "my-replay-2023"],
58+
)
2259

2360
@field_validator("detail", mode="before")
2461
def validate_detail(cls, v, fields):

aws_lambda_powertools/utilities/parser/models/kinesis.py

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import zlib
33
from typing import Dict, List, Literal, Type, Union
44

5-
from pydantic import BaseModel, field_validator
5+
from pydantic import BaseModel, Field, field_validator
66

77
from aws_lambda_powertools.shared.functions import base64_decode
88
from aws_lambda_powertools.utilities.parser.models.cloudwatch import (
@@ -11,26 +11,61 @@
1111

1212

1313
class KinesisDataStreamRecordPayload(BaseModel):
14-
kinesisSchemaVersion: str
15-
partitionKey: str
16-
sequenceNumber: str
17-
data: Union[bytes, Type[BaseModel], BaseModel] # base64 encoded str is parsed into bytes
18-
approximateArrivalTimestamp: float
14+
kinesisSchemaVersion: str = Field(
15+
description="The version of the Kinesis Data Streams record format.",
16+
examples=["1.0"],
17+
)
18+
partitionKey: str = Field(
19+
description="The partition key that was used to place the record in the stream.",
20+
examples=["user123", "device-001", "order-12345"],
21+
)
22+
sequenceNumber: str = Field(
23+
description="The unique sequence number for the record within the shard.",
24+
examples=[
25+
"49590338271490256608559692538361571095921575989136588898",
26+
"49545115243490985018280067714973144582180062593244200961",
27+
],
28+
)
29+
data: Union[bytes, Type[BaseModel], BaseModel] = Field( # base64 encoded str is parsed into bytes
30+
description="The data payload of the record. Base64 encoded string is automatically decoded to bytes.",
31+
)
32+
approximateArrivalTimestamp: float = Field(
33+
description="The approximate time that the record was inserted into the stream (Unix timestamp).",
34+
examples=[1428537600.0, 1609459200.5],
35+
)
1936

2037
@field_validator("data", mode="before")
2138
def data_base64_decode(cls, value):
2239
return base64_decode(value)
2340

2441

2542
class KinesisDataStreamRecord(BaseModel):
26-
eventSource: Literal["aws:kinesis"]
27-
eventVersion: str
28-
eventID: str
29-
eventName: Literal["aws:kinesis:record"]
30-
invokeIdentityArn: str
31-
awsRegion: str
32-
eventSourceARN: str
33-
kinesis: KinesisDataStreamRecordPayload
43+
eventSource: Literal["aws:kinesis"] = Field(
44+
description="The AWS service that generated the event.",
45+
examples=["aws:kinesis"],
46+
)
47+
eventVersion: str = Field(description="The version of the event schema.", examples=["1.0"])
48+
eventID: str = Field(
49+
description="A unique identifier for the event.",
50+
examples=["shardId-000000000006:49590338271490256608559692538361571095921575989136588898"],
51+
)
52+
eventName: Literal["aws:kinesis:record"] = Field(
53+
description="The name of the event type.",
54+
examples=["aws:kinesis:record"],
55+
)
56+
invokeIdentityArn: str = Field(
57+
description="The ARN of the IAM role used to invoke the Lambda function.",
58+
examples=["arn:aws:iam::123456789012:role/lambda-kinesis-role"],
59+
)
60+
awsRegion: str = Field(
61+
description="The AWS region where the Kinesis stream is located.",
62+
examples=["us-east-1", "us-west-2", "eu-west-1"],
63+
)
64+
eventSourceARN: str = Field(
65+
description="The ARN of the Kinesis stream that generated the event.",
66+
examples=["arn:aws:kinesis:us-east-1:123456789012:stream/my-stream"],
67+
)
68+
kinesis: KinesisDataStreamRecordPayload = Field(description="The Kinesis-specific data for the record.")
3469

3570
def decompress_zlib_record_data_as_json(self) -> Dict:
3671
"""Decompress Kinesis Record bytes data zlib compressed to JSON"""
@@ -41,7 +76,10 @@ def decompress_zlib_record_data_as_json(self) -> Dict:
4176

4277

4378
class KinesisDataStreamModel(BaseModel):
44-
Records: List[KinesisDataStreamRecord]
79+
Records: List[KinesisDataStreamRecord] = Field(
80+
description="A list of Kinesis Data Stream records that triggered the Lambda function.",
81+
examples=[[]],
82+
)
4583

4684

4785
def extract_cloudwatch_logs_from_event(event: KinesisDataStreamModel) -> List[CloudWatchLogsDecode]:
Lines changed: 64 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,81 @@
11
from typing import List, Optional, Type, Union
22

3-
from pydantic import BaseModel, PositiveInt, field_validator
3+
from pydantic import BaseModel, Field, PositiveInt, field_validator
44

55
from aws_lambda_powertools.shared.functions import base64_decode
66

77

88
class KinesisFirehoseRecordMetadata(BaseModel):
9-
shardId: str
10-
partitionKey: str
11-
approximateArrivalTimestamp: PositiveInt
12-
sequenceNumber: str
13-
subsequenceNumber: int
9+
shardId: str = Field(
10+
description="The shard ID of the Kinesis stream record.",
11+
examples=["shardId-000000000000", "shardId-000000000001"],
12+
)
13+
partitionKey: str = Field(
14+
description="The partition key of the Kinesis stream record.",
15+
examples=["user123", "device-001", "transaction-456"],
16+
)
17+
approximateArrivalTimestamp: PositiveInt = Field(
18+
description="The approximate time when the record arrived in the Kinesis stream \
19+
(Unix timestamp in milliseconds).",
20+
examples=[1428537600000, 1609459200500],
21+
)
22+
sequenceNumber: str = Field(
23+
description="The sequence number of the Kinesis stream record.",
24+
examples=["49590338271490256608559692538361571095921575989136588898"],
25+
)
26+
subsequenceNumber: int = Field(
27+
description="The subsequence number for records that share the same sequence number.",
28+
examples=[0, 1, 2],
29+
)
1430

1531

1632
class KinesisFirehoseRecord(BaseModel):
17-
data: Union[bytes, Type[BaseModel]] # base64 encoded str is parsed into bytes
18-
recordId: str
19-
approximateArrivalTimestamp: PositiveInt
20-
kinesisRecordMetadata: Optional[KinesisFirehoseRecordMetadata] = None
33+
data: Union[bytes, Type[BaseModel]] = Field( # base64 encoded str is parsed into bytes
34+
description="The data payload of the record. Base64 encoded string is automatically decoded to bytes.",
35+
)
36+
recordId: str = Field(
37+
description="A unique identifier for the record within the batch.",
38+
examples=[
39+
"49546986683135544286507457936321625675700192471156785154",
40+
"49546986683135544286507457936321625675700192471156785155",
41+
],
42+
)
43+
approximateArrivalTimestamp: PositiveInt = Field(
44+
description="The approximate time when the record arrived in Kinesis Data Firehose \
45+
(Unix timestamp in milliseconds).",
46+
examples=[1428537600000, 1609459200500],
47+
)
48+
kinesisRecordMetadata: Optional[KinesisFirehoseRecordMetadata] = Field(
49+
None,
50+
description="Metadata about the original Kinesis stream record \
51+
(only present when the delivery stream source is a Kinesis stream).",
52+
)
2153

2254
@field_validator("data", mode="before")
2355
def data_base64_decode(cls, value):
2456
return base64_decode(value)
2557

2658

2759
class KinesisFirehoseModel(BaseModel):
28-
invocationId: str
29-
deliveryStreamArn: str
30-
region: str
31-
sourceKinesisStreamArn: Optional[str] = None
32-
records: List[KinesisFirehoseRecord]
60+
invocationId: str = Field(
61+
description="A unique identifier for the Lambda invocation.",
62+
examples=["invocationIdExample", "12345678-1234-1234-1234-123456789012"],
63+
)
64+
deliveryStreamArn: str = Field(
65+
description="The ARN of the Kinesis Data Firehose delivery stream.",
66+
examples=["arn:aws:firehose:us-east-1:123456789012:deliverystream/my-delivery-stream"],
67+
)
68+
region: str = Field(
69+
description="The AWS region where the delivery stream is located.",
70+
examples=["us-east-1", "us-west-2", "eu-west-1"],
71+
)
72+
sourceKinesisStreamArn: Optional[str] = Field(
73+
None,
74+
description="The ARN of the source Kinesis stream \
75+
(only present when the delivery stream source is a Kinesis stream).",
76+
examples=["arn:aws:kinesis:us-east-1:123456789012:stream/my-source-stream"],
77+
)
78+
records: List[KinesisFirehoseRecord] = Field(
79+
description="A list of records to be processed by the Lambda function.",
80+
examples=[[]],
81+
)
Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
22
from typing import List, Optional
33

4-
from pydantic import BaseModel, PositiveInt, field_validator
4+
from pydantic import BaseModel, Field, PositiveInt, field_validator
55

66
from aws_lambda_powertools.shared.functions import base64_decode
77
from aws_lambda_powertools.utilities.parser.models import KinesisFirehoseRecordMetadata
@@ -10,10 +10,21 @@
1010

1111

1212
class KinesisFirehoseSqsRecord(BaseModel):
13-
data: SqsRecordModel
14-
recordId: str
15-
approximateArrivalTimestamp: PositiveInt
16-
kinesisRecordMetadata: Optional[KinesisFirehoseRecordMetadata] = None
13+
data: SqsRecordModel = Field(description="The SQS record data that was delivered through Kinesis Data Firehose.")
14+
recordId: str = Field(
15+
description="A unique identifier for the record within the batch.",
16+
examples=["49546986683135544286507457936321625675700192471156785154"],
17+
)
18+
approximateArrivalTimestamp: PositiveInt = Field(
19+
description="The approximate time when the record arrived in Kinesis Data Firehose \
20+
(Unix timestamp in milliseconds).",
21+
examples=[1428537600000, 1609459200500],
22+
)
23+
kinesisRecordMetadata: Optional[KinesisFirehoseRecordMetadata] = Field(
24+
None,
25+
description="Metadata about the original Kinesis stream record \
26+
(only present when the delivery stream source is a Kinesis stream).",
27+
)
1728

1829
@field_validator("data", mode="before")
1930
def data_base64_decode(cls, value):
@@ -22,8 +33,26 @@ def data_base64_decode(cls, value):
2233

2334

2435
class KinesisFirehoseSqsModel(BaseModel):
25-
invocationId: str
26-
deliveryStreamArn: str
27-
region: str
28-
sourceKinesisStreamArn: Optional[str] = None
29-
records: List[KinesisFirehoseSqsRecord]
36+
invocationId: str = Field(
37+
description="A unique identifier for the Lambda invocation.",
38+
examples=["invocationIdExample", "12345678-1234-1234-1234-123456789012"],
39+
)
40+
deliveryStreamArn: str = Field(
41+
description="The ARN of the Kinesis Data Firehose delivery stream.",
42+
examples=["arn:aws:firehose:us-east-1:123456789012:deliverystream/my-sqs-delivery-stream"],
43+
)
44+
region: str = Field(
45+
description="The AWS region where the delivery stream is located.",
46+
examples=["us-east-1", "us-west-2", "eu-west-1"],
47+
)
48+
sourceKinesisStreamArn: Optional[str] = Field(
49+
None,
50+
description="The ARN of the source Kinesis stream \
51+
(only present when the delivery stream source is a Kinesis stream).",
52+
examples=["arn:aws:kinesis:us-east-1:123456789012:stream/my-source-stream"],
53+
)
54+
records: List[KinesisFirehoseSqsRecord] = Field(
55+
description="A list of SQS records delivered through Kinesis Data Firehose \
56+
to be processed by the Lambda function.",
57+
examples=[[]],
58+
)

0 commit comments

Comments
 (0)