diff --git a/aws_lambda_powertools/utilities/parameters/ssm.py b/aws_lambda_powertools/utilities/parameters/ssm.py index ebe8e57ac21..7df0e66c027 100644 --- a/aws_lambda_powertools/utilities/parameters/ssm.py +++ b/aws_lambda_powertools/utilities/parameters/ssm.py @@ -545,9 +545,57 @@ def _raise_if_errors_key_is_present(parameters: Dict, reserved_parameter: str, r ) +@overload +def get_parameter( + name: str, + transform: None = None, + decrypt: Optional[bool] = None, + force_fetch: bool = False, + max_age: Optional[int] = None, + **sdk_options, +) -> str: + ... + + +@overload +def get_parameter( + name: str, + transform: Literal["json"], + decrypt: Optional[bool] = None, + force_fetch: bool = False, + max_age: Optional[int] = None, + **sdk_options, +) -> dict: + ... + + +@overload def get_parameter( name: str, - transform: Optional[str] = None, + transform: Literal["binary"], + decrypt: Optional[bool] = None, + force_fetch: bool = False, + max_age: Optional[int] = None, + **sdk_options, +) -> Union[str, dict, bytes]: + ... + + +@overload +def get_parameter( + name: str, + transform: Literal["auto"], + decrypt: Optional[bool] = None, + force_fetch: bool = False, + max_age: Optional[int] = None, + **sdk_options, +) -> bytes: + ... + + +def get_parameter( + name: str, + transform: TransformOptions = None, decrypt: Optional[bool] = None, force_fetch: bool = False, max_age: Optional[int] = None, @@ -625,9 +673,65 @@ def get_parameter( ) +@overload def get_parameters( path: str, - transform: Optional[str] = None, + transform: None = None, + recursive: bool = True, + decrypt: Optional[bool] = None, + force_fetch: bool = False, + max_age: Optional[int] = None, + raise_on_transform_error: bool = False, + **sdk_options, +) -> Dict[str, str]: + ... + + +@overload +def get_parameters( + path: str, + transform: Literal["json"], + recursive: bool = True, + decrypt: Optional[bool] = None, + force_fetch: bool = False, + max_age: Optional[int] = None, + raise_on_transform_error: bool = False, + **sdk_options, +) -> Dict[str, dict]: + ... + + +@overload +def get_parameters( + path: str, + transform: Literal["binary"], + recursive: bool = True, + decrypt: Optional[bool] = None, + force_fetch: bool = False, + max_age: Optional[int] = None, + raise_on_transform_error: bool = False, + **sdk_options, +) -> Dict[str, bytes]: + ... + + +@overload +def get_parameters( + path: str, + transform: Literal["auto"], + recursive: bool = True, + decrypt: Optional[bool] = None, + force_fetch: bool = False, + max_age: Optional[int] = None, + raise_on_transform_error: bool = False, + **sdk_options, +) -> Union[Dict[str, bytes], Dict[str, dict], Dict[str, str]]: + ... + + +def get_parameters( + path: str, + transform: TransformOptions = None, recursive: bool = True, decrypt: Optional[bool] = None, force_fetch: bool = False, diff --git a/examples/parameters/src/getting_started_single_ssm_parameter.py b/examples/parameters/src/getting_started_single_ssm_parameter.py index d31c7a180f1..f35aa3ede84 100644 --- a/examples/parameters/src/getting_started_single_ssm_parameter.py +++ b/examples/parameters/src/getting_started_single_ssm_parameter.py @@ -7,7 +7,7 @@ def lambda_handler(event: dict, context: LambdaContext) -> dict: try: # Retrieve a single parameter - endpoint_comments: str = parameters.get_parameter("/lambda-powertools/endpoint_comments") # type: ignore[assignment] # noqa: E501 + endpoint_comments = parameters.get_parameter("/lambda-powertools/endpoint_comments") # the value of this parameter is https://jsonplaceholder.typicode.com/comments/ comments: requests.Response = requests.get(endpoint_comments)