lsrestclient 2.1.0__tar.gz → 3.0.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lsrestclient
3
- Version: 2.1.0
3
+ Version: 3.0.0
4
4
  Summary: REST Api Client
5
5
  Author: mba
6
6
  Author-email: bartel@electronic-shop.lu
@@ -2,7 +2,7 @@ from lsrestclient import LsRestClient, DownStreamError
2
2
 
3
3
 
4
4
  def auth_am_login(**kwargs) -> str:
5
- am = LsRestClient.from_env("AM_BASE_URL", "am", True)
5
+ am = LsRestClient.from_env("AM_API_URL", "am", True)
6
6
  r = am.post("/auth/login", body=kwargs)
7
7
  if r.status_code == 200:
8
8
  return r.json().get("access_token")
@@ -56,6 +56,9 @@ class LsRestClient(Session):
56
56
  except KeyError:
57
57
  raise Exception(f"LsRestClient with name '{name}' not initialized.")
58
58
 
59
+ def __repr__(self):
60
+ return f"<LsRestClient name:'{self.name}' base_url:'{self.base_url}'>"
61
+
59
62
  def __init__(
60
63
  self,
61
64
  base_url: str = None,
@@ -95,7 +98,7 @@ class LsRestClient(Session):
95
98
 
96
99
  :param url: The relative URL to be used to build the full URL.
97
100
  :param params: An optional dictionary that contains the parameters to be used in formatting the URL.
98
- Default is None. Used parameters get removed from the dictionary.
101
+ Default is None. Used parameters get removed from the dictionary.
99
102
  :return: The full URL with the parameters replaced.
100
103
  """
101
104
 
@@ -174,6 +177,16 @@ class LsRestClient(Session):
174
177
  if body is not None:
175
178
  kwargs["data"] = lsjsonclasses.LSoftJSONEncoder.dumps(body).encode("utf8")
176
179
 
180
+ return self.real_request(method, url, *args, params=params, **kwargs)
181
+
182
+ def real_request(
183
+ self,
184
+ method: str,
185
+ url: str,
186
+ *args,
187
+ params: Optional[Dict[str, Any]] = None,
188
+ **kwargs,
189
+ ):
177
190
  full_url = self.full_url(url, params)
178
191
 
179
192
  try:
@@ -199,6 +212,7 @@ class LsRestClient(Session):
199
212
  :param kwargs: Additional keyword arguments for the request.
200
213
  :return: The response object of type LsRestClientResponse.
201
214
  """
215
+
202
216
  return self.caller("GET", *args, **kwargs)
203
217
 
204
218
  def post(self, *args, **kwargs) -> LsRestClientResponse:
@@ -278,17 +292,13 @@ class LsRestClientTestClient(LsRestClient):
278
292
  super().__init__(base_url=None, name=name)
279
293
  self.test_client = test_client
280
294
 
281
- def request(
295
+ def real_request(
282
296
  self,
283
297
  method: str,
284
298
  url: str,
285
299
  *args,
286
300
  params: Optional[Dict[str, Any]] = None,
287
- body: Optional[Dict[str, Any]] = None,
288
301
  **kwargs,
289
- ) -> LsRestClientResponse:
290
- if body is not None:
291
- kwargs["data"] = lsjsonclasses.LSoftJSONEncoder.dumps(body).encode("utf8")
292
-
302
+ ):
293
303
  r = self.test_client.request(method, url, *args, params=params, **kwargs)
294
304
  return LsRestClientResponse(status_code=r.status_code, content=r.content.decode("utf8"), headers=r.headers)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "lsrestclient"
3
- version = "2.1.0"
3
+ version = "3.0.0"
4
4
  description = "REST Api Client"
5
5
  authors = ["mba <bartel@electronic-shop.lu>"]
6
6
  readme = "README.md"
File without changes