11
11
12
12
13
13
class CloudWatchLogsLogEvent (BaseModel ):
14
- id : str # noqa AA03 VNE003
15
- timestamp : datetime
16
- message : Union [str , Type [BaseModel ]]
14
+ id : str = Field (
15
+ description = "Unique identifier for the log event within the batch." ,
16
+ examples = ["eventId1" , "abc123def456" ],
17
+ )
18
+ timestamp : datetime = Field (
19
+ description = "The time when the event occurred in milliseconds since Jan 1, 1970 00:00:00 UTC." ,
20
+ examples = [1673779200000 ],
21
+ )
22
+ message : Union [str , Type [BaseModel ]] = Field (
23
+ description = "The actual log message string or structured JSON payload emitted by the service or application." ,
24
+ examples = ["This is a sample log message" , '{"statusCode":200,"path":"/hello"}' ],
25
+ )
17
26
18
27
19
28
class CloudWatchLogsDecode (BaseModel ):
20
- messageType : str
21
- owner : str
22
- logGroup : str
23
- logStream : str
24
- subscriptionFilters : List [str ]
25
- logEvents : List [CloudWatchLogsLogEvent ]
26
- policyLevel : Optional [str ] = None
29
+ messageType : str = Field (
30
+ description = "The type of CloudWatch Logs message." ,
31
+ examples = ["DATA_MESSAGE" , "CONTROL_MESSAGE" ],
32
+ )
33
+ owner : str = Field (description = "The AWS account ID of the originating log data." , examples = ["123456789012" ])
34
+ logGroup : str = Field (
35
+ description = "The name of the log group that contains the log stream." ,
36
+ examples = ["/aws/lambda/my-function" , "/aws/apigateway/my-api" ],
37
+ )
38
+ logStream : str = Field (
39
+ description = "The name of the log stream that stores the log events." ,
40
+ examples = ["2023/01/15/[$LATEST]abcdef1234567890" , "i-1234567890abcdef0" ],
41
+ )
42
+ subscriptionFilters : List [str ] = Field (
43
+ description = "List of subscription filter names associated with the log group." ,
44
+ examples = [["LambdaStream_cloudwatch" , "AlertFilter" ]],
45
+ )
46
+ logEvents : List [CloudWatchLogsLogEvent ] = Field (
47
+ description = "Array of log events included in the message." ,
48
+ examples = [[{"id" : "eventId1" , "timestamp" : 1673779200000 , "message" : "Sample log line" }]],
49
+ )
50
+ policyLevel : Optional [str ] = Field (
51
+ default = None ,
52
+ description = "Optional field specifying the policy level applied to the subscription filter, if present." ,
53
+ examples = ["ACCOUNT" , "LOG_GROUP" ],
54
+ )
27
55
28
56
29
57
class CloudWatchLogsData (BaseModel ):
30
- decoded_data : CloudWatchLogsDecode = Field (..., alias = "data" )
58
+ decoded_data : CloudWatchLogsDecode = Field (
59
+ ...,
60
+ alias = "data" ,
61
+ description = "Decoded CloudWatch log data payload after base64 decoding and decompression." ,
62
+ )
31
63
32
64
@field_validator ("decoded_data" , mode = "before" )
33
65
def prepare_data (cls , value ):
@@ -42,4 +74,6 @@ def prepare_data(cls, value):
42
74
43
75
44
76
class CloudWatchLogsModel (BaseModel ):
45
- awslogs : CloudWatchLogsData
77
+ awslogs : CloudWatchLogsData = Field (
78
+ description = "Top-level CloudWatch Logs model containing the AWS logs data section." ,
79
+ )
0 commit comments