Skip to content

Commit c049fd5

Browse files
author
Michael Brewer
committed
feat(data-classes): Add ses response builder function
1 parent f06a096 commit c049fd5

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

aws_lambda_powertools/utilities/data_classes/ses_event.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Iterator, List, Optional
1+
from enum import Enum
2+
from typing import Dict, Iterator, List, Optional
23

34
from aws_lambda_powertools.utilities.data_classes.common import DictWrapper
45

@@ -316,3 +317,17 @@ def mail(self) -> SESMail:
316317
@property
317318
def receipt(self) -> SESReceipt:
318319
return self.record.ses.receipt
320+
321+
322+
class Disposition(Enum):
323+
"""No further actions in the current receipt rule will be processed, but further receipt rules can be processed."""
324+
325+
STOP_RULE = "STOP_RULE"
326+
"""No further actions or receipt rules will be processed."""
327+
STOP_RULE_SET = "STOP_RULE_SET"
328+
"""This means that further actions and receipt rules can be processed."""
329+
CONTINUE = "CONTINUE"
330+
331+
332+
def disposition_response(disposition: Disposition) -> Dict[str, str]:
333+
return {"disposition": disposition.value}

tests/functional/test_data_classes.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
)
7777
from aws_lambda_powertools.utilities.data_classes.event_source import event_source
7878
from aws_lambda_powertools.utilities.data_classes.s3_object_event import S3ObjectLambdaEvent
79-
from aws_lambda_powertools.utilities.data_classes.ses_event import SESReceiptAction
79+
from aws_lambda_powertools.utilities.data_classes.ses_event import Disposition, SESReceiptAction, disposition_response
8080
from tests.functional.utils import load_event
8181

8282

@@ -769,6 +769,11 @@ def test_ses_trigger_event_work_mail():
769769
assert action.organization_arn == action["organizationArn"]
770770

771771

772+
def test_ses_disposition_response():
773+
response = disposition_response(Disposition.STOP_RULE_SET)
774+
assert response == {"disposition": "STOP_RULE_SET"}
775+
776+
772777
def test_sns_trigger_event():
773778
event = SNSEvent(load_event("snsEvent.json"))
774779
records = list(event.records)

0 commit comments

Comments
 (0)