appmesh 1.6.14__py3-none-any.whl → 1.6.16__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.
@@ -1,8 +1,7 @@
1
1
  # client_http_oauth.py
2
2
  # pylint: disable=line-too-long,broad-exception-caught,too-many-lines, import-outside-toplevel, protected-access
3
- import os
4
3
  import logging
5
- from typing import Optional, Union
4
+ from typing import Optional, Union, Tuple
6
5
  from keycloak import KeycloakOpenID
7
6
  from .client_http import AppMeshClient
8
7
 
@@ -18,10 +17,10 @@ class AppMeshClientOAuth(AppMeshClient):
18
17
  self,
19
18
  oauth2: dict, # Required for Keycloak
20
19
  rest_url: str = "https://127.0.0.1:6060",
21
- rest_ssl_verify=AppMeshClient.DEFAULT_SSL_CA_CERT_PATH,
22
- rest_ssl_client_cert=AppMeshClient.DEFAULT_SSL_CLIENT_CERT_PATH,
23
- rest_timeout=(60, 300),
24
- jwt_token=None, # Keycloak dict
20
+ rest_ssl_verify: Union[bool, str] = AppMeshClient._DEFAULT_SSL_CA_CERT_PATH,
21
+ rest_ssl_client_cert: Optional[Union[str, Tuple[str, str]]] = None,
22
+ rest_timeout: Tuple[float, float] = (60, 300),
23
+ jwt_token: Optional[dict] = None, # Keycloak dict
25
24
  auto_refresh_token: bool = True, # Default to True for Keycloak
26
25
  ):
27
26
  """Initialize an App Mesh HTTP client with Keycloak support.
@@ -63,7 +62,6 @@ class AppMeshClientOAuth(AppMeshClient):
63
62
  user_name: str,
64
63
  user_pwd: str,
65
64
  totp_code: Optional[str] = "",
66
- timeout_seconds: Union[str, int] = AppMeshClient.DURATION_ONE_WEEK_ISO,
67
65
  ) -> dict:
68
66
  """Login with user name and password using Keycloak.
69
67
  Args:
appmesh/client_tcp.py CHANGED
@@ -44,15 +44,15 @@ class AppMeshClientTCP(AppMeshClient):
44
44
  """
45
45
 
46
46
  # TLS-optimized chunk size, leaves room for TLS overhead within the 16 KB limit
47
- TCP_BLOCK_SIZE = 16 * 1024 - 128
48
- ENCODING_UTF8 = "utf-8"
49
- HTTP_USER_AGENT_TCP = "appmesh/python/tcp"
50
- HTTP_HEADER_KEY_X_SEND_FILE_SOCKET = "X-Send-File-Socket"
51
- HTTP_HEADER_KEY_X_RECV_FILE_SOCKET = "X-Recv-File-Socket"
47
+ _TCP_BLOCK_SIZE = 16 * 1024 - 128
48
+ _ENCODING_UTF8 = "utf-8"
49
+ _HTTP_USER_AGENT_TCP = "appmesh/python/tcp"
50
+ _HTTP_HEADER_KEY_X_SEND_FILE_SOCKET = "X-Send-File-Socket"
51
+ _HTTP_HEADER_KEY_X_RECV_FILE_SOCKET = "X-Recv-File-Socket"
52
52
 
53
53
  def __init__(
54
54
  self,
55
- rest_ssl_verify: Union[bool, str] = AppMeshClient.DEFAULT_SSL_CA_CERT_PATH,
55
+ rest_ssl_verify: Union[bool, str] = AppMeshClient._DEFAULT_SSL_CA_CERT_PATH,
56
56
  rest_ssl_client_cert: Optional[Union[str, Tuple[str, str]]] = None,
57
57
  jwt_token: Optional[str] = None,
58
58
  tcp_address: Tuple[str, int] = ("127.0.0.1", 6059),
@@ -100,14 +100,14 @@ class AppMeshClientTCP(AppMeshClient):
100
100
  return body
101
101
 
102
102
  if isinstance(body, str):
103
- return body.encode(self.ENCODING_UTF8)
103
+ return body.encode(self._ENCODING_UTF8)
104
104
 
105
105
  if isinstance(body, (dict, list)):
106
- return json.dumps(body).encode(self.ENCODING_UTF8)
106
+ return json.dumps(body).encode(self._ENCODING_UTF8)
107
107
 
108
108
  raise TypeError(f"Unsupported body type: {type(body)}")
109
109
 
110
- def _request_http(self, method: AppMeshClient.Method, path: str, query: Optional[dict] = None, header: Optional[dict] = None, body=None) -> requests.Response:
110
+ def _request_http(self, method: AppMeshClient._Method, path: str, query: Optional[dict] = None, header: Optional[dict] = None, body=None) -> requests.Response:
111
111
  """Send HTTP request over TCP transport.
112
112
 
113
113
  Args:
@@ -134,12 +134,12 @@ class AppMeshClientTCP(AppMeshClient):
134
134
  appmesh_request.http_method = method.value
135
135
  appmesh_request.request_uri = path
136
136
  appmesh_request.client_addr = socket.gethostname()
137
- appmesh_request.headers[self.HTTP_HEADER_KEY_USER_AGENT] = self.HTTP_USER_AGENT_TCP
137
+ appmesh_request.headers[self._HTTP_HEADER_KEY_USER_AGENT] = self._HTTP_USER_AGENT_TCP
138
138
 
139
139
  # Add authentication token
140
140
  token = self._get_access_token()
141
141
  if token:
142
- appmesh_request.headers[self.HTTP_HEADER_KEY_AUTH] = token
142
+ appmesh_request.headers[self._HTTP_HEADER_KEY_AUTH] = token
143
143
 
144
144
  # Add custom headers
145
145
  if header:
@@ -171,17 +171,17 @@ class AppMeshClientTCP(AppMeshClient):
171
171
  response.headers = appmesh_resp.headers
172
172
 
173
173
  # Set response content
174
- # response.encoding = self.ENCODING_UTF8 # only need when charset not in appmesh_resp.body_msg_type
174
+ # response.encoding = self._ENCODING_UTF8 # only need when charset not in appmesh_resp.body_msg_type
175
175
  if isinstance(appmesh_resp.body, bytes):
176
176
  response._content = appmesh_resp.body
177
177
  else:
178
- response._content = str(appmesh_resp.body).encode(self.ENCODING_UTF8)
178
+ response._content = str(appmesh_resp.body).encode(self._ENCODING_UTF8)
179
179
 
180
180
  # Set content type
181
181
  if appmesh_resp.body_msg_type:
182
182
  response.headers["Content-Type"] = appmesh_resp.body_msg_type
183
183
 
184
- return AppMeshClient.EncodingResponse(response)
184
+ return AppMeshClient._EncodingResponse(response)
185
185
 
186
186
  def _apply_file_attributes(self, local_file: str, headers: dict) -> None:
187
187
  """Apply file attributes from headers to local file."""
@@ -232,15 +232,15 @@ class AppMeshClientTCP(AppMeshClient):
232
232
  preserve_permissions: Apply remote file permissions/ownership locally.
233
233
  """
234
234
  header = {
235
- AppMeshClient.HTTP_HEADER_KEY_X_FILE_PATH: remote_file,
236
- self.HTTP_HEADER_KEY_X_RECV_FILE_SOCKET: "true",
235
+ AppMeshClient._HTTP_HEADER_KEY_X_FILE_PATH: remote_file,
236
+ self._HTTP_HEADER_KEY_X_RECV_FILE_SOCKET: "true",
237
237
  }
238
238
 
239
- resp = self._request_http(AppMeshClient.Method.GET, path="/appmesh/file/download", header=header)
239
+ resp = self._request_http(AppMeshClient._Method.GET, path="/appmesh/file/download", header=header)
240
240
  resp.raise_for_status()
241
241
 
242
- if self.HTTP_HEADER_KEY_X_RECV_FILE_SOCKET not in resp.headers:
243
- raise ValueError(f"Server did not respond with socket transfer option: " f"{self.HTTP_HEADER_KEY_X_RECV_FILE_SOCKET}")
242
+ if self._HTTP_HEADER_KEY_X_RECV_FILE_SOCKET not in resp.headers:
243
+ raise ValueError(f"Server did not respond with socket transfer option: " f"{self._HTTP_HEADER_KEY_X_RECV_FILE_SOCKET}")
244
244
 
245
245
  # Download file chunks
246
246
  with open(local_file, "wb") as fp:
@@ -267,9 +267,9 @@ class AppMeshClientTCP(AppMeshClient):
267
267
 
268
268
  # Prepare headers
269
269
  header = {
270
- AppMeshClient.HTTP_HEADER_KEY_X_FILE_PATH: remote_file,
270
+ AppMeshClient._HTTP_HEADER_KEY_X_FILE_PATH: remote_file,
271
271
  "Content-Type": "text/plain",
272
- self.HTTP_HEADER_KEY_X_SEND_FILE_SOCKET: "true",
272
+ self._HTTP_HEADER_KEY_X_SEND_FILE_SOCKET: "true",
273
273
  }
274
274
 
275
275
  # Add file attributes if requested
@@ -277,16 +277,16 @@ class AppMeshClientTCP(AppMeshClient):
277
277
  header.update(self._get_file_attributes(local_file))
278
278
 
279
279
  # Initiate upload
280
- resp = self._request_http(AppMeshClient.Method.POST, path="/appmesh/file/upload", header=header)
280
+ resp = self._request_http(AppMeshClient._Method.POST, path="/appmesh/file/upload", header=header)
281
281
  resp.raise_for_status()
282
282
 
283
- if self.HTTP_HEADER_KEY_X_SEND_FILE_SOCKET not in resp.headers:
284
- raise ValueError(f"Server did not respond with socket transfer option: " f"{self.HTTP_HEADER_KEY_X_SEND_FILE_SOCKET}")
283
+ if self._HTTP_HEADER_KEY_X_SEND_FILE_SOCKET not in resp.headers:
284
+ raise ValueError(f"Server did not respond with socket transfer option: " f"{self._HTTP_HEADER_KEY_X_SEND_FILE_SOCKET}")
285
285
 
286
286
  # Upload file chunks
287
287
  with open(local_file, "rb") as fp:
288
288
  while True:
289
- chunk_data = fp.read(self.TCP_BLOCK_SIZE)
289
+ chunk_data = fp.read(self._TCP_BLOCK_SIZE)
290
290
  if not chunk_data:
291
291
  self.tcp_transport.send_message([]) # EOF signal
292
292
  break
appmesh/server_http.py CHANGED
@@ -40,7 +40,7 @@ class AppMeshServer(metaclass=abc.ABCMeta):
40
40
  def __init__(
41
41
  self,
42
42
  rest_url: str = "https://127.0.0.1:6060",
43
- rest_ssl_verify: Union[bool, str] = AppMeshClient.DEFAULT_SSL_CA_CERT_PATH,
43
+ rest_ssl_verify: Union[bool, str] = AppMeshClient._DEFAULT_SSL_CA_CERT_PATH,
44
44
  rest_ssl_client_cert: Optional[Union[str, Tuple[str, str]]] = None,
45
45
  rest_timeout: Tuple[float, float] = (60, 300),
46
46
  *,
@@ -81,7 +81,7 @@ class AppMeshServer(metaclass=abc.ABCMeta):
81
81
 
82
82
  while True:
83
83
  resp = self._client._request_http(
84
- AppMeshClient.Method.GET,
84
+ AppMeshClient._Method.GET,
85
85
  path=path,
86
86
  query=query_params,
87
87
  )
@@ -106,7 +106,7 @@ class AppMeshServer(metaclass=abc.ABCMeta):
106
106
  query_params = {"process_key": pkey}
107
107
 
108
108
  resp = self._client._request_http(
109
- AppMeshClient.Method.PUT,
109
+ AppMeshClient._Method.PUT,
110
110
  path=path,
111
111
  query=query_params,
112
112
  body=result,
appmesh/server_tcp.py CHANGED
@@ -18,7 +18,7 @@ class AppMeshServerTCP(AppMeshServer):
18
18
 
19
19
  def __init__(
20
20
  self,
21
- rest_ssl_verify: Union[bool, str] = AppMeshClient.DEFAULT_SSL_CA_CERT_PATH,
21
+ rest_ssl_verify: Union[bool, str] = AppMeshClient._DEFAULT_SSL_CA_CERT_PATH,
22
22
  rest_ssl_client_cert: Optional[Union[str, Tuple[str, str]]] = None,
23
23
  tcp_address: Tuple[str, int] = ("127.0.0.1", 6059),
24
24
  *,
appmesh/tcp_messages.py CHANGED
@@ -1,4 +1,5 @@
1
1
  """TCP message classes for HTTP-like communication."""
2
+ __all__ = []
2
3
 
3
4
  # Standard library imports
4
5
  from dataclasses import dataclass, field
appmesh/tcp_transport.py CHANGED
@@ -1,5 +1,6 @@
1
1
  # tcp_transport.py
2
2
  """TCP Transport layer handling socket connections."""
3
+ __all__ = []
3
4
 
4
5
  import socket
5
6
  import ssl
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: appmesh
3
- Version: 1.6.14
3
+ Version: 1.6.16
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,16 @@
1
+ appmesh/__init__.py,sha256=on6GmTTwo6mrRbw_XUuf8sZdl5zBYsGT4CSf8l__NnI,2488
2
+ appmesh/app.py,sha256=bJyv_uOSMj5esMgkFWuvpMPS5ayFTBJLVll2Tvw8xB4,11213
3
+ appmesh/app_output.py,sha256=s6eqevFxETTVXSPTJX6JyGNpHHILv4ZyM7YWvlkuqQs,741
4
+ appmesh/app_run.py,sha256=m3ihaacx84o1rl2Oc3EbnppW8D-PTxdehftbWRe8rPk,1732
5
+ appmesh/appmesh_client.py,sha256=ywB2222PtJUffdfdxZcBfdhZs1KYyc7JvzMxwuK2qyI,378
6
+ appmesh/client_http.py,sha256=Cq2BBH6eygs-aySoqyiv2saV9mu0gvzd5XF4SB_MhcU,48973
7
+ appmesh/client_http_oauth.py,sha256=qD0uRToAzcqIl0Dqu-JFBusguHUtpnetjme0sKikLeI,5916
8
+ appmesh/client_tcp.py,sha256=4grKe_BGy-_QNGJ_41LCnLOE0cYm3fE-FSsPLW7JRpY,11843
9
+ appmesh/server_http.py,sha256=uP_ozwv6zYm_3SO9pMATk3wcW6m0UsQ_KVOXEM4cRS8,4196
10
+ appmesh/server_tcp.py,sha256=8pu6njVkMjJTG5F4sWjm0W3lygY782avH32-B1uzvJU,1365
11
+ appmesh/tcp_messages.py,sha256=Igo8MPwzQtKhvfAsYgS_opCBxowvG-cHIRRoCHtvvTY,2004
12
+ appmesh/tcp_transport.py,sha256=SLIWxaz0fg462GThxDjgXb0zjo-BZt3eLmSOIv6VFng,8176
13
+ appmesh-1.6.16.dist-info/METADATA,sha256=_GXtei9_IVGv4kNT0m9Vj4c2jHHfeDuiVZa4Aap1TIw,11814
14
+ appmesh-1.6.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
+ appmesh-1.6.16.dist-info/top_level.txt,sha256=-y0MNQOGJxUzLdHZ6E_Rfv5_LNCkV-GTmOBME_b6pg8,8
16
+ appmesh-1.6.16.dist-info/RECORD,,
@@ -1,16 +0,0 @@
1
- appmesh/__init__.py,sha256=on6GmTTwo6mrRbw_XUuf8sZdl5zBYsGT4CSf8l__NnI,2488
2
- appmesh/app.py,sha256=bJyv_uOSMj5esMgkFWuvpMPS5ayFTBJLVll2Tvw8xB4,11213
3
- appmesh/app_output.py,sha256=s6eqevFxETTVXSPTJX6JyGNpHHILv4ZyM7YWvlkuqQs,741
4
- appmesh/app_run.py,sha256=m3ihaacx84o1rl2Oc3EbnppW8D-PTxdehftbWRe8rPk,1732
5
- appmesh/appmesh_client.py,sha256=ywB2222PtJUffdfdxZcBfdhZs1KYyc7JvzMxwuK2qyI,378
6
- appmesh/client_http.py,sha256=BsFgafrk4iUJlmrz21hlovyN5XAPYTGKjLNMt6aH8nM,58986
7
- appmesh/client_http_oauth.py,sha256=zES-f6AnG6dUo754zd-HM6Pvu4vp_64vTKT61npY6HE,5934
8
- appmesh/client_tcp.py,sha256=K3IneOSl8xiOIC9z4jHK_4Mhq2n8eeUDASvXJQiRjfQ,11817
9
- appmesh/server_http.py,sha256=g2NYREF-f-vnSFVntAJDc0H43v_kNEqS7M4y7Q_DpEY,4193
10
- appmesh/server_tcp.py,sha256=GXEVDmYwM19ZUKkRXm8eEzBep9rE1vzV-PwaTlROpFU,1364
11
- appmesh/tcp_messages.py,sha256=E0cKWUta7NjuLoTGk-Z9CvbdZyakwG7hO8st_07E5L4,1991
12
- appmesh/tcp_transport.py,sha256=nkml2hqSkyeJrGDKGAYjWDgOnSyYMEImVT1PQ6jeudk,8163
13
- appmesh-1.6.14.dist-info/METADATA,sha256=2LZhu1Rp50ERLUa9DxhS-zQNM5om3-aLwtlcB4zNrUw,11814
14
- appmesh-1.6.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
- appmesh-1.6.14.dist-info/top_level.txt,sha256=-y0MNQOGJxUzLdHZ6E_Rfv5_LNCkV-GTmOBME_b6pg8,8
16
- appmesh-1.6.14.dist-info/RECORD,,