Skip to content

Commit a247ffd

Browse files
Merge branch 'develop' into feat/parser-improve-sqs-models
2 parents a1d1b82 + 0cf950b commit a247ffd

File tree

6 files changed

+243
-136
lines changed

6 files changed

+243
-136
lines changed

CHANGELOG.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,71 +28,71 @@
2828
* **ci:** new pre-release 3.19.1a11 ([#7278](https://github.com/aws-powertools/powertools-lambda-python/issues/7278))
2929
* **ci:** new pre-release 3.19.1a4 ([#7217](https://github.com/aws-powertools/powertools-lambda-python/issues/7217))
3030
* **ci:** new pre-release 3.19.1a10 ([#7269](https://github.com/aws-powertools/powertools-lambda-python/issues/7269))
31-
* **ci:** new pre-release 3.19.1a3 ([#7207](https://github.com/aws-powertools/powertools-lambda-python/issues/7207))
3231
* **ci:** new pre-release 3.19.1a5 ([#7226](https://github.com/aws-powertools/powertools-lambda-python/issues/7226))
32+
* **ci:** new pre-release 3.19.1a3 ([#7207](https://github.com/aws-powertools/powertools-lambda-python/issues/7207))
33+
* **ci:** new pre-release 3.19.1a0 ([#7161](https://github.com/aws-powertools/powertools-lambda-python/issues/7161))
3334
* **ci:** new pre-release 3.19.1a9 ([#7256](https://github.com/aws-powertools/powertools-lambda-python/issues/7256))
34-
* **ci:** new pre-release 3.19.1a6 ([#7232](https://github.com/aws-powertools/powertools-lambda-python/issues/7232))
3535
* **ci:** new pre-release 3.19.1a1 ([#7172](https://github.com/aws-powertools/powertools-lambda-python/issues/7172))
3636
* **ci:** new pre-release 3.19.1a8 ([#7247](https://github.com/aws-powertools/powertools-lambda-python/issues/7247))
3737
* **ci:** new pre-release 3.19.1a7 ([#7244](https://github.com/aws-powertools/powertools-lambda-python/issues/7244))
38-
* **ci:** new pre-release 3.19.1a0 ([#7161](https://github.com/aws-powertools/powertools-lambda-python/issues/7161))
3938
* **ci:** new pre-release 3.19.1a2 ([#7192](https://github.com/aws-powertools/powertools-lambda-python/issues/7192))
40-
* **deps:** bump mkdocs-material from 9.6.17 to 9.6.18 ([#7237](https://github.com/aws-powertools/powertools-lambda-python/issues/7237))
41-
* **deps:** bump squidfunk/mkdocs-material from `bb7b015` to `405aeb6` in /docs ([#7185](https://github.com/aws-powertools/powertools-lambda-python/issues/7185))
39+
* **ci:** new pre-release 3.19.1a6 ([#7232](https://github.com/aws-powertools/powertools-lambda-python/issues/7232))
40+
* **deps:** bump protobuf from 6.31.1 to 6.32.0 ([#7208](https://github.com/aws-powertools/powertools-lambda-python/issues/7208))
41+
* **deps:** bump mkdocs-material from 9.6.16 to 9.6.17 ([#7188](https://github.com/aws-powertools/powertools-lambda-python/issues/7188))
4242
* **deps:** bump squidfunk/mkdocs-material from `405aeb6` to `1a4e939` in /docs ([#7236](https://github.com/aws-powertools/powertools-lambda-python/issues/7236))
43-
* **deps:** bump aws-powertools/actions from 1.4.0 to 1.5.0 ([#7180](https://github.com/aws-powertools/powertools-lambda-python/issues/7180))
43+
* **deps:** bump squidfunk/mkdocs-material from `bb7b015` to `405aeb6` in /docs ([#7185](https://github.com/aws-powertools/powertools-lambda-python/issues/7185))
4444
* **deps:** bump mkdocs-material from 9.6.17 to 9.6.18 in /docs ([#7235](https://github.com/aws-powertools/powertools-lambda-python/issues/7235))
45-
* **deps:** bump typing-extensions from 4.14.1 to 4.15.0 ([#7251](https://github.com/aws-powertools/powertools-lambda-python/issues/7251))
46-
* **deps:** bump mkdocstrings-python from 1.17.0 to 1.18.0 ([#7254](https://github.com/aws-powertools/powertools-lambda-python/issues/7254))
47-
* **deps:** bump mkdocs-material from 9.6.16 to 9.6.17 ([#7188](https://github.com/aws-powertools/powertools-lambda-python/issues/7188))
45+
* **deps:** bump aws-powertools/actions from 1.4.0 to 1.5.0 ([#7180](https://github.com/aws-powertools/powertools-lambda-python/issues/7180))
46+
* **deps:** bump mkdocs-material from 9.6.17 to 9.6.18 ([#7237](https://github.com/aws-powertools/powertools-lambda-python/issues/7237))
4847
* **deps:** bump fastjsonschema from 2.21.1 to 2.21.2 ([#7179](https://github.com/aws-powertools/powertools-lambda-python/issues/7179))
48+
* **deps:** bump mkdocstrings-python from 1.17.0 to 1.18.0 ([#7254](https://github.com/aws-powertools/powertools-lambda-python/issues/7254))
4949
* **deps:** bump actions/dependency-review-action from 4.7.2 to 4.7.3 ([#7255](https://github.com/aws-powertools/powertools-lambda-python/issues/7255))
50-
* **deps:** bump protobuf from 6.31.1 to 6.32.0 ([#7208](https://github.com/aws-powertools/powertools-lambda-python/issues/7208))
50+
* **deps:** bump actions/dependency-review-action from 4.7.1 to 4.7.2 ([#7203](https://github.com/aws-powertools/powertools-lambda-python/issues/7203))
5151
* **deps:** bump codecov/codecov-action from 5.4.3 to 5.5.0 ([#7221](https://github.com/aws-powertools/powertools-lambda-python/issues/7221))
5252
* **deps:** bump aws-actions/configure-aws-credentials from 0eb446ecb2e3f0e1a19f106e12e76c6a98b6bdb2 to 241c954d319becef88d2022775301737d5eb5e24 ([#7260](https://github.com/aws-powertools/powertools-lambda-python/issues/7260))
5353
* **deps:** bump aws-actions/configure-aws-credentials from 241c954d319becef88d2022775301737d5eb5e24 to 1b2b73eb6a459c3a91fde76ba4c255e5b4b8e94e ([#7266](https://github.com/aws-powertools/powertools-lambda-python/issues/7266))
5454
* **deps:** bump aws-actions/configure-aws-credentials from 09a74e37ceda446282c61f1496cdca8d8dca0e57 to 0eb446ecb2e3f0e1a19f106e12e76c6a98b6bdb2 ([#7222](https://github.com/aws-powertools/powertools-lambda-python/issues/7222))
55-
* **deps:** bump aws-actions/configure-aws-credentials from aa1f74b81b53cb3adb28afcdb21d7b9f3fceea98 to 209f2a4450bb4b277e1dedaff40ad2fd8d4d0a4c ([#7160](https://github.com/aws-powertools/powertools-lambda-python/issues/7160))
56-
* **deps:** bump mkdocs-material from 9.6.16 to 9.6.17 ([#7216](https://github.com/aws-powertools/powertools-lambda-python/issues/7216))
5755
* **deps:** bump mkdocstrings-python from 1.17.0 to 1.18.0 ([#7268](https://github.com/aws-powertools/powertools-lambda-python/issues/7268))
56+
* **deps:** bump aws-actions/configure-aws-credentials from aa1f74b81b53cb3adb28afcdb21d7b9f3fceea98 to 209f2a4450bb4b277e1dedaff40ad2fd8d4d0a4c ([#7160](https://github.com/aws-powertools/powertools-lambda-python/issues/7160))
57+
* **deps:** bump aws-actions/configure-aws-credentials from 209f2a4450bb4b277e1dedaff40ad2fd8d4d0a4c to 3821430d177f66b128b701e38ba67c5319b1b0bd ([#7202](https://github.com/aws-powertools/powertools-lambda-python/issues/7202))
5858
* **deps:** bump mkdocstrings-python from 1.16.12 to 1.17.0 ([#7206](https://github.com/aws-powertools/powertools-lambda-python/issues/7206))
5959
* **deps:** bump aws-actions/configure-aws-credentials from 3821430d177f66b128b701e38ba67c5319b1b0bd to 09a74e37ceda446282c61f1496cdca8d8dca0e57 ([#7213](https://github.com/aws-powertools/powertools-lambda-python/issues/7213))
6060
* **deps:** bump mkdocstrings-python from 1.18.0 to 1.18.2 in /docs ([#7273](https://github.com/aws-powertools/powertools-lambda-python/issues/7273))
6161
* **deps:** bump mkdocstrings-python from 1.18.0 to 1.18.2 ([#7277](https://github.com/aws-powertools/powertools-lambda-python/issues/7277))
62-
* **deps:** bump actions/dependency-review-action from 4.7.1 to 4.7.2 ([#7203](https://github.com/aws-powertools/powertools-lambda-python/issues/7203))
63-
* **deps:** bump aws-actions/configure-aws-credentials from 209f2a4450bb4b277e1dedaff40ad2fd8d4d0a4c to 3821430d177f66b128b701e38ba67c5319b1b0bd ([#7202](https://github.com/aws-powertools/powertools-lambda-python/issues/7202))
62+
* **deps:** bump mkdocs-material from 9.6.16 to 9.6.17 ([#7216](https://github.com/aws-powertools/powertools-lambda-python/issues/7216))
63+
* **deps:** bump typing-extensions from 4.14.1 to 4.15.0 ([#7251](https://github.com/aws-powertools/powertools-lambda-python/issues/7251))
6464
* **deps:** bump mkdocstrings-python from 1.16.12 to 1.17.0 in /docs ([#7187](https://github.com/aws-powertools/powertools-lambda-python/issues/7187))
65-
* **deps-dev:** bump coverage from 7.10.3 to 7.10.4 ([#7205](https://github.com/aws-powertools/powertools-lambda-python/issues/7205))
65+
* **deps-dev:** bump boto3-stubs from 1.40.15 to 1.40.16 ([#7240](https://github.com/aws-powertools/powertools-lambda-python/issues/7240))
6666
* **deps-dev:** bump cfn-lint from 1.38.3 to 1.39.0 ([#7212](https://github.com/aws-powertools/powertools-lambda-python/issues/7212))
6767
* **deps-dev:** bump requests from 2.32.4 to 2.32.5 ([#7215](https://github.com/aws-powertools/powertools-lambda-python/issues/7215))
6868
* **deps-dev:** bump boto3-stubs from 1.40.11 to 1.40.12 ([#7204](https://github.com/aws-powertools/powertools-lambda-python/issues/7204))
6969
* **deps-dev:** bump boto3-stubs from 1.40.12 to 1.40.13 ([#7214](https://github.com/aws-powertools/powertools-lambda-python/issues/7214))
70-
* **deps-dev:** bump aws-cdk-aws-lambda-python-alpha from 2.211.0a0 to 2.212.0a0 ([#7223](https://github.com/aws-powertools/powertools-lambda-python/issues/7223))
70+
* **deps-dev:** bump boto3-stubs from 1.40.13 to 1.40.14 ([#7224](https://github.com/aws-powertools/powertools-lambda-python/issues/7224))
7171
* **deps-dev:** bump filelock from 3.18.0 to 3.19.1 ([#7177](https://github.com/aws-powertools/powertools-lambda-python/issues/7177))
7272
* **deps-dev:** bump boto3-stubs from 1.40.9 to 1.40.11 ([#7189](https://github.com/aws-powertools/powertools-lambda-python/issues/7189))
73-
* **deps-dev:** bump boto3-stubs from 1.40.13 to 1.40.14 ([#7224](https://github.com/aws-powertools/powertools-lambda-python/issues/7224))
7473
* **deps-dev:** bump boto3-stubs from 1.40.14 to 1.40.15 ([#7230](https://github.com/aws-powertools/powertools-lambda-python/issues/7230))
74+
* **deps-dev:** bump ruff from 0.12.9 to 0.12.10 ([#7231](https://github.com/aws-powertools/powertools-lambda-python/issues/7231))
7575
* **deps-dev:** bump aws-cdk from 2.1024.0 to 2.1025.0 ([#7167](https://github.com/aws-powertools/powertools-lambda-python/issues/7167))
7676
* **deps-dev:** bump sentry-sdk from 2.34.1 to 2.35.0 ([#7181](https://github.com/aws-powertools/powertools-lambda-python/issues/7181))
77-
* **deps-dev:** bump ruff from 0.12.9 to 0.12.10 ([#7231](https://github.com/aws-powertools/powertools-lambda-python/issues/7231))
7877
* **deps-dev:** bump types-protobuf from 6.30.2.20250809 to 6.30.2.20250822 ([#7241](https://github.com/aws-powertools/powertools-lambda-python/issues/7241))
7978
* **deps-dev:** bump types-python-dateutil from 2.9.0.20250809 to 2.9.0.20250822 ([#7238](https://github.com/aws-powertools/powertools-lambda-python/issues/7238))
8079
* **deps-dev:** bump aws-cdk from 2.1025.0 to 2.1026.0 ([#7239](https://github.com/aws-powertools/powertools-lambda-python/issues/7239))
80+
* **deps-dev:** bump coverage from 7.10.3 to 7.10.4 ([#7205](https://github.com/aws-powertools/powertools-lambda-python/issues/7205))
8181
* **deps-dev:** bump ruff from 0.12.8 to 0.12.9 ([#7182](https://github.com/aws-powertools/powertools-lambda-python/issues/7182))
82-
* **deps-dev:** bump boto3-stubs from 1.40.15 to 1.40.16 ([#7240](https://github.com/aws-powertools/powertools-lambda-python/issues/7240))
82+
* **deps-dev:** bump coverage from 7.10.4 to 7.10.5 ([#7249](https://github.com/aws-powertools/powertools-lambda-python/issues/7249))
8383
* **deps-dev:** bump aws-cdk-aws-lambda-python-alpha from 2.210.0a0 to 2.211.0a0 ([#7168](https://github.com/aws-powertools/powertools-lambda-python/issues/7168))
8484
* **deps-dev:** bump cfn-lint from 1.38.2 to 1.38.3 ([#7169](https://github.com/aws-powertools/powertools-lambda-python/issues/7169))
85-
* **deps-dev:** bump coverage from 7.10.4 to 7.10.5 ([#7249](https://github.com/aws-powertools/powertools-lambda-python/issues/7249))
8685
* **deps-dev:** bump boto3-stubs from 1.40.16 to 1.40.17 ([#7250](https://github.com/aws-powertools/powertools-lambda-python/issues/7250))
86+
* **deps-dev:** bump aws-cdk from 2.1026.0 to 2.1027.0 ([#7265](https://github.com/aws-powertools/powertools-lambda-python/issues/7265))
8787
* **deps-dev:** bump sentry-sdk from 2.35.0 to 2.35.1 ([#7258](https://github.com/aws-powertools/powertools-lambda-python/issues/7258))
8888
* **deps-dev:** bump boto3-stubs from 1.40.8 to 1.40.9 ([#7170](https://github.com/aws-powertools/powertools-lambda-python/issues/7170))
8989
* **deps-dev:** bump cfn-lint from 1.39.0 to 1.39.1 ([#7259](https://github.com/aws-powertools/powertools-lambda-python/issues/7259))
9090
* **deps-dev:** bump boto3-stubs from 1.40.17 to 1.40.18 ([#7264](https://github.com/aws-powertools/powertools-lambda-python/issues/7264))
9191
* **deps-dev:** bump boto3-stubs from 1.40.7 to 1.40.8 ([#7159](https://github.com/aws-powertools/powertools-lambda-python/issues/7159))
92-
* **deps-dev:** bump aws-cdk from 2.1026.0 to 2.1027.0 ([#7265](https://github.com/aws-powertools/powertools-lambda-python/issues/7265))
9392
* **deps-dev:** bump boto3-stubs from 1.40.18 to 1.40.19 ([#7267](https://github.com/aws-powertools/powertools-lambda-python/issues/7267))
9493
* **deps-dev:** bump aws-cdk-aws-lambda-python-alpha from 2.212.0a0 to 2.213.0a0 ([#7274](https://github.com/aws-powertools/powertools-lambda-python/issues/7274))
9594
* **deps-dev:** bump ruff from 0.12.10 to 0.12.11 ([#7275](https://github.com/aws-powertools/powertools-lambda-python/issues/7275))
95+
* **deps-dev:** bump aws-cdk-aws-lambda-python-alpha from 2.211.0a0 to 2.212.0a0 ([#7223](https://github.com/aws-powertools/powertools-lambda-python/issues/7223))
9696

9797

9898
<a name="v3.19.0"></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.19.1a11"
3+
VERSION = "3.19.1a12"

aws_lambda_powertools/utilities/parser/models/sns.py

Lines changed: 125 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,116 @@
22
from typing import Dict, List, Literal, Optional, Union
33
from typing import Type as TypingType
44

5-
from pydantic import BaseModel, model_validator
5+
from pydantic import BaseModel, Field, model_validator
66
from pydantic.networks import HttpUrl
77

88

99
class SnsMsgAttributeModel(BaseModel):
10-
Type: str
11-
Value: str
10+
Type: str = Field(
11+
description="The data type of the message attribute (String, Number, Binary, or custom data type).",
12+
examples=["String", "Number", "Binary", "String.Array", "Number.Array"],
13+
)
14+
Value: str = Field(
15+
description="The value of the message attribute. All values are strings, even for Number types.",
16+
examples=["TestString", "123", "TestBinary", '["item1", "item2"]'],
17+
)
1218

1319

1420
class SnsNotificationModel(BaseModel):
15-
Subject: Optional[str] = None
16-
TopicArn: str
17-
UnsubscribeUrl: HttpUrl
18-
Type: Literal["Notification"]
19-
MessageAttributes: Optional[Dict[str, SnsMsgAttributeModel]] = None
20-
Message: Union[str, TypingType[BaseModel]]
21-
MessageId: str
22-
SigningCertUrl: Optional[HttpUrl] = None # NOTE: FIFO opt-in removes attribute
23-
Signature: Optional[str] = None # NOTE: FIFO opt-in removes attribute
24-
Timestamp: datetime
25-
SignatureVersion: Optional[str] = None # NOTE: FIFO opt-in removes attribute
21+
Subject: Optional[str] = Field(
22+
default=None,
23+
description="The subject parameter provided when the notification was published to the topic.",
24+
examples=["TestInvoke", "Alert: System maintenance", "Order Confirmation", None],
25+
)
26+
TopicArn: str = Field(
27+
description="The Amazon Resource Name (ARN) for the topic that this message was published to.",
28+
examples=[
29+
"arn:aws:sns:us-east-2:123456789012:sns-lambda",
30+
"arn:aws:sns:eu-west-1:123456789012:notification-topic",
31+
"arn:aws:sns:us-west-2:123456789012:alerts.fifo",
32+
],
33+
)
34+
UnsubscribeUrl: HttpUrl = Field(
35+
description="A URL that you can use to unsubscribe the endpoint from this topic.",
36+
examples=[
37+
(
38+
"https://sns.us-east-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn= \
39+
arn:aws:sns:us-east-2:123456789012:test-lambda:21be56ed-a058-49f5-8c98-aedd2564c486"
40+
),
41+
(
42+
"https://sns.eu-west-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn= \
43+
arn:aws:sns:eu-west-1:123456789012:notification-topic:abcd1234-5678-90ef-ghij-klmnopqrstuv"
44+
),
45+
],
46+
)
47+
Type: Literal["Notification"] = Field(
48+
description="The type of message. For Lambda triggers, this is always 'Notification'.",
49+
examples=["Notification"],
50+
)
51+
MessageAttributes: Optional[Dict[str, SnsMsgAttributeModel]] = Field(
52+
default=None,
53+
description="User-defined message attributes as key-value pairs with type information.",
54+
examples=[
55+
{"Test": {"Type": "String", "Value": "TestString"}},
56+
{"priority": {"Type": "Number", "Value": "1"}, "env": {"Type": "String", "Value": "prod"}},
57+
None,
58+
],
59+
)
60+
Message: Union[str, TypingType[BaseModel]] = Field(
61+
description="The message value specified when the notification was published to the topic.",
62+
examples=[
63+
"Hello from SNS!",
64+
'{"alert": "CPU usage above 80%", "instance": "i-1234567890abcdef0"}',
65+
'{"order_id": 12345, "status": "confirmed", "total": 99.99}',
66+
],
67+
)
68+
MessageId: str = Field(
69+
description="A Universally Unique Identifier, unique for each message published.",
70+
examples=[
71+
"95df01b4-ee98-5cb9-9903-4c221d41eb5e",
72+
"da41e39f-ea4d-435a-b922-c6aae3915ebe",
73+
"f3c8d4e2-1a2b-4c5d-9e8f-7g6h5i4j3k2l",
74+
],
75+
)
76+
SigningCertUrl: Optional[HttpUrl] = Field(
77+
default=None,
78+
description=(
79+
"The URL to the certificate that was used to sign the message. "
80+
"Not present for FIFO topics with content-based deduplication."
81+
),
82+
examples=[
83+
"https://sns.us-east-2.amazonaws.com/SimpleNotificationService-1234567890.pem",
84+
"https://sns.eu-west-1.amazonaws.com/SimpleNotificationService-0987654321.pem",
85+
None,
86+
],
87+
) # NOTE: FIFO opt-in removes attribute
88+
Signature: Optional[str] = Field(
89+
default=None,
90+
description=(
91+
"Base64-encoded SHA1withRSA signature of the message. "
92+
"Not present for FIFO topics with content-based deduplication."
93+
),
94+
examples=[
95+
"tcc6faL2yUC6dgZdmrwh1Y4cGa/ebXEkAi6RibDsvpi+tE/1+82j...65r==",
96+
"EXAMPLEw6JRNwm1LFQL4ICB0bnXrdB8ClRMTQFPGBfHs...EXAMPLEw==",
97+
None,
98+
],
99+
) # NOTE: FIFO opt-in removes attribute
100+
Timestamp: datetime = Field(
101+
description="The time (GMT) when the notification was published.",
102+
examples=[
103+
"2019-01-02T12:45:07.000Z",
104+
"2023-06-15T10:30:00.000Z",
105+
"2023-12-25T18:45:30.123Z",
106+
],
107+
)
108+
SignatureVersion: Optional[str] = Field(
109+
default=None,
110+
description=(
111+
"Version of the Amazon SNS signature used. Not present for FIFO topics with content-based deduplication."
112+
),
113+
examples=["1", "2", None],
114+
) # NOTE: FIFO opt-in removes attribute
26115

27116
@model_validator(mode="before")
28117
def check_sqs_protocol(cls, values):
@@ -37,11 +126,28 @@ def check_sqs_protocol(cls, values):
37126

38127

39128
class SnsRecordModel(BaseModel):
40-
EventSource: Literal["aws:sns"]
41-
EventVersion: str
42-
EventSubscriptionArn: str
43-
Sns: SnsNotificationModel
129+
EventSource: Literal["aws:sns"] = Field(
130+
description="The AWS service that invoked the function.",
131+
examples=["aws:sns"],
132+
)
133+
EventVersion: str = Field(
134+
description="The version of the event schema.",
135+
examples=["1.0", "2.0"],
136+
)
137+
EventSubscriptionArn: str = Field(
138+
description="The Amazon Resource Name (ARN) of the subscription.",
139+
examples=[
140+
"arn:aws:sns:us-east-2:123456789012:sns-lambda:21be56ed-a058-49f5-8c98-aedd2564c486",
141+
"arn:aws:sns:eu-west-1:123456789012:notification-topic:abcd1234-5678-90ef-ghij-klmnopqrstuv",
142+
],
143+
)
144+
Sns: SnsNotificationModel = Field(
145+
description="The SNS message that triggered the Lambda function.",
146+
)
44147

45148

46149
class SnsModel(BaseModel):
47-
Records: List[SnsRecordModel]
150+
Records: List[SnsRecordModel] = Field(
151+
description="A list of SNS message records included in the event.",
152+
examples=[[{"EventSource": "aws:sns", "Sns": {"MessageId": "95df01b4-ee98-5cb9-9903-4c221d41eb5e"}}]],
153+
)

0 commit comments

Comments
 (0)