appmesh 1.3.1__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 +24 -24
- {appmesh-1.3.1.dist-info → appmesh-1.3.2.dist-info}/METADATA +1 -1
- appmesh-1.3.2.dist-info/RECORD +6 -0
- {appmesh-1.3.1.dist-info → appmesh-1.3.2.dist-info}/WHEEL +1 -1
- appmesh-1.3.1.dist-info/RECORD +0 -6
- {appmesh-1.3.1.dist-info → appmesh-1.3.2.dist-info}/top_level.txt +0 -0
appmesh/appmesh_client.py
CHANGED
@@ -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,22 +401,22 @@ class AppMeshClient(metaclass=abc.ABCMeta):
|
|
401
401
|
self._jwt_token = token
|
402
402
|
|
403
403
|
@property
|
404
|
-
def
|
405
|
-
"""property for
|
404
|
+
def forwarding_host(self) -> str:
|
405
|
+
"""property for forwarding_host
|
406
406
|
|
407
407
|
Returns:
|
408
|
-
str:
|
408
|
+
str: forward request to target host (host:port)
|
409
409
|
"""
|
410
|
-
return self.
|
410
|
+
return self._forwarding_host
|
411
411
|
|
412
|
-
@
|
413
|
-
def
|
414
|
-
"""setter for
|
412
|
+
@forwarding_host.setter
|
413
|
+
def forwarding_host(self, host: str) -> None:
|
414
|
+
"""setter for forwarding_host
|
415
415
|
|
416
416
|
Args:
|
417
|
-
host (str):
|
417
|
+
host (str): forward request to target host (host:port)
|
418
418
|
"""
|
419
|
-
self.
|
419
|
+
self._forwarding_host = host
|
420
420
|
|
421
421
|
########################################
|
422
422
|
# Security
|
@@ -1335,11 +1335,11 @@ class AppMeshClient(metaclass=abc.ABCMeta):
|
|
1335
1335
|
header = {} if header is None else header
|
1336
1336
|
if self.jwt_token:
|
1337
1337
|
header["Authorization"] = "Bearer " + self.jwt_token
|
1338
|
-
if self.
|
1339
|
-
if ":" in self.
|
1340
|
-
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
|
1341
1341
|
else:
|
1342
|
-
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)
|
1343
1343
|
header[HTTP_USER_AGENT_HEADER_NAME] = HTTP_USER_AGENT
|
1344
1344
|
|
1345
1345
|
if method is AppMeshClient.Method.GET:
|
@@ -1503,8 +1503,8 @@ class AppMeshClientTCP(AppMeshClient):
|
|
1503
1503
|
appmesh_requst = RequestMsg()
|
1504
1504
|
if super().jwt_token:
|
1505
1505
|
appmesh_requst.headers["Authorization"] = "Bearer " + super().jwt_token
|
1506
|
-
if super().
|
1507
|
-
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")
|
1508
1508
|
appmesh_requst.headers[HTTP_USER_AGENT_HEADER_NAME] = HTTP_USER_AGENT_TCP
|
1509
1509
|
appmesh_requst.uuid = str(uuid.uuid1())
|
1510
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.1.dist-info/RECORD
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
appmesh/__init__.py,sha256=xRdXeFHEieRauuJZElbEBASgXG0ZzU1a5_0isAhM7Gw,11
|
2
|
-
appmesh/appmesh_client.py,sha256=BHgPST7m4vFbGCzHfg_kaqFZZyP9dW-h2M8mEurfyt0,62882
|
3
|
-
appmesh-1.3.1.dist-info/METADATA,sha256=qtqT4-GC1-PwliFwBHf-7Ixbt-UjgHiZ5DxO2JGkGfQ,11031
|
4
|
-
appmesh-1.3.1.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
|
5
|
-
appmesh-1.3.1.dist-info/top_level.txt,sha256=-y0MNQOGJxUzLdHZ6E_Rfv5_LNCkV-GTmOBME_b6pg8,8
|
6
|
-
appmesh-1.3.1.dist-info/RECORD,,
|
File without changes
|