lsrestclient 3.0.2__py3-none-any.whl → 3.1.1__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.
lsrestclient/client.py CHANGED
@@ -63,12 +63,21 @@ class LsRestClient(Session):
63
63
  self,
64
64
  base_url: str = None,
65
65
  name: str = "default",
66
+ headers: dict = None,
67
+ ignore_bearer_context: bool = False,
66
68
  ) -> None:
67
69
  """Class representing a REST client for JSON API."""
68
70
 
69
71
  self._mocks = {}
70
72
  self.base_url = base_url
73
+ self.ignore_bearer_context = ignore_bearer_context
71
74
  self.base_headers = {"content-type": "application/json"}
75
+
76
+ with bearer_token_context() as bearer_token:
77
+ bearer_headers = {"Authorization": f"Bearer {bearer_token}"} if bearer_token is not None else {}
78
+ self.base_headers.update(bearer_headers)
79
+ if headers is not None:
80
+ self.base_headers.update(headers)
72
81
  self.base_kwargs = {}
73
82
  self.name = name
74
83
  super().__init__()
@@ -162,9 +171,12 @@ class LsRestClient(Session):
162
171
  Note: This method raises a `ConnectionError` if a connection error occurs during the request.
163
172
  """
164
173
  # apply base_headers
165
-
166
174
  with bearer_token_context() as bearer_token:
167
- bearer_headers = {"Authorization": f"Bearer {bearer_token}"} if bearer_token is not None else {}
175
+ bearer_headers = (
176
+ {"Authorization": f"Bearer {bearer_token}"}
177
+ if bearer_token is not None and not self.ignore_bearer_context
178
+ else {}
179
+ )
168
180
 
169
181
  headers = self.base_headers | bearer_headers | kwargs.get("headers", {})
170
182
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lsrestclient
3
- Version: 3.0.2
3
+ Version: 3.1.1
4
4
  Summary: REST Api Client
5
5
  Author: mba
6
6
  Author-email: bartel@electronic-shop.lu
@@ -1,13 +1,13 @@
1
1
  lsrestclient/__init__.py,sha256=lI62SHmG0m-iukB5UEwdN5dO4cKnDasOt-TmR1rgaWI,72
2
2
  lsrestclient/auth.py,sha256=IC6niEht-xB_wC7da0HIeM05Ha785qhls-Q39P6dMHQ,467
3
- lsrestclient/client.py,sha256=JWhf9foS-2RC0_LZz-DoXD6CE7T-o2J-DuAtDE6aaXc,11336
3
+ lsrestclient/client.py,sha256=VnF8y4q4uR6vCMJNMYuS72cTmuCWwGFjYJkgeLWtJD4,11862
4
4
  lsrestclient/contexts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  lsrestclient/contexts/bearer_token.py,sha256=GZZOzAI2Ng_9DvFCbhv1Wwb8wJ1AYCca3fQeNtt2NaU,753
6
6
  lsrestclient/exceptions.py,sha256=exJd1BfygNkkAqekmWepVXvXlMiOInVzPRnq7TmPURs,2149
7
7
  lsrestclient/fixtures.py,sha256=dFkAYQXL6xqTOwRofb03Nsu_cIjq1sG10Rh8dxWfz9s,239
8
8
  lsrestclient/mock.py,sha256=Ya12F0t5sXHTSt-X4jDDj5ILJx6y6QaBAMXutQMsIRI,1376
9
9
  lsrestclient/response.py,sha256=8ovVmVB8gLW3U1EkewdQlPdFYP-YLoOpIH3ATVQc3wc,2189
10
- lsrestclient-3.0.2.dist-info/METADATA,sha256=W3mzdeZFyyBiKuw61phWZxZpgZ05SjdyD2ouyKDzppE,6748
11
- lsrestclient-3.0.2.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
12
- lsrestclient-3.0.2.dist-info/entry_points.txt,sha256=7lN1XN3lq5Jv5PlpOdIlFrLlFlwzE5MaEWSgMhKASOM,47
13
- lsrestclient-3.0.2.dist-info/RECORD,,
10
+ lsrestclient-3.1.1.dist-info/METADATA,sha256=kHaZe0v1gee56HD9-u24rC6-qLbWeVhGH42jRgfSWsc,6748
11
+ lsrestclient-3.1.1.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
12
+ lsrestclient-3.1.1.dist-info/entry_points.txt,sha256=7lN1XN3lq5Jv5PlpOdIlFrLlFlwzE5MaEWSgMhKASOM,47
13
+ lsrestclient-3.1.1.dist-info/RECORD,,