nextlayer-sdk-python 1.1.0__py3-none-any.whl → 1.2.0__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.
nextlayer/sdk/__init__.py CHANGED
@@ -1,2 +1,2 @@
1
1
  # do not edit this version line, it will be updated in CI-Pipeline!
2
- __version__ = "v1.1.0"
2
+ __version__ = "v1.2.0"
@@ -1,4 +1,5 @@
1
- from typing import Generator
1
+ import asyncio
2
+ from typing import AsyncGenerator, Generator
2
3
 
3
4
  import httpx
4
5
 
@@ -13,9 +14,22 @@ class NlHttpxAuth(httpx.Auth):
13
14
  else:
14
15
  # pass all arguments to NlAuth constructor and create NlAuth instance internally
15
16
  self.nlauth = NlAuth(*args, **kwargs)
17
+ self._lock = asyncio.Lock()
16
18
 
17
19
  def auth_flow(
18
20
  self, request: httpx.Request
19
21
  ) -> Generator[httpx.Request, httpx.Response, None]:
20
22
  request.headers["Authorization"] = "Bearer " + self.nlauth.get_access_token()
21
23
  yield request
24
+
25
+ async def async_auth_flow(
26
+ self, request: httpx.Request
27
+ ) -> AsyncGenerator[httpx.Request, httpx.Response]:
28
+ # NlAuth.get_access_token() does blocking file I/O and, on refresh/login,
29
+ # a blocking HTTP call to Keycloak - offload it so it doesn't stall the
30
+ # event loop. The lock avoids concurrent coroutines all triggering
31
+ # redundant refresh/login calls when the token expires under load.
32
+ async with self._lock:
33
+ access_token = await asyncio.to_thread(self.nlauth.get_access_token)
34
+ request.headers["Authorization"] = "Bearer " + access_token
35
+ yield request
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nextlayer-sdk-python
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Client utilities to interact with next layer public APIs
5
5
  Author: Wolfgang Powisch
6
6
  Author-email: wolfgang.powisch@nextlayer.at
@@ -0,0 +1,11 @@
1
+ nextlayer/sdk/__init__.py,sha256=EfLbD6-AXvk4rve6mPa9Gpf5QIau7TBrkkGJuOoWWu0,91
2
+ nextlayer/sdk/__init__.pye,sha256=fIfxryYAp41WbubhUjhitrpwoi6wXFQCZL40RdI4tHA,90
3
+ nextlayer/sdk/auth.py,sha256=i89o0NmSgR9gwntoihfQ_CqyH7iT_FS-w9vCqLMJV5k,13911
4
+ nextlayer/sdk/auth_code_browser_flow.py,sha256=luPScN2WFJtBzUc-6jEGx1zx3cjfgsl1UQweikD3y90,4648
5
+ nextlayer/sdk/auth_httpx.py,sha256=sW_wmzaWTFR6f-xQXfwHtBdNt4gsMdEcbBsKulnC9Ag,1398
6
+ nextlayer/sdk/errors.py,sha256=ZylQSsiFOulLaFwIeBHK0ZWo2Vn6AjML8PoNGIDdx8c,430
7
+ nextlayer/sdk/utils.py,sha256=JPkPuy1bU4jBOf0NunYWMqwrwKmNa2OKNTGPv_UaH6s,583
8
+ nextlayer_sdk_python-1.2.0.dist-info/METADATA,sha256=ADU3udM8afXB2nxiastSW6H8i08nJnxEGb8f6GihnvE,2906
9
+ nextlayer_sdk_python-1.2.0.dist-info/WHEEL,sha256=EGEvSphFYqXKs23-kQBeyNoJP1nrT8ZJKQoi5p5DYL8,88
10
+ nextlayer_sdk_python-1.2.0.dist-info/entry_points.txt,sha256=d2f4hShiG0Z_TDG72fCWJdOUZkXPfmPBUIieDXh94d0,58
11
+ nextlayer_sdk_python-1.2.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.2.1
2
+ Generator: poetry-core 2.4.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,11 +0,0 @@
1
- nextlayer/sdk/__init__.py,sha256=NxlAYeesZK2o7oYu_DI8iFduo5smKVKK5zaWPX5VNdg,91
2
- nextlayer/sdk/__init__.pye,sha256=fIfxryYAp41WbubhUjhitrpwoi6wXFQCZL40RdI4tHA,90
3
- nextlayer/sdk/auth.py,sha256=i89o0NmSgR9gwntoihfQ_CqyH7iT_FS-w9vCqLMJV5k,13911
4
- nextlayer/sdk/auth_code_browser_flow.py,sha256=luPScN2WFJtBzUc-6jEGx1zx3cjfgsl1UQweikD3y90,4648
5
- nextlayer/sdk/auth_httpx.py,sha256=g04GqH_lbr2UNA5rGzk_G0VvN9Um1xezqVuWz8WaAyU,692
6
- nextlayer/sdk/errors.py,sha256=ZylQSsiFOulLaFwIeBHK0ZWo2Vn6AjML8PoNGIDdx8c,430
7
- nextlayer/sdk/utils.py,sha256=JPkPuy1bU4jBOf0NunYWMqwrwKmNa2OKNTGPv_UaH6s,583
8
- nextlayer_sdk_python-1.1.0.dist-info/METADATA,sha256=JkhVMxKu3GgjgFkNk8-UcI1p7dz6xMvcw6ZCG9isKio,2906
9
- nextlayer_sdk_python-1.1.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
10
- nextlayer_sdk_python-1.1.0.dist-info/entry_points.txt,sha256=d2f4hShiG0Z_TDG72fCWJdOUZkXPfmPBUIieDXh94d0,58
11
- nextlayer_sdk_python-1.1.0.dist-info/RECORD,,