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