-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(jmespath_utils): deprecate extract_data_from_envelope in fav…
…or of query (#4907) * refactor!(jmespath_utils): deprecate extract_data_from_envelope in jmespath_utils and replace with query issue: #4218 * Adding deprecation decorator * Adding test * Fix highlight --------- Co-authored-by: Neel Krishna <[email protected]> Co-authored-by: Leandro Damascena <[email protected]>
- Loading branch information
1 parent
1a8818d
commit a4fdec0
Showing
16 changed files
with
80 additions
and
51 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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
6 changes: 3 additions & 3 deletions
6
...nctions/src/extract_data_from_envelope.py → examples/jmespath_functions/src/query.py
This file contains 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,12 @@ | ||
from aws_lambda_powertools.utilities.jmespath_utils import extract_data_from_envelope | ||
from aws_lambda_powertools.utilities.jmespath_utils import query | ||
from aws_lambda_powertools.utilities.typing import LambdaContext | ||
|
||
|
||
def handler(event: dict, context: LambdaContext) -> dict: | ||
payload = extract_data_from_envelope(data=event, envelope="powertools_json(body)") | ||
payload = query(data=event, envelope="powertools_json(body)") | ||
customer_id = payload.get("customerId") # now deserialized | ||
|
||
# also works for fetching and flattening deeply nested data | ||
some_data = extract_data_from_envelope(data=event, envelope="deeply_nested[*].some_data[]") | ||
some_data = query(data=event, envelope="deeply_nested[*].some_data[]") | ||
|
||
return {"customer_id": customer_id, "message": "success", "context": some_data, "statusCode": 200} |
This file contains 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import pytest | ||
|
||
from aws_lambda_powertools.utilities.jmespath_utils import extract_data_from_envelope | ||
from aws_lambda_powertools.warnings import PowertoolsDeprecationWarning | ||
|
||
|
||
def test_extract_data_from_envelope(): | ||
data = {"data": {"foo": "bar"}} | ||
envelope = "data" | ||
|
||
with pytest.warns(PowertoolsDeprecationWarning, match="The extract_data_from_envelope method is deprecated in V3*"): | ||
assert extract_data_from_envelope(data=data, envelope=envelope) == {"foo": "bar"} |