Skip to content

Commit b8ae35b

Browse files
refactor(parser): Improve EventBridge models with examples and descriptions (#7090)
Improve EventBridge models with examples and descriptions
1 parent d516b24 commit b8ae35b

File tree

1 file changed

+47
-10
lines changed

1 file changed

+47
-10
lines changed

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):

0 commit comments

Comments
 (0)