appmesh 0.5.6__py3-none-any.whl → 0.5.8__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.
appmesh/appmesh_client.py CHANGED
@@ -17,7 +17,7 @@ from datetime import datetime
17
17
  import requests
18
18
 
19
19
 
20
- DEFAULT_TOKEN_EXPIRE_SECONDS = "P1W" # 7 days
20
+ DEFAULT_TOKEN_EXPIRE_SECONDS = "P1W" # default 7 day(s)
21
21
  DEFAULT_RUN_APP_TIMEOUT_SECONDS = "PT1H" # 1 hour
22
22
  DEFAULT_RUN_APP_LIFECYCLE_SECONDS = "PT10H" # 10 hours
23
23
  REST_TEXT_MESSAGE_JSON_KEY = "message"
@@ -274,7 +274,6 @@ class AppMeshClient(metaclass=abc.ABCMeta):
274
274
 
275
275
  def __init__(
276
276
  self,
277
- auth_enable: bool = True,
278
277
  rest_url: str = "https://127.0.0.1:6060",
279
278
  rest_ssl_verify=_SSL_CA_PEM_FILE,
280
279
  rest_timeout=(60, 300),
@@ -283,14 +282,12 @@ class AppMeshClient(metaclass=abc.ABCMeta):
283
282
  """Construct an App Mesh client object
284
283
 
285
284
  Args:
286
- auth_enable (bool, optional): server enabled JWT authentication or not.
287
285
  rest_url (str, optional): server URI string.
288
286
  rest_ssl_verify (str, optional): SSL CA certification file path or False to disable SSL verification.
289
287
  rest_timeout (tuple, optional): HTTP timeout, Defaults to 60 seconds for connect timeout and 300 seconds for read timeout
290
288
  jwt_token (str, optional): JWT token, provide correct token is same with login() & authenticate().
291
289
  """
292
290
  self.server_url = rest_url
293
- self.jwt_auth_enable = auth_enable
294
291
  self.__jwt_token = jwt_token
295
292
  self.ssl_verify = rest_ssl_verify
296
293
  self.rest_timeout = rest_timeout
@@ -328,22 +325,21 @@ class AppMeshClient(metaclass=abc.ABCMeta):
328
325
  str: JWT token if verify success, otherwise return None.
329
326
  """
330
327
  self.jwt_token = None
331
- if self.jwt_auth_enable:
332
- resp = self._request_http(
333
- AppMeshClient.Method.POST,
334
- path="/appmesh/login",
335
- header={
336
- "Username": base64.b64encode(user_name.encode()),
337
- "Password": base64.b64encode(user_pwd.encode()),
338
- "Expire-Seconds": self._parse_duration(timeout_seconds),
339
- },
340
- )
341
- if resp.status_code == HTTPStatus.OK:
342
- if "Access-Token" in resp.json():
343
- self.jwt_token = resp.json()["Access-Token"]
344
- else:
345
- print(resp.text)
346
- # resp.raise_for_status()
328
+ resp = self._request_http(
329
+ AppMeshClient.Method.POST,
330
+ path="/appmesh/login",
331
+ header={
332
+ "Username": base64.b64encode(user_name.encode()),
333
+ "Password": base64.b64encode(user_pwd.encode()),
334
+ "Expire-Seconds": self._parse_duration(timeout_seconds),
335
+ },
336
+ )
337
+ if resp.status_code == HTTPStatus.OK:
338
+ if "Access-Token" in resp.json():
339
+ self.jwt_token = resp.json()["Access-Token"]
340
+ else:
341
+ print(resp.text)
342
+ # resp.raise_for_status()
347
343
  return self.jwt_token
348
344
 
349
345
  def authentication(self, token: str, permission=None) -> bool:
@@ -359,19 +355,17 @@ class AppMeshClient(metaclass=abc.ABCMeta):
359
355
  Returns:
360
356
  bool: authentication success or failure.
361
357
  """
362
- if self.jwt_auth_enable:
363
- self.jwt_token = token
364
- headers = {}
365
- if permission:
366
- headers["Auth-Permission"] = permission
367
- resp = self._request_http(AppMeshClient.Method.POST, path="/appmesh/auth", header=headers)
368
- if resp.status_code == HTTPStatus.OK:
369
- return True
370
- else:
371
- # resp.raise_for_status()
372
- print(resp.text)
373
- return False
374
- return True
358
+ self.jwt_token = token
359
+ headers = {}
360
+ if permission:
361
+ headers["Auth-Permission"] = permission
362
+ resp = self._request_http(AppMeshClient.Method.POST, path="/appmesh/auth", header=headers)
363
+ if resp.status_code == HTTPStatus.OK:
364
+ return True
365
+ else:
366
+ # resp.raise_for_status()
367
+ print(resp.text)
368
+ return False
375
369
 
376
370
  ########################################
377
371
  # Application view
@@ -1140,17 +1134,14 @@ class AppMeshClientTCP(AppMeshClient):
1140
1134
  def __init__(
1141
1135
  self,
1142
1136
  tcp_address=("localhost", 6059),
1143
- auth_enable: bool = True,
1144
1137
  ):
1145
1138
  """Construct an App Mesh client TCP object
1146
1139
 
1147
1140
  Args:
1148
1141
  tcp_address (tuple, optional): TCP connect address.
1149
- auth_enable (bool, optional): server enabled JWT authentication or not.
1150
1142
  """
1151
- super().__init__(auth_enable=auth_enable)
1143
+ super().__init__()
1152
1144
  self.tcp_address = tcp_address
1153
- self.jwt_auth_enable = auth_enable
1154
1145
  self.__socket_client = None
1155
1146
 
1156
1147
  def __del__(self) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: appmesh
3
- Version: 0.5.6
3
+ Version: 0.5.8
4
4
  Summary: Client SDK for App Mesh
5
5
  Home-page: https://github.com/laoshanxi/app-mesh
6
6
  Author: laoshanxi
@@ -0,0 +1,6 @@
1
+ appmesh/__init__.py,sha256=xRdXeFHEieRauuJZElbEBASgXG0ZzU1a5_0isAhM7Gw,11
2
+ appmesh/appmesh_client.py,sha256=vFObuCjScy-TOJS1qv3t7shgIo6QfFlFMgxoeJDASVA,52277
3
+ appmesh-0.5.8.dist-info/METADATA,sha256=l93m2CjKMA1TQJ6Xlhnn0rlZh1fQklIskgmNR2OtQDc,10746
4
+ appmesh-0.5.8.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
5
+ appmesh-0.5.8.dist-info/top_level.txt,sha256=-y0MNQOGJxUzLdHZ6E_Rfv5_LNCkV-GTmOBME_b6pg8,8
6
+ appmesh-0.5.8.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- appmesh/__init__.py,sha256=xRdXeFHEieRauuJZElbEBASgXG0ZzU1a5_0isAhM7Gw,11
2
- appmesh/appmesh_client.py,sha256=i9HPt3w2t0MIcBjGOXFmlPPpdOkka_IxVgJk85aF9M4,52802
3
- appmesh-0.5.6.dist-info/METADATA,sha256=CiRCsJkY73NtF2uHhOyEYIvkmtOEmu9aa2dJ5RvDxqs,10746
4
- appmesh-0.5.6.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
5
- appmesh-0.5.6.dist-info/top_level.txt,sha256=-y0MNQOGJxUzLdHZ6E_Rfv5_LNCkV-GTmOBME_b6pg8,8
6
- appmesh-0.5.6.dist-info/RECORD,,