appmesh 1.5.6__py3-none-any.whl → 1.5.7__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/__init__.py CHANGED
@@ -14,5 +14,7 @@ Example:
14
14
  from .app import App
15
15
  from .http_client import AppMeshClient
16
16
  from .tcp_client import AppMeshClientTCP
17
+ from .http_server import AppMeshServer
18
+ from .tcp_server import AppMeshServerTCP
17
19
 
18
- __all__ = ["App", "AppMeshClient", "AppMeshClientTCP"]
20
+ __all__ = ["App", "AppMeshClient", "AppMeshClientTCP", "AppMeshServer", "AppMeshServerTCP"]
appmesh/http_client.py CHANGED
@@ -34,10 +34,10 @@ class AppMeshClient(metaclass=abc.ABCMeta):
34
34
  - Install the App Mesh Python package:
35
35
  python3 -m pip install --upgrade appmesh
36
36
  - Import the client module:
37
- from appmesh import appmesh_client
37
+ from appmesh import AppMeshClient
38
38
 
39
39
  Example:
40
- client = appmesh_client.AppMeshClient()
40
+ client = AppMeshClient()
41
41
  client.login("your-name", "your-password")
42
42
  response = client.app_view(app_name='ping')
43
43
 
@@ -152,7 +152,7 @@ class AppMeshClient(metaclass=abc.ABCMeta):
152
152
  which may be necessary in environments requiring specific CA chains that differ from the default system CAs.
153
153
  To use both a custom CA and the system's default CAs, create a combined CA bundle by concatenating them into a single file. (e.g., `cat custom_ca.pem /etc/ssl/certs/ca-certificates.crt > combined_ca.pem`).
154
154
 
155
- ssl_client_cert (Union[str, Tuple[str, str]], optional): Path to the SSL client certificate and key. Can be:
155
+ rest_ssl_client_cert (Union[str, Tuple[str, str]], optional): Path to the SSL client certificate and key. Can be:
156
156
  - `str`: A path to a single PEM file containing both the client certificate and private key.
157
157
  - `tuple`: A pair of paths (`cert_file`, `key_file`), where `cert_file` is the client certificate file path and `key_file` is the private key file path.
158
158
 
@@ -1228,54 +1228,6 @@ class AppMeshClient(metaclass=abc.ABCMeta):
1228
1228
 
1229
1229
  return resp.text
1230
1230
 
1231
- def task_fetch(self) -> str:
1232
- """Fetch invocation data in the currently running App Mesh application process.
1233
-
1234
- This helper is intended to be called by an application process running from App Mesh
1235
- to obtain the payload that a client pushed to it. It reads two required
1236
- environment variables set by the runtime:
1237
-
1238
- - APP_MESH_PROCESS_ID: the process UUID for this invocation
1239
- - APP_MESH_APPLICATION_NAME: the application name
1240
-
1241
- Returns:
1242
- str: The payload provided by the client as returned by the service.
1243
- """
1244
- process_uuid = os.environ["APP_MESH_PROCESS_ID"]
1245
- app_name = os.environ["APP_MESH_APPLICATION_NAME"]
1246
- while True:
1247
- resp = self._request_http(
1248
- AppMeshClient.Method.GET,
1249
- path=f"/appmesh/app/{app_name}/task",
1250
- query={"process_uuid": process_uuid},
1251
- )
1252
- if resp.status_code != HTTPStatus.OK:
1253
- time.sleep(0.1)
1254
- continue
1255
-
1256
- return resp.text
1257
-
1258
- def task_return(self, result: str) -> None:
1259
- """Return the result of a server-side invocation back to the original client.
1260
-
1261
- The method posts the `result` associated with the current process UUID so
1262
- the invoking client can retrieve it. The same environment variables used by
1263
- `task_fetch` are required to identify the target process.
1264
-
1265
- Args:
1266
- result (str): Result payload to be delivered back to the client.
1267
- """
1268
- process_uuid = os.environ["APP_MESH_PROCESS_ID"]
1269
- app_name = os.environ["APP_MESH_APPLICATION_NAME"]
1270
- resp = self._request_http(
1271
- AppMeshClient.Method.PUT,
1272
- path=f"/appmesh/app/{app_name}/task",
1273
- query={"process_uuid": process_uuid},
1274
- body=result,
1275
- )
1276
- if resp.status_code != HTTPStatus.OK:
1277
- raise Exception(resp.text)
1278
-
1279
1231
  def run_app_async(
1280
1232
  self,
1281
1233
  app: Union[App, str],
@@ -1369,7 +1321,7 @@ class AppMeshClient(metaclass=abc.ABCMeta):
1369
1321
  Args:
1370
1322
  app (Union[App, str]): An App instance or a shell command string.
1371
1323
  If a string, an App instance is created as:
1372
- `appmesh_client.App({"command": "<command_string>", "shell": True})`
1324
+ `appmesh.App({"command": "<command_string>", "shell": True})`
1373
1325
  stdout_print (bool, optional): If True, prints the remote stdout locally. Defaults to True.
1374
1326
  max_time_seconds (Union[int, str], optional): Maximum runtime for the remote process.
1375
1327
  Supports ISO 8601 duration format (e.g., 'P1Y2M3DT4H5M6S', 'P5W'). Defaults to DEFAULT_RUN_APP_TIMEOUT_SECONDS.
appmesh/http_server.py ADDED
@@ -0,0 +1,89 @@
1
+ # TCP-based App Mesh Server
2
+ # pylint: disable=line-too-long,broad-exception-raised,broad-exception-caught,import-outside-toplevel,protected-access
3
+
4
+ import abc
5
+ import os
6
+ import time
7
+ from http import HTTPStatus
8
+ from .http_client import AppMeshClient
9
+
10
+
11
+ class AppMeshServer(metaclass=abc.ABCMeta):
12
+ """
13
+ Server SDK for App Mesh application interacting with the local App Mesh REST service over HTTPS.
14
+
15
+ Build-in runtime environment variables required:
16
+ - APP_MESH_PROCESS_ID
17
+ - APP_MESH_APPLICATION_NAME
18
+
19
+ Methods:
20
+ - task_fetch(): fetch invocation payloads
21
+ - task_return(): return results to the invoking client
22
+
23
+ Example:
24
+ server = AppMeshServer()
25
+ payload = server.task_fetch()
26
+ server.task_return(result)
27
+ """
28
+
29
+ def __init__(
30
+ self,
31
+ rest_url: str = "https://127.0.0.1:6060",
32
+ rest_ssl_verify=AppMeshClient.DEFAULT_SSL_CA_CERT_PATH if os.path.exists(AppMeshClient.DEFAULT_SSL_CA_CERT_PATH) else False,
33
+ rest_ssl_client_cert=(AppMeshClient.DEFAULT_SSL_CLIENT_CERT_PATH, AppMeshClient.DEFAULT_SSL_CLIENT_KEY_PATH) if os.path.exists(AppMeshClient.DEFAULT_SSL_CLIENT_CERT_PATH) else None,
34
+ rest_timeout=(60, 300),
35
+ ):
36
+ """Initialize an App Mesh HTTP client for interacting with the App Mesh server via secure HTTPS.
37
+
38
+ Args:
39
+ follows the same parameters as `AppMeshClient`.
40
+ """
41
+ self._client = AppMeshClient(rest_url, rest_ssl_verify, rest_ssl_client_cert, rest_timeout)
42
+
43
+ def task_fetch(self) -> str:
44
+ """Fetch invocation data in the currently running App Mesh application process.
45
+
46
+ This helper is intended to be called by an application process running from App Mesh
47
+ to obtain the payload that a client pushed to it. It reads two required
48
+ environment variables set by the runtime:
49
+
50
+ - APP_MESH_PROCESS_ID: the process UUID for this invocation
51
+ - APP_MESH_APPLICATION_NAME: the application name
52
+
53
+ Returns:
54
+ str: The payload provided by the client as returned by the service.
55
+ """
56
+ process_uuid = os.environ["APP_MESH_PROCESS_ID"]
57
+ app_name = os.environ["APP_MESH_APPLICATION_NAME"]
58
+ while True:
59
+ resp = self._client._request_http(
60
+ AppMeshClient.Method.GET,
61
+ path=f"/appmesh/app/{app_name}/task",
62
+ query={"process_uuid": process_uuid},
63
+ )
64
+ if resp.status_code != HTTPStatus.OK:
65
+ time.sleep(0.1)
66
+ continue
67
+
68
+ return resp.text
69
+
70
+ def task_return(self, result: str) -> None:
71
+ """Return the result of a server-side invocation back to the original client.
72
+
73
+ The method posts the `result` associated with the current process UUID so
74
+ the invoking client can retrieve it. The same environment variables used by
75
+ `task_fetch` are required to identify the target process.
76
+
77
+ Args:
78
+ result (str): Result payload to be delivered back to the client.
79
+ """
80
+ process_uuid = os.environ["APP_MESH_PROCESS_ID"]
81
+ app_name = os.environ["APP_MESH_APPLICATION_NAME"]
82
+ resp = self._client._request_http(
83
+ AppMeshClient.Method.PUT,
84
+ path=f"/appmesh/app/{app_name}/task",
85
+ query={"process_uuid": process_uuid},
86
+ body=result,
87
+ )
88
+ if resp.status_code != HTTPStatus.OK:
89
+ raise Exception(resp.text)
appmesh/tcp_server.py ADDED
@@ -0,0 +1,33 @@
1
+ # TCP-based App Mesh Server
2
+ # pylint: disable=line-too-long,broad-exception-raised,broad-exception-caught,import-outside-toplevel,protected-access
3
+
4
+ import os
5
+ from .http_client import AppMeshClient
6
+ from .tcp_client import AppMeshClientTCP
7
+ from .http_server import AppMeshServer
8
+
9
+
10
+ class AppMeshServerTCP(AppMeshServer):
11
+ """
12
+ Server SDK for interacting with the local App Mesh service over TCP.
13
+
14
+ Attributes:
15
+ - Inherits all attributes from `AppMeshServer`.
16
+
17
+ Methods:
18
+ - Inherits all methods from `AppMeshServer`.
19
+ """
20
+
21
+ def __init__(
22
+ self,
23
+ rest_ssl_verify=AppMeshClient.DEFAULT_SSL_CA_CERT_PATH if os.path.exists(AppMeshClient.DEFAULT_SSL_CA_CERT_PATH) else False,
24
+ rest_ssl_client_cert=None,
25
+ tcp_address=("localhost", 6059),
26
+ ):
27
+ """Construct an App Mesh server TCP object to communicate securely with an App Mesh server over TLS.
28
+
29
+ Args:
30
+ follows the same parameters as `AppMeshClientTCP`.
31
+ """
32
+ object.__init__(self)
33
+ self._client = AppMeshClientTCP(rest_ssl_verify=rest_ssl_verify, rest_ssl_client_cert=rest_ssl_client_cert, tcp_address=tcp_address)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: appmesh
3
- Version: 1.5.6
3
+ Version: 1.5.7
4
4
  Summary: Client SDK for App Mesh
5
5
  Home-page: https://github.com/laoshanxi/app-mesh
6
6
  Author: laoshanxi
@@ -1,13 +1,15 @@
1
- appmesh/__init__.py,sha256=vgiSdMzlzDwgHxBMDoFaKWb77g2nJVciRf4z_ssAlwE,431
1
+ appmesh/__init__.py,sha256=fQHuLWBaMZmbs5i5AV4KIXhv9YlIWkhYIv9WSLGNLm4,548
2
2
  appmesh/app.py,sha256=9Q-SOOej-MH13BU5Dv2iTa-p-sECCJQp6ZX9DjWWmwE,10526
3
3
  appmesh/app_output.py,sha256=JK_TMKgjvaw4n_ys_vmN5S4MyWVZpmD7NlKz_UyMIM8,1015
4
4
  appmesh/app_run.py,sha256=9ISKGZ3k3kkbQvSsPfRfkOLqD9xhbqNOM7ork9F4w9c,1712
5
5
  appmesh/appmesh_client.py,sha256=0ltkqHZUq094gKneYmC0bEZCP0X9kHTp9fccKdWFWP0,339
6
- appmesh/http_client.py,sha256=9PUGuo2YCv1KYVeDhYxFegeEGSBqoSim3UK9OJHEsnU,59143
6
+ appmesh/http_client.py,sha256=G_T0VDnGf1_CNMYaHHmjfZ_XgMDyC21GBE0zgn4Bh3s,57185
7
+ appmesh/http_server.py,sha256=u4oGtZr8e1AnDvmiyN-6pX-nUpzDK24di0mSl6gJgL0,3467
7
8
  appmesh/tcp_client.py,sha256=yi0n2NpBBCA-JHYWQPPE_1euE7Oz6JHBe1op7lypTXY,10999
8
9
  appmesh/tcp_messages.py,sha256=w1Kehz_aX4X2CYAUsy9mFVJRhxnLQwwc6L58W4YkQqs,969
10
+ appmesh/tcp_server.py,sha256=c6lNM8OgYUVREs7gn2okt57PYOEfqcUuExCtL4D-xbE,1166
9
11
  appmesh/tcp_transport.py,sha256=-XDTQbsKL3yCbguHeW2jNqXpYgnCyHsH4rwcaJ46AS8,8645
10
- appmesh-1.5.6.dist-info/METADATA,sha256=k241QBT0-fxg36SOh4Y3qHLkYwTkjUgXPRJxYHZ38oY,11768
11
- appmesh-1.5.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
- appmesh-1.5.6.dist-info/top_level.txt,sha256=-y0MNQOGJxUzLdHZ6E_Rfv5_LNCkV-GTmOBME_b6pg8,8
13
- appmesh-1.5.6.dist-info/RECORD,,
12
+ appmesh-1.5.7.dist-info/METADATA,sha256=dFSkl2YjZYHYZop6QQ6X-T94zLmut_nJqJwt0vrK4CQ,11768
13
+ appmesh-1.5.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
+ appmesh-1.5.7.dist-info/top_level.txt,sha256=-y0MNQOGJxUzLdHZ6E_Rfv5_LNCkV-GTmOBME_b6pg8,8
15
+ appmesh-1.5.7.dist-info/RECORD,,