You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/utilities/idempotency.md
+7-1
Original file line number
Diff line number
Diff line change
@@ -206,6 +206,11 @@ In this example, we have a Lambda handler that creates a payment for a user subs
206
206
207
207
Imagine the function executes successfully, but the client never receives the response due to a connection issue. It is safe to retry in this instance, as the idempotent decorator will return a previously saved response.
208
208
209
+
!!! warning "Making JSON APIs Idempotent"
210
+
To ensure JSON structured APIs are fully idempotent we must ensure the idempotent key is a valid JSON object.
211
+
212
+
To do this we can [customize the default behaviour](#customizing-the-default-behavior) with *event_key_jmespath* and the [JMESPath built-in function](/utilities/jmespath_functions) *powertools_json()*.
213
+
209
214
=== "payment.py"
210
215
211
216
```python hl_lines="2-4 10 12 15 20"
@@ -218,7 +223,7 @@ Imagine the function executes successfully, but the client never receives the re
Copy file name to clipboardExpand all lines: docs/utilities/validation.md
+1-123
Original file line number
Diff line number
Diff line change
@@ -429,129 +429,7 @@ For each format defined in a dictionary key, you must use a regex, or a function
429
429
430
430
You might have events or responses that contain non-encoded JSON, where you need to decode before validating them.
431
431
432
-
You can use our built-in JMESPath functions within your expressions to do exactly that to decode JSON Strings, base64, and uncompress gzip data.
432
+
You can use our built-in [JMESPath functions](/utilities/jmespath_functions) within your expressions to do exactly that to decode JSON Strings, base64, and uncompress gzip data.
433
433
434
434
!!! info
435
435
We use these for built-in envelopes to easily to decode and unwrap events from sources like Kinesis, CloudWatch Logs, etc.
436
-
437
-
#### powertools_json function
438
-
439
-
Use `powertools_json` function to decode any JSON String.
440
-
441
-
This sample will decode the value within the `data` key into a valid JSON before we can validate it.
442
-
443
-
=== "powertools_json_jmespath_function.py"
444
-
445
-
```python hl_lines="9"
446
-
from aws_lambda_powertools.utilities.validation import validate
This should only be used for advanced use cases where you have special formats not covered by the built-in functions.
527
-
528
-
This will **replace all provided built-in functions such as `powertools_json`, so you will no longer be able to use them**.
529
-
530
-
For special binary formats that you want to decode before applying JSON Schema validation, you can bring your own [JMESPath function](https://github.com/jmespath/jmespath.py#custom-functions){target="_blank"} and any additional option via `jmespath_options` param.
531
-
532
-
=== "custom_jmespath_function.py"
533
-
534
-
```python hl_lines="2 6-10 14"
535
-
from aws_lambda_powertools.utilities.validation import validator
0 commit comments