|
3 | 3 | """
|
4 | 4 |
|
5 | 5 | import os
|
6 |
| -from typing import TYPE_CHECKING, Any, Dict, Optional, Union |
| 6 | +from typing import TYPE_CHECKING, Any, Dict, Literal, Optional, Union, overload |
7 | 7 |
|
8 | 8 | import boto3
|
9 | 9 | from botocore.config import Config
|
10 | 10 |
|
| 11 | +from aws_lambda_powertools.utilities.parameters.types import TransformOptions |
| 12 | + |
11 | 13 | if TYPE_CHECKING:
|
12 | 14 | from mypy_boto3_secretsmanager import SecretsManagerClient
|
13 | 15 |
|
@@ -116,9 +118,49 @@ def _get_multiple(self, path: str, **sdk_options) -> Dict[str, str]:
|
116 | 118 | raise NotImplementedError()
|
117 | 119 |
|
118 | 120 |
|
| 121 | +@overload |
| 122 | +def get_secret( |
| 123 | + name: str, |
| 124 | + transform: None = None, |
| 125 | + force_fetch: bool = False, |
| 126 | + max_age: Optional[int] = None, |
| 127 | + **sdk_options, |
| 128 | +) -> str: ... |
| 129 | + |
| 130 | + |
| 131 | +@overload |
| 132 | +def get_secret( |
| 133 | + name: str, |
| 134 | + transform: Literal["json"], |
| 135 | + force_fetch: bool = False, |
| 136 | + max_age: Optional[int] = None, |
| 137 | + **sdk_options, |
| 138 | +) -> dict: ... |
| 139 | + |
| 140 | + |
| 141 | +@overload |
| 142 | +def get_secret( |
| 143 | + name: str, |
| 144 | + transform: Literal["binary"], |
| 145 | + force_fetch: bool = False, |
| 146 | + max_age: Optional[int] = None, |
| 147 | + **sdk_options, |
| 148 | +) -> Union[str, dict, bytes]: ... |
| 149 | + |
| 150 | + |
| 151 | +@overload |
| 152 | +def get_secret( |
| 153 | + name: str, |
| 154 | + transform: Literal["auto"], |
| 155 | + force_fetch: bool = False, |
| 156 | + max_age: Optional[int] = None, |
| 157 | + **sdk_options, |
| 158 | +) -> bytes: ... |
| 159 | + |
| 160 | + |
119 | 161 | def get_secret(
|
120 | 162 | name: str,
|
121 |
| - transform: Optional[str] = None, |
| 163 | + transform: TransformOptions = None, |
122 | 164 | force_fetch: bool = False,
|
123 | 165 | max_age: Optional[int] = None,
|
124 | 166 | **sdk_options,
|
|
0 commit comments