appmesh 1.3.0__py3-none-any.whl → 1.3.2__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 +25 -27
- {appmesh-1.3.0.dist-info → appmesh-1.3.2.dist-info}/METADATA +1 -1
- appmesh-1.3.2.dist-info/RECORD +6 -0
- {appmesh-1.3.0.dist-info → appmesh-1.3.2.dist-info}/WHEEL +1 -1
- appmesh-1.3.0.dist-info/RECORD +0 -6
- {appmesh-1.3.0.dist-info → appmesh-1.3.2.dist-info}/top_level.txt +0 -0
appmesh/appmesh_client.py
CHANGED
@@ -13,7 +13,7 @@ import uuid
|
|
13
13
|
from enum import Enum, unique
|
14
14
|
from datetime import datetime
|
15
15
|
from http import HTTPStatus
|
16
|
-
from typing import Optional, Tuple
|
16
|
+
from typing import Optional, Tuple
|
17
17
|
from urllib import parse
|
18
18
|
|
19
19
|
import aniso8601
|
@@ -312,18 +312,18 @@ class AppRun(object):
|
|
312
312
|
"""process_uuid from run_async()"""
|
313
313
|
self._client = client
|
314
314
|
"""AppMeshClient object"""
|
315
|
-
self.
|
316
|
-
"""
|
315
|
+
self._forwarding_host = client.forwarding_host
|
316
|
+
"""forward host indicates the target server for this app run"""
|
317
317
|
|
318
318
|
@contextmanager
|
319
|
-
def
|
320
|
-
"""context manager for
|
321
|
-
original_value = self._client.
|
322
|
-
self._client.
|
319
|
+
def forwarding_host(self):
|
320
|
+
"""context manager for forward host override to self._client"""
|
321
|
+
original_value = self._client.forwarding_host
|
322
|
+
self._client.forwarding_host = self._forwarding_host
|
323
323
|
try:
|
324
324
|
yield
|
325
325
|
finally:
|
326
|
-
self._client.
|
326
|
+
self._client.forwarding_host = original_value
|
327
327
|
|
328
328
|
def wait(self, stdout_print: bool = True, timeout: int = 0) -> int:
|
329
329
|
"""Wait for an async run to be finished
|
@@ -335,7 +335,7 @@ class AppRun(object):
|
|
335
335
|
Returns:
|
336
336
|
int: return exit code if process finished, return None for timeout or exception.
|
337
337
|
"""
|
338
|
-
with self.
|
338
|
+
with self.forwarding_host():
|
339
339
|
return self._client.run_async_wait(self, stdout_print, timeout)
|
340
340
|
|
341
341
|
|
@@ -380,7 +380,7 @@ class AppMeshClient(metaclass=abc.ABCMeta):
|
|
380
380
|
self.ssl_verify = rest_ssl_verify
|
381
381
|
self.ssl_client_cert = rest_ssl_client_cert
|
382
382
|
self.rest_timeout = rest_timeout
|
383
|
-
self.
|
383
|
+
self._forwarding_host = None
|
384
384
|
|
385
385
|
@property
|
386
386
|
def jwt_token(self) -> str:
|
@@ -401,24 +401,22 @@ class AppMeshClient(metaclass=abc.ABCMeta):
|
|
401
401
|
self._jwt_token = token
|
402
402
|
|
403
403
|
@property
|
404
|
-
|
405
|
-
|
406
|
-
"""property for delegate_host
|
404
|
+
def forwarding_host(self) -> str:
|
405
|
+
"""property for forwarding_host
|
407
406
|
|
408
407
|
Returns:
|
409
|
-
str:
|
408
|
+
str: forward request to target host (host:port)
|
410
409
|
"""
|
411
|
-
return self.
|
410
|
+
return self._forwarding_host
|
412
411
|
|
413
|
-
@
|
414
|
-
|
415
|
-
|
416
|
-
"""setter for delegate_host
|
412
|
+
@forwarding_host.setter
|
413
|
+
def forwarding_host(self, host: str) -> None:
|
414
|
+
"""setter for forwarding_host
|
417
415
|
|
418
416
|
Args:
|
419
|
-
host (str):
|
417
|
+
host (str): forward request to target host (host:port)
|
420
418
|
"""
|
421
|
-
self.
|
419
|
+
self._forwarding_host = host
|
422
420
|
|
423
421
|
########################################
|
424
422
|
# Security
|
@@ -1337,11 +1335,11 @@ class AppMeshClient(metaclass=abc.ABCMeta):
|
|
1337
1335
|
header = {} if header is None else header
|
1338
1336
|
if self.jwt_token:
|
1339
1337
|
header["Authorization"] = "Bearer " + self.jwt_token
|
1340
|
-
if self.
|
1341
|
-
if ":" in self.
|
1342
|
-
header[HTTP_HEADER_KEY_X_TARGET_HOST] = self.
|
1338
|
+
if self.forwarding_host and len(self.forwarding_host) > 0:
|
1339
|
+
if ":" in self.forwarding_host:
|
1340
|
+
header[HTTP_HEADER_KEY_X_TARGET_HOST] = self.forwarding_host
|
1343
1341
|
else:
|
1344
|
-
header[HTTP_HEADER_KEY_X_TARGET_HOST] = self.
|
1342
|
+
header[HTTP_HEADER_KEY_X_TARGET_HOST] = self.forwarding_host + ":" + str(parse.urlsplit(self.server_url).port)
|
1345
1343
|
header[HTTP_USER_AGENT_HEADER_NAME] = HTTP_USER_AGENT
|
1346
1344
|
|
1347
1345
|
if method is AppMeshClient.Method.GET:
|
@@ -1505,8 +1503,8 @@ class AppMeshClientTCP(AppMeshClient):
|
|
1505
1503
|
appmesh_requst = RequestMsg()
|
1506
1504
|
if super().jwt_token:
|
1507
1505
|
appmesh_requst.headers["Authorization"] = "Bearer " + super().jwt_token
|
1508
|
-
if super().
|
1509
|
-
raise Exception("Not support
|
1506
|
+
if super().forwarding_host and len(super().forwarding_host) > 0:
|
1507
|
+
raise Exception("Not support forward request in TCP mode")
|
1510
1508
|
appmesh_requst.headers[HTTP_USER_AGENT_HEADER_NAME] = HTTP_USER_AGENT_TCP
|
1511
1509
|
appmesh_requst.uuid = str(uuid.uuid1())
|
1512
1510
|
appmesh_requst.http_method = method.value
|
@@ -0,0 +1,6 @@
|
|
1
|
+
appmesh/__init__.py,sha256=xRdXeFHEieRauuJZElbEBASgXG0ZzU1a5_0isAhM7Gw,11
|
2
|
+
appmesh/appmesh_client.py,sha256=Ev0MMq7nu02pFbmTCLvPdxK3P-NmOeQQXiIYAibSYjQ,62923
|
3
|
+
appmesh-1.3.2.dist-info/METADATA,sha256=pp8AVbBvK6naixdn039eaqy49JFa9dX6Qs7XS7mD7-0,11031
|
4
|
+
appmesh-1.3.2.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
5
|
+
appmesh-1.3.2.dist-info/top_level.txt,sha256=-y0MNQOGJxUzLdHZ6E_Rfv5_LNCkV-GTmOBME_b6pg8,8
|
6
|
+
appmesh-1.3.2.dist-info/RECORD,,
|
appmesh-1.3.0.dist-info/RECORD
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
appmesh/__init__.py,sha256=xRdXeFHEieRauuJZElbEBASgXG0ZzU1a5_0isAhM7Gw,11
|
2
|
-
appmesh/appmesh_client.py,sha256=1K0n44MLVPJUUSN4Lg-SK49Vjn4yveW1PymaceW7nUI,62911
|
3
|
-
appmesh-1.3.0.dist-info/METADATA,sha256=Qkniderc7hlYrnsPZ4S2wWR6JYtROtrHruko3kdXUdc,11031
|
4
|
-
appmesh-1.3.0.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
|
5
|
-
appmesh-1.3.0.dist-info/top_level.txt,sha256=-y0MNQOGJxUzLdHZ6E_Rfv5_LNCkV-GTmOBME_b6pg8,8
|
6
|
-
appmesh-1.3.0.dist-info/RECORD,,
|
File without changes
|