Skip to content

Commit 2a10202

Browse files
committed
feat(parser): adds support for S3 event notifications through EventBridge
1 parent 1ae2e89 commit 2a10202

File tree

1 file changed

+12
-12
lines changed
  • aws_lambda_powertools/utilities/data_classes

1 file changed

+12
-12
lines changed

aws_lambda_powertools/utilities/data_classes/s3_event.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,27 @@ class S3EventBridgeNotificationObject(DictWrapper):
2929
@property
3030
def key(self) -> str:
3131
"""Object key"""
32-
return unquote_plus(self["object"]["key"])
32+
return unquote_plus(self["key"])
3333

3434
@property
3535
def size(self) -> str:
3636
"""Object size"""
37-
return self["object"]["size"]
37+
return self["size"]
3838

3939
@property
4040
def etag(self) -> str:
4141
"""Object etag"""
42-
return self["object"]["etag"]
42+
return self["etag"]
4343

4444
@property
4545
def version_id(self) -> str:
4646
"""Object version ID"""
47-
return self["object"]["version-id"]
47+
return self["version-id"]
4848

4949
@property
5050
def sequencer(self) -> str:
5151
"""Object key"""
52-
return self["object"]["sequencer"]
52+
return self["sequencer"]
5353

5454

5555
class S3EventBridgeNotificationDetail(DictWrapper):
@@ -61,27 +61,27 @@ def version(self) -> str:
6161
@property
6262
def bucket(self) -> S3EventNotificationEventBridgeBucket:
6363
"""Get the bucket name for the S3 notification"""
64-
return S3EventNotificationEventBridgeBucket(self["detail"]["bucket"])
64+
return S3EventNotificationEventBridgeBucket(self["bucket"])
6565

6666
@property
6767
def object(self) -> S3EventBridgeNotificationObject: # noqa: A003
6868
"""Get the request-id for the S3 notification"""
69-
return S3EventBridgeNotificationObject(self["detail"]["object"])
69+
return S3EventBridgeNotificationObject(self["object"])
7070

7171
@property
7272
def request_id(self) -> str:
7373
"""Get the request-id for the S3 notification"""
74-
return self["detail"]["request-id"]
74+
return self["request-id"]
7575

7676
@property
7777
def requester(self) -> str:
7878
"""Get the AWS account ID or AWS service principal of requester for the S3 notification"""
79-
return self["detail"]["requester"]
79+
return self["requester"]
8080

8181
@property
8282
def source_ip_address(self) -> str:
8383
"""Get the source IP address of S3 request. Only present for events triggered by an S3 request."""
84-
return self["detail"]["source-ip-address"]
84+
return self["source-ip-address"]
8585

8686
@property
8787
def reason(self) -> Optional[str]:
@@ -91,7 +91,7 @@ def reason(self) -> Optional[str]:
9191
`CompleteMultipartUpload`. For 'Object Deleted' events, this is set to `DeleteObject` when an object is deleted
9292
by an S3 API call, or 'Lifecycle Expiration' when an object is deleted by an S3 Lifecycle expiration rule.
9393
"""
94-
return self["detail"].get("reason")
94+
return self.get("reason")
9595

9696
@property
9797
def deletion_type(self) -> Optional[str]:
@@ -101,7 +101,7 @@ def deletion_type(self) -> Optional[str]:
101101
this is set to 'Permanently Deleted'. When a delete marker is created for a versioned object, this is set to
102102
'Delete Marker Created'.
103103
"""
104-
return self["detail"].get("deletion-type")
104+
return self.get("deletion-type")
105105

106106
@property
107107
def restore_expiry_time(self) -> Optional[str]:

0 commit comments

Comments
 (0)