boto3-refresh-session 0.1.15__py3-none-any.whl → 0.1.17__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.
@@ -14,6 +14,7 @@ object.
14
14
  """
15
15
  __all__ = ["AutoRefreshableSession"]
16
16
 
17
+ import logging
17
18
  from typing import Type
18
19
 
19
20
  from attrs import define, field
@@ -25,6 +26,15 @@ from botocore.credentials import (
25
26
  )
26
27
  from botocore.session import get_session
27
28
 
29
+ # configuring logging
30
+ logging.basicConfig(
31
+ level=logging.INFO,
32
+ format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
33
+ )
34
+
35
+ # creating logger
36
+ logger = logging.getLogger(__name__)
37
+
28
38
 
29
39
  @define
30
40
  class AutoRefreshableSession:
@@ -95,10 +105,13 @@ class AutoRefreshableSession:
95
105
  default={}, validator=optional(instance_of(dict))
96
106
  )
97
107
  session: Type[Session] = field(init=False)
108
+ _creds_already_fetched: int = field(init=False, default=0)
98
109
 
99
110
  def __attrs_post_init__(self):
100
111
  __session = get_session()
101
112
 
113
+ logger.info("Fetching temporary AWS credentials.")
114
+
102
115
  if not self.defer_refresh:
103
116
  __credentials = RefreshableCredentials.create_from_metadata(
104
117
  metadata=self._get_credentials(),
@@ -124,6 +137,14 @@ class AutoRefreshableSession:
124
137
  AWS temporary credentials.
125
138
  """
126
139
 
140
+ msg = "Refreshing temporary AWS credentials"
141
+ if self.defer_refresh and self._creds_already_fetched:
142
+ logger.info(msg)
143
+ elif not self.defer_refresh and self._creds_already_fetched > 1:
144
+ logger.info(msg)
145
+ else:
146
+ self._creds_already_fetched += 1
147
+
127
148
  __sts_client = client(
128
149
  service_name="sts", region_name=self.region, **self.client_kwargs
129
150
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: boto3-refresh-session
3
- Version: 0.1.15
3
+ Version: 0.1.17
4
4
  Summary: A simple Python package for refreshing boto3 sessions automatically.
5
5
  License: MIT
6
6
  Keywords: boto3,botocore,aws
@@ -0,0 +1,6 @@
1
+ boto3_refresh_session/__init__.py,sha256=OMY8el4qROyEvo0vr1Kv8rtFU7g3xnjHuBss54XRTEA,135
2
+ boto3_refresh_session/session.py,sha256=DC12GTqyuoCE1UVpQnYQ870S3yp2x7RZNdX-wtxk5ok,5518
3
+ boto3_refresh_session-0.1.17.dist-info/LICENSE,sha256=I3ZYTXAjbIly6bm6J-TvFTuuHwTKws4h89QaY5c5HiY,1067
4
+ boto3_refresh_session-0.1.17.dist-info/METADATA,sha256=ctmV-A0UiknIiwGfA4jgjDbFNuTQN3C86vLf4Epi0CM,4463
5
+ boto3_refresh_session-0.1.17.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
6
+ boto3_refresh_session-0.1.17.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- boto3_refresh_session/__init__.py,sha256=OMY8el4qROyEvo0vr1Kv8rtFU7g3xnjHuBss54XRTEA,135
2
- boto3_refresh_session/session.py,sha256=565FIz_PW8jTptvWooMEuS7igvWxWCjejBC500erUwU,4880
3
- boto3_refresh_session-0.1.15.dist-info/LICENSE,sha256=I3ZYTXAjbIly6bm6J-TvFTuuHwTKws4h89QaY5c5HiY,1067
4
- boto3_refresh_session-0.1.15.dist-info/METADATA,sha256=w5OyT_mvP8JBIEa9g2mK52_Cr2Ioi8QG0BQyLA5JJCo,4463
5
- boto3_refresh_session-0.1.15.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
6
- boto3_refresh_session-0.1.15.dist-info/RECORD,,