Base
Base for Parameter providers
Usage Documentation
CLASS | DESCRIPTION |
---|---|
BaseProvider |
Abstract Base Class for Parameter providers |
FUNCTION | DESCRIPTION |
---|---|
clear_caches |
Clear cached parameter values from all providers |
get_transform_method |
Determine the transform method |
transform_value |
Transform a value using one of the available options. |
BaseProvider ¶
BaseProvider(*, client=None, resource=None)
Bases: ABC
Abstract Base Class for Parameter providers
METHOD | DESCRIPTION |
---|---|
get |
Retrieve a parameter value or return the cached value |
get_multiple |
Retrieve multiple parameters based on a path prefix |
set |
Set parameter value from the underlying parameter store |
Source code in aws_lambda_powertools/utilities/parameters/base.py
41 42 43 44 45 46 47 48 49 50 |
|
get ¶
get(
name: str,
max_age: int | None = None,
transform: TransformOptions = None,
force_fetch: bool = False,
**sdk_options
) -> str | bytes | dict | None
Retrieve a parameter value or return the cached value
PARAMETER | DESCRIPTION |
---|---|
name
|
Parameter name
TYPE:
|
max_age
|
Maximum age of the cached value
TYPE:
|
transform
|
Optional transformation of the parameter value. Supported values are "json" for JSON strings and "binary" for base 64 encoded values.
TYPE:
|
force_fetch
|
Force update even before a cached item has expired, defaults to False
TYPE:
|
sdk_options
|
Arguments that will be passed directly to the underlying API call
DEFAULT:
|
RAISES | DESCRIPTION |
---|---|
GetParameterError
|
When the parameter provider fails to retrieve a parameter value for a given name. |
TransformParameterError
|
When the parameter provider fails to transform a parameter value. |
Source code in aws_lambda_powertools/utilities/parameters/base.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
get_multiple ¶
get_multiple(
path: str,
max_age: int | None = None,
transform: TransformOptions = None,
raise_on_transform_error: bool = False,
force_fetch: bool = False,
**sdk_options
) -> dict[str, str] | dict[str, bytes] | dict[str, dict]
Retrieve multiple parameters based on a path prefix
PARAMETER | DESCRIPTION |
---|---|
path
|
Parameter path used to retrieve multiple parameters
TYPE:
|
max_age
|
Maximum age of the cached value
TYPE:
|
transform
|
Optional transformation of the parameter value. Supported values are "json" for JSON strings, "binary" for base 64 encoded values or "auto" which looks at the attribute key to determine the type.
TYPE:
|
raise_on_transform_error
|
Raises an exception if any transform fails, otherwise this will return a None value for each transform that failed
TYPE:
|
force_fetch
|
Force update even before a cached item has expired, defaults to False
TYPE:
|
sdk_options
|
Arguments that will be passed directly to the underlying API call
DEFAULT:
|
RAISES | DESCRIPTION |
---|---|
GetParameterError
|
When the parameter provider fails to retrieve parameter values for a given path. |
TransformParameterError
|
When the parameter provider fails to transform a parameter value. |
Source code in aws_lambda_powertools/utilities/parameters/base.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
set ¶
set(
name: str,
value: Any,
*,
overwrite: bool = False,
**kwargs
)
Set parameter value from the underlying parameter store
Source code in aws_lambda_powertools/utilities/parameters/base.py
130 131 132 133 134 |
|
clear_caches ¶
clear_caches()
Clear cached parameter values from all providers
Source code in aws_lambda_powertools/utilities/parameters/base.py
359 360 361 |
|
get_transform_method ¶
get_transform_method(
value: str, transform: TransformOptions = None
) -> Callable[..., Any]
Determine the transform method
Examples:
1 2 3 4 5 6 7 8 9 10 |
|
PARAMETER | DESCRIPTION |
---|---|
value
|
Only used when the transform is "auto".
TYPE:
|
transform
|
Original transform method, only "auto" will try to detect the transform method by the key
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Callable
|
Transform function could be json.loads, base64.b64decode, or a lambda that echo the str value |
Source code in aws_lambda_powertools/utilities/parameters/base.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
|
transform_value ¶
transform_value(
value: dict[str, Any],
transform: TransformOptions,
raise_on_transform_error: bool = False,
key: str = "",
) -> dict[str, Any]
transform_value(
value: str | bytes | dict[str, Any],
transform: TransformOptions,
raise_on_transform_error: bool = False,
key: str = "",
) -> str | bytes | dict[str, Any] | None
transform_value(
value: str | bytes | dict[str, Any],
transform: TransformOptions,
raise_on_transform_error: bool = True,
key: str = "",
) -> str | bytes | dict[str, Any] | None
Transform a value using one of the available options.
PARAMETER | DESCRIPTION |
---|---|
value
|
Parameter value to transform |
transform
|
Type of transform, supported values are "json", "binary", and "auto" based on suffix (.json, .binary)
TYPE:
|
key
|
Parameter key when transform is auto to infer its transform method
TYPE:
|
raise_on_transform_error
|
Raises an exception if any transform fails, otherwise this will return a None value for each transform that failed
TYPE:
|
RAISES | DESCRIPTION |
---|---|
TransformParameterError:
|
When the parameter value could not be transformed |
Source code in aws_lambda_powertools/utilities/parameters/base.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
|