Repository navigation
feat(event_sources): add support for Amazon Connect Outbound Campaigns - #8702
ASHMEET555 wants to merge 2 commits into
Conversation
|
Hi @leandrodamascena , PR is ready for review! Includes Event Source Data Classes, Pydantic v2 Parser models, documentation, and 100% test coverage matching the TypeScript reference implementation. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8702 +/- ##
===========================================
+ Coverage 96.99% 97.02% +0.02%
===========================================
Files 321 323 +2
Lines 16332 16483 +151
Branches 1473 1483 +10
===========================================
+ Hits 15841 15992 +151
Misses 350 350
Partials 141 141 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… sends Extending the model with a plain typed field fails on a real event because CustomerData is a string; document and test the Json[...] pattern instead.
|
leandrodamascena
left a comment
There was a problem hiding this comment.
Thanks @ASHMEET555, this matches the AWS docs and the TypeScript schema field by field. I pushed one commit on top: CustomerData is a JSON string on the wire, so a subclass with a plain typed field fails on a real event. The model now types it as str like TypeScript does, and the test shows the Json[YourModel] pattern on the real payload instead of a dict that the service never sends. One caveat for the record: a user in #7976 reported real payloads without InvocationMetadata back in July. The docs and TypeScript say otherwise and I could not run a real campaign to settle it, so we follow the docs; if someone hits that shape we will hear about it quickly.
I'm approving now. This goes out in 3.40.0, so it will sit here for a while before I merge it. No rebase needed in the meantime, and you'll be credited in the release notes.



Issue number: closes #7976
Summary
Adds support for Amazon Connect Outbound Campaigns custom action block triggers, achieving feature parity with TypeScript implementation (aws-powertools/powertools-lambda-typescript#5502).
Changes
Event Source Data Classes
ConnectOutboundCampaignsEventinaws_lambda_powertools/utilities/data_classes/connect_campaign_event.pywith typed sub-wrappers:ConnectOutboundCampaignInvocationMetadata&ConnectOutboundCampaignContext(CampaignId,RunId,ActionId,CampaignName).ConnectOutboundCampaignItems&ConnectOutboundCampaignCustomerProfile(ProfileId,CustomerData,IdempotencyToken).cached_property json_customer_datato automatically deserialize the embedded campaign JSON string.event.customer_profilesto iterate directly over profiles.aws_lambda_powertools/utilities/data_classes/__init__.py.Parser (Pydantic v2)
ConnectOutboundCampaignsEventModelinaws_lambda_powertools/utilities/parser/models/connect_campaign.py.ConnectInvocationMetadataModel,ConnectCampaignContextModel,ConnectItemsModel, andConnectCustomerProfileModel.CustomerDatais typedAnyby default, allowing developers to extendConnectCustomerProfileModelwith custom Pydantic schemas for campaign payloads.aws_lambda_powertools/utilities/parser/models/__init__.py.Documentation & Examples
docs/utilities/data_classes.md.examples/event_sources/src/connect_outbound_campaigns.py.ConnectOutboundCampaignsEventModelto the built-in models reference table indocs/utilities/parser.md.Tests & Fixtures
tests/events/connectOutboundCampaignsEvent.json(matches AWS documentation and TS fixture).tests/unit/data_classes/required_dependencies/test_connect_campaign_event.py.tests/unit/parser/_pydantic/test_connect_campaign.py.User experience
1. With Event Source Data Classes:
2. With Parser:
Verification
uv run pytest tests/unit/data_classes/required_dependencies/test_connect_campaign_event.py tests/unit/parser/_pydantic/test_connect_campaign.py --cov=aws_lambda_powertools.utilities.data_classes.connect_campaign_event --cov=aws_lambda_powertools.utilities.parser.models.connect_campaign— 4 passed, 100% test coverage.uv run ruff check aws_lambda_powertools/ docs/ examples/ tests/— Passed.uv run ruff format --check— Passed.uv run mypy aws_lambda_powertools/utilities/data_classes/ aws_lambda_powertools/utilities/parser/— Success: no issues found in 98 source files.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.