10
10
11
11
12
12
class S3EventRecordGlacierRestoreEventData (BaseModel ):
13
- lifecycleRestorationExpiryTime : datetime
13
+ lifecycleRestorationExpiryTime : datetime = Field (
14
+ description = "The time, in ISO-8601 format, of Restore Expiry." ,
15
+ examples = [
16
+ "1970-01-01T00:00:00.000Z" ,
17
+ ],
18
+ )
14
19
lifecycleRestoreStorageClass : str = Field (
15
20
description = "Source storage class for restore." ,
16
21
examples = [
@@ -22,12 +27,22 @@ class S3EventRecordGlacierRestoreEventData(BaseModel):
22
27
23
28
24
29
class S3EventRecordGlacierEventData (BaseModel ):
25
- restoreEventData : S3EventRecordGlacierRestoreEventData
30
+ restoreEventData : S3EventRecordGlacierRestoreEventData = Field (
31
+ description = "Event data produced only for 's3:ObjectRestore:Completed' events." ,
32
+ examples = [
33
+ {
34
+ "restoreEventData" : {
35
+ "lifecycleRestorationExpiryTime" : "1970-01-01T00:00:00.000Z" ,
36
+ "lifecycleRestoreStorageClass" : "glacier" ,
37
+ },
38
+ },
39
+ ],
40
+ )
26
41
27
42
28
43
class S3Identity (BaseModel ):
29
44
principalId : str = Field (
30
- description = "Amazon customer ID of the user who caused the event." ,
45
+ description = "Amazon identifier of the user, role, account or services who caused the event." ,
31
46
examples = [
32
47
"AIDAJDPLRKLG7UEXAMPLE" ,
33
48
"A1YQ72UWCM96UF" ,
@@ -37,7 +52,14 @@ class S3Identity(BaseModel):
37
52
38
53
39
54
class S3RequestParameters (BaseModel ):
40
- sourceIPAddress : Union [IPvAnyNetwork , Literal ["s3.amazonaws.com" ]]
55
+ sourceIPAddress : Union [IPvAnyNetwork , Literal ["s3.amazonaws.com" ]] = Field (
56
+ description = "Source IP address of the request." ,
57
+ examples = [
58
+ "0.0.0.0" ,
59
+ "255.255.255.255" ,
60
+ "s3.amazonaws.com" ,
61
+ ],
62
+ )
41
63
42
64
43
65
class S3ResponseElements (BaseModel ):
@@ -81,7 +103,10 @@ class S3Bucket(BaseModel):
81
103
"sourcebucket" ,
82
104
],
83
105
)
84
- ownerIdentity : S3OwnerIdentify
106
+ ownerIdentity : S3OwnerIdentify = Field (
107
+ description = "Amazon customer ID of the bucket owner." ,
108
+ examples = [{"principalId" : "A3NL1KOZZKExample" }, {"principalId" : "A1YQ72UWCM96UF" }],
109
+ )
85
110
arn : str = Field (
86
111
description = "The ARN of the Amazon S3 bucket." ,
87
112
examples = [
@@ -146,8 +171,29 @@ class S3Message(BaseModel):
146
171
"b1d3a482-96eb-4d3a-abd7-763662a6ba94" ,
147
172
],
148
173
)
149
- bucket : S3Bucket
150
- object : S3Object # noqa: A003
174
+ bucket : S3Bucket = Field (
175
+ description = "The S3 bucket object." ,
176
+ examples = [
177
+ {
178
+ "bucket" : {
179
+ "name" : "lambda-artifacts-deafc19498e3f2df" ,
180
+ "ownerIdentity" : {"principalId" : "A3I5XTEXAMAI3E" },
181
+ "arn" : "arn:aws:s3:::lambda-artifacts-deafc19498e3f2df" ,
182
+ },
183
+ },
184
+ ],
185
+ )
186
+ object : S3Object = Field (
187
+ description = "The S3 object object." ,
188
+ examples = [
189
+ {
190
+ "key" : "b21b84d653bb07b05b1e6b33684dc11b" ,
191
+ "size" : 1305107 ,
192
+ "eTag" : "b21b84d653bb07b05b1e6b33684dc11b" ,
193
+ "sequencer" : "0C0F6F405D6ED209E1" ,
194
+ },
195
+ ],
196
+ ) # noqa: A003
151
197
152
198
153
199
class S3EventNotificationObjectModel (BaseModel ):
@@ -209,8 +255,21 @@ class S3EventNotificationEventBridgeDetailModel(BaseModel):
209
255
"0" ,
210
256
],
211
257
)
212
- bucket : S3EventNotificationEventBridgeBucketModel
213
- object : S3EventNotificationObjectModel # noqa: A003
258
+ bucket : S3EventNotificationEventBridgeBucketModel = Field (
259
+ description = "Bucket object of the event sent from S3 to EventBridge." ,
260
+ examples = [{"name" : "example-bucket" }],
261
+ )
262
+ object : S3EventNotificationObjectModel = Field (
263
+ description = "The S3 object object." ,
264
+ examples = [
265
+ {
266
+ "key" : "b21b84d653bb07b05b1e6b33684dc11b" ,
267
+ "size" : 1305107 ,
268
+ "eTag" : "b21b84d653bb07b05b1e6b33684dc11b" ,
269
+ "sequencer" : "0C0F6F405D6ED209E1" ,
270
+ },
271
+ ],
272
+ ) # noqa: A003
214
273
request_id : str = Field (
215
274
...,
216
275
alias = "request-id" ,
@@ -289,7 +348,25 @@ class S3EventNotificationEventBridgeDetailModel(BaseModel):
289
348
290
349
291
350
class S3EventNotificationEventBridgeModel (EventBridgeModel ): # type: ignore[override]
292
- detail : S3EventNotificationEventBridgeDetailModel
351
+ detail : S3EventNotificationEventBridgeDetailModel = Field (
352
+ description = "Object representing the details of the S3 Event Notification sent to EventBridge." ,
353
+ examples = [
354
+ {
355
+ "version" : "0" ,
356
+ "bucket" : {"name" : "example-bucket" },
357
+ "object" : {
358
+ "key" : "IMG_m7fzo3.jpg" ,
359
+ "size" : 184662 ,
360
+ "etag" : "4e68adba0abe2dc8653dc3354e14c01d" ,
361
+ "sequencer" : "006408CAD69598B05E" ,
362
+ },
363
+ "request-id" : "57H08PA84AB1JZW0" ,
364
+ "requester" : "123456789012" ,
365
+ "source-ip-address" : "255.255.255.255" ,
366
+ "reason" : "PutObject" ,
367
+ },
368
+ ],
369
+ )
293
370
294
371
295
372
class S3RecordModel (BaseModel ):
@@ -300,7 +377,11 @@ class S3RecordModel(BaseModel):
300
377
"1.9" ,
301
378
],
302
379
)
303
- eventSource : Literal ["aws:s3" ]
380
+ eventSource : Literal ["aws:s3" ] = Field (
381
+ default = "aws:s3" ,
382
+ description = "Source of the event." ,
383
+ examples = ["aws:s3" ],
384
+ )
304
385
awsRegion : str = Field (
305
386
description = "The AWS region where the event occurred." ,
306
387
examples = [
@@ -324,11 +405,56 @@ class S3RecordModel(BaseModel):
324
405
"LifecycleExpiration:Delete" ,
325
406
],
326
407
)
327
- userIdentity : S3Identity
328
- requestParameters : S3RequestParameters
329
- responseElements : S3ResponseElements
330
- s3 : S3Message
331
- glacierEventData : Optional [S3EventRecordGlacierEventData ] = None
408
+ userIdentity : S3Identity = Field (
409
+ description = "Amazon identifier of the user, role, account or services who caused the event." ,
410
+ examples = [{"principalId" : "AWS:AIDAINPONIXQXHT3IKHL2" }],
411
+ )
412
+ requestParameters : S3RequestParameters = Field (
413
+ description = "Source IP address of the request." ,
414
+ examples = [{"sourceIPAddress" : "255.255.255.255" }],
415
+ )
416
+ responseElements : S3ResponseElements = Field (
417
+ description = "Response elements from an Amazon S3 response object. Useful if you want to trace a request by "
418
+ "following up with AWS Support." ,
419
+ examples = [
420
+ {
421
+ "x-amz-request-id" : "D82B88E5F771F645" ,
422
+ "x-amz-id-2" : "vlR7PnpV2Ce81l0PRw6jlUpck7Jo5ZsQjryTjKlc5aLWGVHPZLj5NeC6qMa0emYBDXOo6QBU0Wo=" ,
423
+ },
424
+ ],
425
+ )
426
+ s3 : S3Message = Field (
427
+ description = "The Amazon S3 message object." ,
428
+ examples = [
429
+ {
430
+ "s3SchemaVersion" : "1.0" ,
431
+ "configurationId" : "828aa6fc-f7b5-4305-8584-487c791949c1" ,
432
+ "bucket" : {
433
+ "name" : "lambda-artifacts-deafc19498e3f2df" ,
434
+ "ownerIdentity" : {"principalId" : "A3I5XTEXAMAI3E" },
435
+ "arn" : "arn:aws:s3:::lambda-artifacts-deafc19498e3f2df" ,
436
+ },
437
+ "object" : {
438
+ "key" : "b21b84d653bb07b05b1e6b33684dc11b" ,
439
+ "size" : 1305107 ,
440
+ "eTag" : "b21b84d653bb07b05b1e6b33684dc11b" ,
441
+ "sequencer" : "0C0F6F405D6ED209E1" ,
442
+ },
443
+ },
444
+ ],
445
+ )
446
+ glacierEventData : Optional [S3EventRecordGlacierEventData ] = Field (
447
+ default = None ,
448
+ description = "The Glacier event data object." ,
449
+ examples = [
450
+ {
451
+ "restoreEventData" : {
452
+ "lifecycleRestorationExpiryTime" : "1970-01-01T00:01:00.000Z" ,
453
+ "lifecycleRestoreStorageClass" : "standard" ,
454
+ },
455
+ },
456
+ ],
457
+ )
332
458
333
459
@model_validator (mode = "before" )
334
460
def validate_s3_object (cls , values ):
@@ -342,4 +468,36 @@ def validate_s3_object(cls, values):
342
468
343
469
344
470
class S3Model (BaseModel ):
345
- Records : List [S3RecordModel ]
471
+ Records : List [S3RecordModel ] = Field (
472
+ description = "List of S3 records included in this event." ,
473
+ examples = [
474
+ {
475
+ "eventVersion" : "2.1" ,
476
+ "eventSource" : "aws:s3" ,
477
+ "awsRegion" : "us-east-2" ,
478
+ "eventTime" : "2019-09-03T19:37:27.192Z" ,
479
+ "eventName" : "ObjectCreated:Put" ,
480
+ "userIdentity" : {"principalId" : "AWS:AIDAINPONIXQXHT3IKHL2" },
481
+ "requestParameters" : {"sourceIPAddress" : "255.255.255.255" },
482
+ "responseElements" : {
483
+ "x-amz-request-id" : "D82B88E5F771F645" ,
484
+ "x-amz-id-2" : "vlR7PnpV2Ce81l0PRw6jlUpck7Jo5ZsQjryTjKlc5aLWGVHPZLj5NeC6qMa0emYBDXOo6QBU0Wo=" ,
485
+ },
486
+ "s3" : {
487
+ "s3SchemaVersion" : "1.0" ,
488
+ "configurationId" : "828aa6fc-f7b5-4305-8584-487c791949c1" ,
489
+ "bucket" : {
490
+ "name" : "lambda-artifacts-deafc19498e3f2df" ,
491
+ "ownerIdentity" : {"principalId" : "A3I5XTEXAMAI3E" },
492
+ "arn" : "arn:aws:s3:::lambda-artifacts-deafc19498e3f2df" ,
493
+ },
494
+ "object" : {
495
+ "key" : "b21b84d653bb07b05b1e6b33684dc11b" ,
496
+ "size" : 1305107 ,
497
+ "eTag" : "b21b84d653bb07b05b1e6b33684dc11b" ,
498
+ "sequencer" : "0C0F6F405D6ED209E1" ,
499
+ },
500
+ },
501
+ },
502
+ ],
503
+ )
0 commit comments