boto3-refresh-session 1.3.16__tar.gz → 1.3.17__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: boto3-refresh-session
3
- Version: 1.3.16
3
+ Version: 1.3.17
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
@@ -57,11 +57,11 @@ Description-Content-Type: text/markdown
57
57
  </a>
58
58
 
59
59
  <a href="https://pypistats.org/packages/boto3-refresh-session">
60
- <img src="https://img.shields.io/badge/downloads-67.6K-red?logo=python&color=%23FF0000&label=Downloads%20%28with%20mirrors%29" alt="Downloads with mirrors"/>
60
+ <img src="https://img.shields.io/badge/downloads-72.1K-red?logo=python&color=%23FF0000&label=Downloads%20%28with%20mirrors%29" alt="Downloads with mirrors"/>
61
61
  </a>
62
62
 
63
63
  <a href="https://pypistats.org/packages/boto3-refresh-session">
64
- <img src="https://img.shields.io/badge/downloads-17.3K-red?logo=python&color=%23FF0000&label=Downloads%20%28without%20mirrors%29" alt="Downloads without mirrors"/>
64
+ <img src="https://img.shields.io/badge/downloads-18.1K-red?logo=python&color=%23FF0000&label=Downloads%20%28without%20mirrors%29" alt="Downloads without mirrors"/>
65
65
  </a>
66
66
 
67
67
  <a href="https://michaelthomasletts.github.io/boto3-refresh-session/index.html">
@@ -33,11 +33,11 @@
33
33
  </a>
34
34
 
35
35
  <a href="https://pypistats.org/packages/boto3-refresh-session">
36
- <img src="https://img.shields.io/badge/downloads-67.6K-red?logo=python&color=%23FF0000&label=Downloads%20%28with%20mirrors%29" alt="Downloads with mirrors"/>
36
+ <img src="https://img.shields.io/badge/downloads-72.1K-red?logo=python&color=%23FF0000&label=Downloads%20%28with%20mirrors%29" alt="Downloads with mirrors"/>
37
37
  </a>
38
38
 
39
39
  <a href="https://pypistats.org/packages/boto3-refresh-session">
40
- <img src="https://img.shields.io/badge/downloads-17.3K-red?logo=python&color=%23FF0000&label=Downloads%20%28without%20mirrors%29" alt="Downloads without mirrors"/>
40
+ <img src="https://img.shields.io/badge/downloads-18.1K-red?logo=python&color=%23FF0000&label=Downloads%20%28without%20mirrors%29" alt="Downloads without mirrors"/>
41
41
  </a>
42
42
 
43
43
  <a href="https://michaelthomasletts.github.io/boto3-refresh-session/index.html">
@@ -4,7 +4,7 @@ from .session import RefreshableSession
4
4
  from .sts import STSRefreshableSession
5
5
 
6
6
  __all__ = ["RefreshableSession"]
7
- __version__ = "1.3.16"
7
+ __version__ = "1.3.17"
8
8
  __title__ = "boto3-refresh-session"
9
9
  __author__ = "Mike Letts"
10
10
  __maintainer__ = "Mike Letts"
@@ -5,7 +5,7 @@ __all__ = ["CustomRefreshableSession"]
5
5
  from typing import Any, Callable
6
6
 
7
7
  from .exceptions import BRSError
8
- from .session import BaseRefreshableSession
8
+ from .session import BaseRefreshableSession, TemporaryCredentials
9
9
 
10
10
 
11
11
  class CustomRefreshableSession(BaseRefreshableSession, method="custom"):
@@ -80,8 +80,8 @@ class CustomRefreshableSession(BaseRefreshableSession, method="custom"):
80
80
  refresh_method="custom",
81
81
  )
82
82
 
83
- def _get_credentials(self) -> dict[str, str]:
84
- credentials = self._custom_get_credentials(
83
+ def _get_credentials(self) -> TemporaryCredentials:
84
+ credentials: TemporaryCredentials = self._custom_get_credentials(
85
85
  **self._custom_get_credentials_args
86
86
  )
87
87
  required_keys = {"access_key", "secret_key", "token", "expiry_time"}
@@ -7,7 +7,7 @@ import os
7
7
  import requests
8
8
 
9
9
  from .exceptions import BRSError
10
- from .session import BaseRefreshableSession
10
+ from .session import BaseRefreshableSession, TemporaryCredentials
11
11
 
12
12
  _ECS_CREDENTIALS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"
13
13
  _ECS_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI"
@@ -71,7 +71,7 @@ class ECSRefreshableSession(BaseRefreshableSession, method="ecs"):
71
71
  session.headers.update(self._headers)
72
72
  return session
73
73
 
74
- def _get_credentials(self) -> dict[str, str]:
74
+ def _get_credentials(self) -> TemporaryCredentials:
75
75
  try:
76
76
  response = self._http.get(self._endpoint, timeout=3)
77
77
  response.raise_for_status()
@@ -3,7 +3,8 @@ from __future__ import annotations
3
3
  __all__ = ["RefreshableSession"]
4
4
 
5
5
  from abc import ABC, abstractmethod
6
- from typing import Any, Callable, ClassVar, Literal, get_args
6
+ from datetime import datetime
7
+ from typing import Any, Callable, ClassVar, Literal, TypedDict, get_args
7
8
 
8
9
  from boto3.session import Session
9
10
  from botocore.credentials import (
@@ -18,6 +19,15 @@ Method = Literal["sts", "ecs", "custom"]
18
19
  RefreshMethod = Literal["sts-assume-role", "ecs-container-metadata", "custom"]
19
20
 
20
21
 
22
+ class TemporaryCredentials(TypedDict):
23
+ """Temporary IAM credentials."""
24
+
25
+ access_key: str
26
+ secret_key: str
27
+ token: str
28
+ expiry_time: datetime | str
29
+
30
+
21
31
  class BaseRefreshableSession(ABC, Session):
22
32
  """Abstract base class for implementing refreshable AWS sessions.
23
33
 
@@ -54,7 +64,7 @@ class BaseRefreshableSession(ABC, Session):
54
64
  super().__init__(**kwargs)
55
65
 
56
66
  @abstractmethod
57
- def _get_credentials(self) -> dict[str, str]: ...
67
+ def _get_credentials(self) -> TemporaryCredentials: ...
58
68
 
59
69
  @abstractmethod
60
70
  def get_identity(self) -> dict[str, Any]: ...
@@ -5,7 +5,7 @@ __all__ = ["STSRefreshableSession"]
5
5
  from typing import Any
6
6
 
7
7
  from .exceptions import BRSWarning
8
- from .session import BaseRefreshableSession
8
+ from .session import BaseRefreshableSession, TemporaryCredentials
9
9
 
10
10
 
11
11
  class STSRefreshableSession(BaseRefreshableSession, method="sts"):
@@ -66,7 +66,7 @@ class STSRefreshableSession(BaseRefreshableSession, method="sts"):
66
66
  refresh_method="sts-assume-role",
67
67
  )
68
68
 
69
- def _get_credentials(self) -> dict[str, str]:
69
+ def _get_credentials(self) -> TemporaryCredentials:
70
70
  temporary_credentials = self._sts_client.assume_role(
71
71
  **self.assume_role_kwargs
72
72
  )["Credentials"]
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "boto3-refresh-session"
3
- version = "1.3.16"
3
+ version = "1.3.17"
4
4
  description = "A simple Python package for refreshing the temporary security credentials in a boto3.session.Session object automatically."
5
5
  authors = [
6
6
  {name = "Mike Letts",email = "lettsmt@gmail.com"}
@@ -41,7 +41,7 @@ flask = "^3.1.1"
41
41
  [tool.black]
42
42
  line-length = 79
43
43
  target-version = ["py310"]
44
- verbose = true
44
+ quiet = true
45
45
 
46
46
  [tool.isort]
47
47
  line_length = 79