boto3-refresh-session 2.0.8__py3-none-any.whl → 2.0.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ from .methods.sts import STSRefreshableSession
4
4
  from .session import RefreshableSession
5
5
 
6
6
  __all__ = ["RefreshableSession"]
7
- __version__ = "2.0.8"
7
+ __version__ = "2.0.10"
8
8
  __title__ = "boto3-refresh-session"
9
9
  __author__ = "Mike Letts"
10
10
  __maintainer__ = "Mike Letts"
@@ -6,7 +6,13 @@ from typing import Any, Callable
6
6
 
7
7
  from ..exceptions import BRSError, BRSWarning
8
8
  from ..session import BaseRefreshableSession
9
- from ..utils import TemporaryCredentials, refreshable_session
9
+ from ..utils import (
10
+ CustomCredentialsMethod,
11
+ CustomCredentialsMethodArgs,
12
+ Identity,
13
+ TemporaryCredentials,
14
+ refreshable_session,
15
+ )
10
16
 
11
17
 
12
18
  @refreshable_session
@@ -18,11 +24,11 @@ class CustomRefreshableSession(BaseRefreshableSession, registry_key="custom"):
18
24
 
19
25
  Parameters
20
26
  ----------
21
- custom_credentials_method: Callable
27
+ custom_credentials_method: CustomCredentialsMethod
22
28
  Required. Accepts a callable object that returns temporary AWS
23
29
  security credentials. That object must return a dictionary containing
24
30
  'access_key', 'secret_key', 'token', and 'expiry_time' when called.
25
- custom_credentials_method_args : dict[str, Any], optional
31
+ custom_credentials_method_args : CustomCredentialsMethodArgs, optional
26
32
  Optional keyword arguments for the function passed to the
27
33
  ``custom_credentials_method`` parameter.
28
34
  defer_refresh : bool, optional
@@ -62,8 +68,10 @@ class CustomRefreshableSession(BaseRefreshableSession, registry_key="custom"):
62
68
 
63
69
  def __init__(
64
70
  self,
65
- custom_credentials_method: Callable,
66
- custom_credentials_method_args: dict[str, Any] | None = None,
71
+ custom_credentials_method: CustomCredentialsMethod,
72
+ custom_credentials_method_args: (
73
+ CustomCredentialsMethodArgs | None
74
+ ) = None,
67
75
  **kwargs,
68
76
  ):
69
77
  if "refresh_method" in kwargs:
@@ -75,8 +83,10 @@ class CustomRefreshableSession(BaseRefreshableSession, registry_key="custom"):
75
83
 
76
84
  # initializing BRSSession
77
85
  super().__init__(refresh_method="custom", **kwargs)
78
- self._custom_get_credentials = custom_credentials_method
79
- self._custom_get_credentials_args = (
86
+ self._custom_get_credentials: CustomCredentialsMethod = (
87
+ custom_credentials_method
88
+ )
89
+ self._custom_get_credentials_args: CustomCredentialsMethodArgs = (
80
90
  custom_credentials_method_args
81
91
  if custom_credentials_method_args is not None
82
92
  else {}
@@ -97,12 +107,12 @@ class CustomRefreshableSession(BaseRefreshableSession, registry_key="custom"):
97
107
 
98
108
  return credentials
99
109
 
100
- def get_identity(self) -> dict[str, str]:
110
+ def get_identity(self) -> Identity:
101
111
  """Returns metadata about the custom credential getter.
102
112
 
103
113
  Returns
104
114
  -------
105
- dict[str, str]
115
+ Identity
106
116
  Dict containing information about the custom credential getter.
107
117
  """
108
118
 
@@ -8,7 +8,7 @@ import requests
8
8
 
9
9
  from ..exceptions import BRSError, BRSWarning
10
10
  from ..session import BaseRefreshableSession
11
- from ..utils import TemporaryCredentials, refreshable_session
11
+ from ..utils import Identity, TemporaryCredentials, refreshable_session
12
12
 
13
13
  _ECS_CREDENTIALS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"
14
14
  _ECS_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI"
@@ -101,12 +101,12 @@ class ECSRefreshableSession(BaseRefreshableSession, registry_key="ecs"):
101
101
  "expiry_time": credentials.get("Expiration"), # already ISO8601
102
102
  }
103
103
 
104
- def get_identity(self) -> dict[str, str]:
104
+ def get_identity(self) -> Identity:
105
105
  """Returns metadata about ECS.
106
106
 
107
107
  Returns
108
108
  -------
109
- dict[str, str]
109
+ Identity
110
110
  Dict containing metadata about ECS.
111
111
  """
112
112
 
@@ -4,7 +4,7 @@ from pathlib import Path
4
4
  from typing import Any
5
5
 
6
6
  from ...exceptions import BRSError
7
- from ...utils import PKCS11, TemporaryCredentials, refreshable_session
7
+ from ...utils import Identity, PKCS11, TemporaryCredentials, refreshable_session
8
8
  from .core import BaseIoTRefreshableSession
9
9
 
10
10
 
@@ -52,4 +52,4 @@ class IoTCertificateRefreshableSession(
52
52
 
53
53
  def _get_credentials(self) -> TemporaryCredentials: ...
54
54
 
55
- def get_identity(self) -> dict[str, Any]: ...
55
+ def get_identity(self) -> Identity: ...
@@ -2,7 +2,7 @@ __all__ = ["IoTCognitoRefreshableSession"]
2
2
 
3
3
  from typing import Any
4
4
 
5
- from ...utils import TemporaryCredentials, refreshable_session
5
+ from ...utils import Identity, TemporaryCredentials, refreshable_session
6
6
  from .core import BaseIoTRefreshableSession
7
7
 
8
8
 
@@ -14,4 +14,4 @@ class IoTCognitoRefreshableSession(
14
14
 
15
15
  def _get_credentials(self) -> TemporaryCredentials: ...
16
16
 
17
- def get_identity(self) -> dict[str, Any]: ...
17
+ def get_identity(self) -> Identity: ...
@@ -8,6 +8,7 @@ from ..exceptions import BRSWarning
8
8
  from ..session import BaseRefreshableSession
9
9
  from ..utils import (
10
10
  AssumeRoleParams,
11
+ Identity,
11
12
  STSClientParams,
12
13
  TemporaryCredentials,
13
14
  refreshable_session,
@@ -85,12 +86,12 @@ class STSRefreshableSession(BaseRefreshableSession, registry_key="sts"):
85
86
  "expiry_time": temporary_credentials.get("Expiration").isoformat(),
86
87
  }
87
88
 
88
- def get_identity(self) -> dict[str, Any]:
89
+ def get_identity(self) -> Identity:
89
90
  """Returns metadata about the identity assumed.
90
91
 
91
92
  Returns
92
93
  -------
93
- dict[str, Any]
94
+ Identity
94
95
  Dict containing caller identity according to AWS STS.
95
96
  """
96
97
 
@@ -10,6 +10,9 @@ from typing import (
10
10
  Generic,
11
11
  List,
12
12
  Literal,
13
+ Mapping,
14
+ Protocol,
15
+ TypeAlias,
13
16
  TypedDict,
14
17
  TypeVar,
15
18
  cast,
@@ -52,6 +55,9 @@ RegistryKey = TypeVar("RegistryKey", bound=str)
52
55
  #: Type alias for a generic refreshable session type.
53
56
  BRSSessionType = TypeVar("BRSSessionType", bound="BRSSession")
54
57
 
58
+ #: Type alias for values returned by get_identity
59
+ Identity: TypeAlias = dict[str, Any]
60
+
55
61
 
56
62
  def refreshable_session(
57
63
  cls: type[BRSSessionType],
@@ -126,6 +132,17 @@ class TemporaryCredentials(TypedDict):
126
132
  expiry_time: datetime | str
127
133
 
128
134
 
135
+ class _CustomCredentialsMethod(Protocol):
136
+ def __call__(self, **kwargs: Any) -> TemporaryCredentials: ...
137
+
138
+
139
+ #: Type alias for custom credential retrieval methods.
140
+ CustomCredentialsMethod: TypeAlias = _CustomCredentialsMethod
141
+
142
+ #: Type alias for custom credential method arguments.
143
+ CustomCredentialsMethodArgs: TypeAlias = Mapping[str, Any]
144
+
145
+
129
146
  class RefreshableTemporaryCredentials(TypedDict):
130
147
  """Refreshable IAM credentials.
131
148
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: boto3-refresh-session
3
- Version: 2.0.8
3
+ Version: 2.0.10
4
4
  Summary: A simple Python package for refreshing the temporary security credentials in a boto3.session.Session object automatically.
5
5
  License: MIT
6
6
  Keywords: boto3,botocore,aws,sts,ecs,credentials,token,refresh
@@ -0,0 +1,17 @@
1
+ boto3_refresh_session/__init__.py,sha256=cv1nXmKo_tIuI-y-JFDK7Q20VCtc0pBX-edmEUGCn_8,388
2
+ boto3_refresh_session/exceptions.py,sha256=cP5d9S8QnUEwXIU3pzMGr6jMOz447kddNJ_UIRERMrk,964
3
+ boto3_refresh_session/methods/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ boto3_refresh_session/methods/custom.py,sha256=FBVkcnT0-VPDbgcjl2iMDvl16miRGXFr-fSNs2g4vkI,4211
5
+ boto3_refresh_session/methods/ecs.py,sha256=HN3dJUGeso0q6YC0S8m40jCfkf3l1lSfxKIP7kKADhM,3929
6
+ boto3_refresh_session/methods/iot/__init__.typed,sha256=Z33nIB6oCsz9TZwikHfNHgY1SKxkSCdB5rwdPSUl3C4,135
7
+ boto3_refresh_session/methods/iot/certificate.typed,sha256=dRVP_Rsob9nQmap9GeKZL3I0kM-pc2hzxnep7kBFhqY,1820
8
+ boto3_refresh_session/methods/iot/cognito.typed,sha256=wyBMWUkuhLt27JsKZIwtfylDdCavNexcEy16ZaDFjUY,435
9
+ boto3_refresh_session/methods/iot/core.typed,sha256=tL-ngB2XYq0XtxhS9mbggCJYdX3eEE0u1Gvcq8sEYGE,1422
10
+ boto3_refresh_session/methods/sts.py,sha256=Iv4FlLvn7dc45uAxJp-DkLxg3ZqnngK4XvjbItq44Uo,3403
11
+ boto3_refresh_session/session.py,sha256=_Z3uB5Xq3S-dFqOFmWhMQbcd__NPGThjULLPStHI6E4,2914
12
+ boto3_refresh_session/utils.py,sha256=fhtWLTHmERPx_3F-dDGrLxG37m2AdLRrhHq8R6ImCfc,8064
13
+ boto3_refresh_session-2.0.10.dist-info/LICENSE,sha256=I3ZYTXAjbIly6bm6J-TvFTuuHwTKws4h89QaY5c5HiY,1067
14
+ boto3_refresh_session-2.0.10.dist-info/METADATA,sha256=RXVVp0ZjG2jZE9I7bAZ-IKBJjNPthtl5rzYZTQanQko,8796
15
+ boto3_refresh_session-2.0.10.dist-info/NOTICE,sha256=1s8r33qbl1z0YvPB942iWgvbkP94P_e8AnROr1qXXuw,939
16
+ boto3_refresh_session-2.0.10.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
17
+ boto3_refresh_session-2.0.10.dist-info/RECORD,,
@@ -1,17 +0,0 @@
1
- boto3_refresh_session/__init__.py,sha256=HfXKz-omIFHEIEjjPVuwpmkqrAox_HU_IFXeTrVTazU,387
2
- boto3_refresh_session/exceptions.py,sha256=cP5d9S8QnUEwXIU3pzMGr6jMOz447kddNJ_UIRERMrk,964
3
- boto3_refresh_session/methods/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- boto3_refresh_session/methods/custom.py,sha256=-KzDFOykdbjXMwGYVJZP8Qbwz8zEbS0R8BtJE8vvfWw,3976
5
- boto3_refresh_session/methods/ecs.py,sha256=aXQXS7beS2RBXIeQkUNQkM4zhtDQv0n1Mkf9wnFbOTE,3931
6
- boto3_refresh_session/methods/iot/__init__.typed,sha256=Z33nIB6oCsz9TZwikHfNHgY1SKxkSCdB5rwdPSUl3C4,135
7
- boto3_refresh_session/methods/iot/certificate.typed,sha256=xBucJJfRb0_iKuhbtRxOWeRERzyJxo7iYW6-0VbmdA0,1816
8
- boto3_refresh_session/methods/iot/cognito.typed,sha256=OgFYOCDIkt2QC_F0KLL_BrxVxT6qMwjn-0yi4ZIwZYo,431
9
- boto3_refresh_session/methods/iot/core.typed,sha256=tL-ngB2XYq0XtxhS9mbggCJYdX3eEE0u1Gvcq8sEYGE,1422
10
- boto3_refresh_session/methods/sts.py,sha256=FvblbuXDaczEfsRIs59eKOodrJjHcMKHrnrmxjXfNeU,3401
11
- boto3_refresh_session/session.py,sha256=_Z3uB5Xq3S-dFqOFmWhMQbcd__NPGThjULLPStHI6E4,2914
12
- boto3_refresh_session/utils.py,sha256=SBzqLeCsAWpDJfGNjIvYPZ5cEKClluOzATHgLKxSWMA,7590
13
- boto3_refresh_session-2.0.8.dist-info/LICENSE,sha256=I3ZYTXAjbIly6bm6J-TvFTuuHwTKws4h89QaY5c5HiY,1067
14
- boto3_refresh_session-2.0.8.dist-info/METADATA,sha256=MQZkpUhHdFISwB07q_tKXNV6iGlRaWJ-TaX0x4MSrBw,8795
15
- boto3_refresh_session-2.0.8.dist-info/NOTICE,sha256=1s8r33qbl1z0YvPB942iWgvbkP94P_e8AnROr1qXXuw,939
16
- boto3_refresh_session-2.0.8.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
17
- boto3_refresh_session-2.0.8.dist-info/RECORD,,