-
Notifications
You must be signed in to change notification settings - Fork 432
feat(jmespath): new built-in envelopes to unwrap S3 events #2169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
heitorlessa
merged 6 commits into
aws-powertools:develop
from
leandrodamascena:jmespath/envelopes
May 1, 2023
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ef81b2f
feat(jmespath): adding new envelopes + docs + small fix
leandrodamascena 0de8370
feat(jmespath): text
leandrodamascena b13a6f9
Merge branch 'develop' into jmespath/envelopes
leandrodamascena 7528d07
chore: addressing Ruben's feedback
leandrodamascena a5152dc
feat(jmespath): addressing Heitor's feedback
leandrodamascena ef54196
chore: break message in two sentences.
heitorlessa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 9 additions & 3 deletions
12
examples/jmespath_functions/src/extract_data_from_builtin_envelope.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
from __future__ import annotations | ||
|
||
from aws_lambda_powertools import Logger | ||
from aws_lambda_powertools.utilities.jmespath_utils import ( | ||
envelopes, | ||
extract_data_from_envelope, | ||
) | ||
from aws_lambda_powertools.utilities.typing import LambdaContext | ||
|
||
logger = Logger() | ||
|
||
|
||
def handler(event: dict, context: LambdaContext) -> dict: | ||
payload = extract_data_from_envelope(data=event, envelope=envelopes.SQS) | ||
customer_id = payload.get("customerId") # now deserialized | ||
records: list = extract_data_from_envelope(data=event, envelope=envelopes.SQS) | ||
for record in records: # records is a list | ||
leandrodamascena marked this conversation as resolved.
Show resolved
Hide resolved
|
||
logger.info(record.get("customerId")) # now deserialized | ||
|
||
return {"customer_id": customer_id, "message": "success", "statusCode": 200} | ||
return {"message": "success", "statusCode": 200} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.