From 847ce3b4f67bd1eec6eba550f98e12ba41781052 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Thu, 29 Jul 2021 14:27:46 +0200 Subject: [PATCH 1/3] Added documentation for auto transform --- docs/utilities/parameters.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/docs/utilities/parameters.md b/docs/utilities/parameters.md index 8fc3227e2c6..057b3979e3f 100644 --- a/docs/utilities/parameters.md +++ b/docs/utilities/parameters.md @@ -437,6 +437,39 @@ For example, if you have three parameters, */param/a*, */param/b* and */param/c* values = ssm_provider.get_multiple("/param", transform="json", raise_on_transform_error=True) ``` +#### Infer transform from parameter suffix with `get_multiple()` + +If you use `transform` with `get_multiple()`, you might want to retrieve and transform parameters encoded in different formats. You can do this with a single request by using `transform="auto"` and let the infer the transform type to use based on the parameter suffix. + +!!! info "The `transform="auto"` feature is available across all providers, including the high level functions" + +=== "partial_failures.py" + +````python hl_lines="6" + from aws_lambda_powertools.utilities import parameters + + ssm_provider = parameters.SSMProvider() + + def handler(event, context): + values = ssm_provider.get_multiple("/param", transform="auto") + +For example, if you have two parameters with the following suffixes `.json` and `.binary`: + +| Parameter name | Parameter value | +| --------------- | ----------------------- | +| /param/a.json | [some encoded value] | +| /param/a.binary | [some encoded value] | + +The return of `ssm_provider.get_multiple("/param", transform="auto")` call will be a dictionary like: + +```json +{ + "a.json": [some value], + "b.binary": [some value] +} +``` +```` + ### Passing additional SDK arguments You can use arbitrary keyword arguments to pass it directly to the underlying SDK method. From 43d812dd914c4b5bcc489486d7ab5ad003511ed7 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Fri, 30 Jul 2021 12:50:21 +0200 Subject: [PATCH 2/3] Fixed formatting issues --- docs/utilities/parameters.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/utilities/parameters.md b/docs/utilities/parameters.md index 057b3979e3f..770666e39e1 100644 --- a/docs/utilities/parameters.md +++ b/docs/utilities/parameters.md @@ -443,22 +443,23 @@ If you use `transform` with `get_multiple()`, you might want to retrieve and tra !!! info "The `transform="auto"` feature is available across all providers, including the high level functions" -=== "partial_failures.py" +=== "transform_auto.py" -````python hl_lines="6" + ```python hl_lines="6" from aws_lambda_powertools.utilities import parameters ssm_provider = parameters.SSMProvider() def handler(event, context): values = ssm_provider.get_multiple("/param", transform="auto") + ``` For example, if you have two parameters with the following suffixes `.json` and `.binary`: -| Parameter name | Parameter value | -| --------------- | ----------------------- | -| /param/a.json | [some encoded value] | -| /param/a.binary | [some encoded value] | +| Parameter name | Parameter value | +| --------------- | -------------------- | +| /param/a.json | [some encoded value] | +| /param/a.binary | [some encoded value] | The return of `ssm_provider.get_multiple("/param", transform="auto")` call will be a dictionary like: @@ -468,7 +469,6 @@ The return of `ssm_provider.get_multiple("/param", transform="auto")` call will "b.binary": [some value] } ``` -```` ### Passing additional SDK arguments From 1649fc2e818941cea811d8a4c0cf4d28c7576c8a Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Tue, 10 Aug 2021 21:10:38 +0200 Subject: [PATCH 3/3] docs(parameters): trim down wording; rename section --- docs/utilities/parameters.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/utilities/parameters.md b/docs/utilities/parameters.md index 770666e39e1..871ea199e5a 100644 --- a/docs/utilities/parameters.md +++ b/docs/utilities/parameters.md @@ -437,11 +437,13 @@ For example, if you have three parameters, */param/a*, */param/b* and */param/c* values = ssm_provider.get_multiple("/param", transform="json", raise_on_transform_error=True) ``` -#### Infer transform from parameter suffix with `get_multiple()` +#### Auto-transform values on suffix -If you use `transform` with `get_multiple()`, you might want to retrieve and transform parameters encoded in different formats. You can do this with a single request by using `transform="auto"` and let the infer the transform type to use based on the parameter suffix. +If you use `transform` with `get_multiple()`, you might want to retrieve and transform parameters encoded in different formats. -!!! info "The `transform="auto"` feature is available across all providers, including the high level functions" +You can do this with a single request by using `transform="auto"`. This will instruct any Parameter to to infer its type based on the suffix and transform it accordingly. + +!!! info "`transform="auto"` feature is available across all providers, including the high level functions" === "transform_auto.py"