appmesh 1.4.0__py3-none-any.whl → 1.4.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/app_run.py CHANGED
@@ -21,18 +21,18 @@ class AppRun(object):
21
21
  self._client = client
22
22
  """Instance of `AppMeshClient` used to manage this application run."""
23
23
 
24
- self._forwarding_host = client.forwarding_host
24
+ self._forward_to = client.forward_to
25
25
  """Target server for the application run, used for forwarding."""
26
26
 
27
27
  @contextmanager
28
- def forwarding_host(self):
29
- """Context manager to override the `forwarding_host` for the duration of the run."""
30
- original_value = self._client.forwarding_host
31
- self._client.forwarding_host = self._forwarding_host
28
+ def forward_to(self):
29
+ """Context manager to override the `forward_to` for the duration of the run."""
30
+ original_value = self._client.forward_to
31
+ self._client.forward_to = self._forward_to
32
32
  try:
33
33
  yield
34
34
  finally:
35
- self._client.forwarding_host = original_value
35
+ self._client.forward_to = original_value
36
36
 
37
37
  def wait(self, stdout_print: bool = True, timeout: int = 0) -> int:
38
38
  """Wait for the asynchronous run to complete.
@@ -44,5 +44,5 @@ class AppRun(object):
44
44
  Returns:
45
45
  int: Exit code if the process finishes successfully. Returns `None` on timeout or exception.
46
46
  """
47
- with self.forwarding_host():
48
- return self._client.run_async_wait(self, stdout_print, timeout)
47
+ with self.forward_to():
48
+ return self._client.wait_for_async_run(self, stdout_print, timeout)
appmesh/http_client.py CHANGED
@@ -47,56 +47,56 @@ class AppMeshClient(metaclass=abc.ABCMeta):
47
47
  # Authentication Management
48
48
  - login()
49
49
  - logoff()
50
- - authentication()
51
- - renew()
52
- - totp_disable()
53
- - totp_secret()
54
- - totp_setup()
50
+ - authenticate()
51
+ - renew_token()
52
+ - disable_totp()
53
+ - get_totp_secret()
54
+ - setup_totp()
55
55
 
56
56
  # Application Management
57
- - app_add()
58
- - app_delete()
59
- - app_disable()
60
- - app_enable()
61
- - app_health()
62
- - app_output()
63
- - app_view()
64
- - app_view_all()
57
+ - add_app()
58
+ - delete_app()
59
+ - disable_app()
60
+ - enable_app()
61
+ - check_app_health()
62
+ - get_app_output()
63
+ - view_app()
64
+ - view_all_apps()
65
65
 
66
66
  # Run Application Operations
67
- - run_async()
68
- - run_async_wait()
69
- - run_sync()
67
+ - run_app_async()
68
+ - wait_for_async_run()
69
+ - run_app_sync()
70
70
 
71
71
  # System Management
72
- - forwarding_host
73
- - config_set()
74
- - config_view()
75
- - log_level_set()
76
- - host_resource()
77
- - metrics()
78
- - tag_add()
79
- - tag_delete()
80
- - tag_view()
72
+ - forward_to
73
+ - set_config()
74
+ - view_config()
75
+ - set_log_level()
76
+ - view_host_resources()
77
+ - get_metrics()
78
+ - add_tag()
79
+ - delete_tag()
80
+ - view_tags()
81
81
 
82
82
  # File Management
83
- - file_download()
84
- - file_upload()
83
+ - download_file()
84
+ - upload_file()
85
85
 
86
86
  # User and Role Management
87
- - user_add()
88
- - user_delete()
89
- - user_lock()
90
- - user_passwd_update()
91
- - user_self()
92
- - user_unlock()
93
- - users_view()
94
- - permissions_for_user()
95
- - permissions_view()
96
- - role_delete()
97
- - role_update()
98
- - roles_view()
99
- - groups_view()
87
+ - add_user()
88
+ - delete_user()
89
+ - lock_user()
90
+ - update_user_password()
91
+ - view_self()
92
+ - unlock_user()
93
+ - view_users()
94
+ - view_user_permissions()
95
+ - view_permissions()
96
+ - delete_role()
97
+ - update_role()
98
+ - view_roles()
99
+ - view_groups()
100
100
  """
101
101
 
102
102
  DURATION_ONE_WEEK_ISO = "P1W"
@@ -157,7 +157,7 @@ class AppMeshClient(metaclass=abc.ABCMeta):
157
157
  self.ssl_verify = rest_ssl_verify
158
158
  self.ssl_client_cert = rest_ssl_client_cert
159
159
  self.rest_timeout = rest_timeout
160
- self._forwarding_host = None
160
+ self._forward_to = None
161
161
 
162
162
  @property
163
163
  def jwt_token(self) -> str:
@@ -203,7 +203,7 @@ class AppMeshClient(metaclass=abc.ABCMeta):
203
203
  self._jwt_token = token
204
204
 
205
205
  @property
206
- def forwarding_host(self) -> str:
206
+ def forward_to(self) -> str:
207
207
  """Get the target host address for request forwarding in a cluster setup.
208
208
 
209
209
  This property manages the destination host where requests will be forwarded to
@@ -223,10 +223,10 @@ class AppMeshClient(metaclass=abc.ABCMeta):
223
223
  - All nodes must use identical JWT issuer settings
224
224
  - When port is omitted, current service port will be used
225
225
  """
226
- return self._forwarding_host
226
+ return self._forward_to
227
227
 
228
- @forwarding_host.setter
229
- def forwarding_host(self, host: str) -> None:
228
+ @forward_to.setter
229
+ def forward_to(self, host: str) -> None:
230
230
  """Set the target host address for request forwarding.
231
231
 
232
232
  Configure the destination host where requests should be forwarded to. This is
@@ -241,12 +241,12 @@ class AppMeshClient(metaclass=abc.ABCMeta):
241
241
  Pass empty string to disable forwarding.
242
242
 
243
243
  Examples:
244
- >>> client.forwarding_host = "backend-node:6060" # Use specific port
245
- >>> client.forwarding_host = "backend-node" # Use current service port
246
- >>> client.forwarding_host = None # Disable forwarding
244
+ >>> client.forward_to = "backend-node:6060" # Use specific port
245
+ >>> client.forward_to = "backend-node" # Use current service port
246
+ >>> client.forward_to = None # Disable forwarding
247
247
  """
248
248
 
249
- self._forwarding_host = host
249
+ self._forward_to = host
250
250
 
251
251
  ########################################
252
252
  # Security
@@ -297,7 +297,7 @@ class AppMeshClient(metaclass=abc.ABCMeta):
297
297
  return self.jwt_token
298
298
 
299
299
  def logoff(self) -> bool:
300
- """Logoff current session from server
300
+ """Log out of the current session from the server.
301
301
 
302
302
  Returns:
303
303
  bool: logoff success or failure.
@@ -309,8 +309,11 @@ class AppMeshClient(metaclass=abc.ABCMeta):
309
309
  return resp.status_code == HTTPStatus.OK
310
310
 
311
311
  def authentication(self, token: str, permission=None) -> bool:
312
- """Login with token and verify permission when specified,
313
- verified token will be stored in client object when success
312
+ """Deprecated: Use authenticate() instead."""
313
+ return self.authenticate(token, permission)
314
+
315
+ def authenticate(self, token: str, permission: str = None) -> bool:
316
+ """Authenticate with a token and verify permission if specified.
314
317
 
315
318
  Args:
316
319
  token (str): JWT token returned from login().
@@ -333,8 +336,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
333
336
  raise Exception(resp.text)
334
337
  return resp.status_code == HTTPStatus.OK
335
338
 
336
- def renew(self, timeout_seconds=DURATION_ONE_WEEK_ISO) -> str:
337
- """Renew current token
339
+ def renew_token(self, timeout: Union[int, str] = DURATION_ONE_WEEK_ISO) -> str:
340
+ """Renew the current token.
338
341
 
339
342
  Args:
340
343
  timeout_seconds (int | str, optional): token expire timeout of seconds. support ISO 8601 durations (e.g., 'P1Y2M3DT4H5M6S' 'P1W').
@@ -347,7 +350,7 @@ class AppMeshClient(metaclass=abc.ABCMeta):
347
350
  AppMeshClient.Method.POST,
348
351
  path="/appmesh/token/renew",
349
352
  header={
350
- "Expire-Seconds": self._parse_duration(timeout_seconds),
353
+ "Expire-Seconds": self._parse_duration(timeout),
351
354
  },
352
355
  )
353
356
  if resp.status_code == HTTPStatus.OK:
@@ -356,8 +359,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
356
359
  return self.jwt_token
357
360
  raise Exception(resp.text)
358
361
 
359
- def totp_secret(self) -> str:
360
- """Generate TOTP secret for current login user and return MFA URI with JSON body
362
+ def get_totp_secret(self) -> str:
363
+ """Generate TOTP secret for the current user and return MFA URI.
361
364
 
362
365
  Returns:
363
366
  str: TOTP secret str
@@ -368,8 +371,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
368
371
  return self._parse_totp_uri(totp_uri).get("secret")
369
372
  raise Exception(resp.text)
370
373
 
371
- def totp_setup(self, totp_code: str) -> bool:
372
- """Setup 2FA for current login user
374
+ def setup_totp(self, totp_code: str) -> bool:
375
+ """Set up 2FA for the current user.
373
376
 
374
377
  Args:
375
378
  totp_code (str): TOTP code
@@ -386,8 +389,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
386
389
  raise Exception(resp.text)
387
390
  return resp.status_code == HTTPStatus.OK
388
391
 
389
- def totp_disable(self, user="self") -> bool:
390
- """Disable 2FA for current user
392
+ def disable_totp(self, user: str = "self") -> bool:
393
+ """Disable 2FA for the specified user.
391
394
 
392
395
  Args:
393
396
  user (str, optional): user name for disable TOTP.
@@ -428,8 +431,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
428
431
  ########################################
429
432
  # Application view
430
433
  ########################################
431
- def app_view(self, app_name: str) -> App:
432
- """Get one application information
434
+ def view_app(self, app_name: str) -> App:
435
+ """Get information about a specific application.
433
436
 
434
437
  Args:
435
438
  app_name (str): the application name.
@@ -445,8 +448,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
445
448
  raise Exception(resp.text)
446
449
  return App(resp.json())
447
450
 
448
- def app_view_all(self):
449
- """Get all applications
451
+ def view_all_apps(self):
452
+ """Get information about all applications.
450
453
 
451
454
  Returns:
452
455
  list: the application object both contain static configuration and runtime information, only return applications that the user has permissions.
@@ -462,8 +465,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
462
465
  apps.append(App(app))
463
466
  return apps
464
467
 
465
- def app_output(self, app_name: str, stdout_position: int = 0, stdout_index: int = 0, stdout_maxsize: int = 10240, process_uuid: str = "", timeout: int = 0) -> AppOutput:
466
- """Get application stdout/stderr
468
+ def get_app_output(self, app_name: str, stdout_position: int = 0, stdout_index: int = 0, stdout_maxsize: int = 10240, process_uuid: str = "", timeout: int = 0) -> AppOutput:
469
+ """Get the stdout/stderr of an application.
467
470
 
468
471
  Args:
469
472
  app_name (str): the application name
@@ -492,8 +495,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
492
495
  exit_code = int(resp.headers["Exit-Code"]) if "Exit-Code" in resp.headers else None
493
496
  return AppOutput(status_code=resp.status_code, output=resp.text, out_position=out_position, exit_code=exit_code)
494
497
 
495
- def app_health(self, app_name: str) -> bool:
496
- """Get application health status
498
+ def check_app_health(self, app_name: str) -> bool:
499
+ """Check the health status of an application.
497
500
 
498
501
  Args:
499
502
  app_name (str): the application name.
@@ -509,8 +512,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
509
512
  ########################################
510
513
  # Application manage
511
514
  ########################################
512
- def app_add(self, app: App) -> App:
513
- """Register an application
515
+ def add_app(self, app: App) -> App:
516
+ """Register a new application.
514
517
 
515
518
  Args:
516
519
  app (App): the application definition.
@@ -526,7 +529,7 @@ class AppMeshClient(metaclass=abc.ABCMeta):
526
529
  raise Exception(resp.text)
527
530
  return App(resp.json())
528
531
 
529
- def app_delete(self, app_name: str) -> bool:
532
+ def delete_app(self, app_name: str) -> bool:
530
533
  """Remove an application.
531
534
 
532
535
  Args:
@@ -543,8 +546,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
543
546
  else:
544
547
  raise Exception(resp.text)
545
548
 
546
- def app_enable(self, app_name: str) -> bool:
547
- """Enable an application
549
+ def enable_app(self, app_name: str) -> bool:
550
+ """Enable an application.
548
551
 
549
552
  Args:
550
553
  app_name (str): the application name.
@@ -557,8 +560,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
557
560
  raise Exception(resp.text)
558
561
  return resp.status_code == HTTPStatus.OK
559
562
 
560
- def app_disable(self, app_name: str) -> bool:
561
- """Stop and disable an application
563
+ def disable_app(self, app_name: str) -> bool:
564
+ """Disable an application.
562
565
 
563
566
  Args:
564
567
  app_name (str): the application name.
@@ -574,8 +577,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
574
577
  ########################################
575
578
  # Cloud management
576
579
  ########################################
577
- def cloud_app_view_all(self) -> dict:
578
- """Get all cloud applications
580
+ def view_all_cloud_apps(self) -> dict:
581
+ """Get information about all cloud applications.
579
582
 
580
583
  Returns:
581
584
  dict: cloud applications in JSON format.
@@ -585,8 +588,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
585
588
  raise Exception(resp.text)
586
589
  return resp.json()
587
590
 
588
- def cloud_app(self, app_name: str) -> dict:
589
- """Get an cloud application
591
+ def view_cloud_app(self, app_name: str) -> dict:
592
+ """Get information about a specific cloud application.
590
593
 
591
594
  Args:
592
595
  app_name (str): the application name.
@@ -599,8 +602,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
599
602
  raise Exception(resp.text)
600
603
  return resp.json()
601
604
 
602
- def cloud_app_output(self, app_name: str, host_name: str, stdout_position: int = 0, stdout_index: int = 0, stdout_maxsize: int = 10240, process_uuid: str = ""):
603
- """Get cloud application stdout/stderr from master agent
605
+ def get_cloud_app_output(self, app_name: str, host_name: str, stdout_position: int = 0, stdout_index: int = 0, stdout_maxsize: int = 10240, process_uuid: str = ""):
606
+ """Get the stdout/stderr of a cloud application.
604
607
 
605
608
  Args:
606
609
  app_name (str): the application name
@@ -631,8 +634,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
631
634
  exit_code = int(resp.headers["Exit-Code"]) if "Exit-Code" in resp.headers else None
632
635
  return (resp.status_code == HTTPStatus.OK), resp.text, out_position, exit_code
633
636
 
634
- def cloud_app_delete(self, app_name: str) -> bool:
635
- """Delete a cloud application
637
+ def delete_cloud_app(self, app_name: str) -> bool:
638
+ """Delete a cloud application.
636
639
 
637
640
  Args:
638
641
  app_name (str): The application name for cloud
@@ -645,8 +648,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
645
648
  raise Exception(resp.text)
646
649
  return resp.status_code == HTTPStatus.OK
647
650
 
648
- def cloud_app_add(self, app_json: dict) -> dict:
649
- """Add a cloud application
651
+ def add_cloud_app(self, app_json: dict) -> dict:
652
+ """Add a new cloud application.
650
653
 
651
654
  Args:
652
655
  app_json (dict): the cloud application definition with replication, condition and resource requirement
@@ -659,8 +662,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
659
662
  raise Exception(resp.text)
660
663
  return resp.json()
661
664
 
662
- def cloud_nodes(self) -> dict:
663
- """Get cluster node list
665
+ def view_cloud_nodes(self) -> dict:
666
+ """Get a list of cluster nodes.
664
667
 
665
668
  Returns:
666
669
  dict: cluster node list json.
@@ -673,8 +676,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
673
676
  ########################################
674
677
  # Configuration
675
678
  ########################################
676
- def host_resource(self) -> dict:
677
- """Get App Mesh host resource report include CPU, memory and disk
679
+ def view_host_resources(self) -> dict:
680
+ """Get a report of host resources including CPU, memory, and disk.
678
681
 
679
682
  Returns:
680
683
  dict: the host resource json.
@@ -684,8 +687,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
684
687
  raise Exception(resp.text)
685
688
  return resp.json()
686
689
 
687
- def config_view(self) -> dict:
688
- """Get App Mesh configuration JSON
690
+ def view_config(self) -> dict:
691
+ """Get the App Mesh configuration in JSON format.
689
692
 
690
693
  Returns:
691
694
  dict: the configuration json.
@@ -695,8 +698,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
695
698
  raise Exception(resp.text)
696
699
  return resp.json()
697
700
 
698
- def config_set(self, cfg_json) -> dict:
699
- """Update configuration, the format follow 'config.yaml', support partial update
701
+ def set_config(self, config_json: dict) -> dict:
702
+ """Update the configuration.
700
703
 
701
704
  Args:
702
705
  cfg_json (dict): the new configuration json.
@@ -704,13 +707,13 @@ class AppMeshClient(metaclass=abc.ABCMeta):
704
707
  Returns:
705
708
  dict: the updated configuration json.
706
709
  """
707
- resp = self._request_http(AppMeshClient.Method.POST, path="/appmesh/config", body=cfg_json)
710
+ resp = self._request_http(AppMeshClient.Method.POST, path="/appmesh/config", body=config_json)
708
711
  if resp.status_code != HTTPStatus.OK:
709
712
  raise Exception(resp.text)
710
713
  return resp.json()
711
714
 
712
- def log_level_set(self, level: str = "DEBUG") -> str:
713
- """Update App Mesh log level(DEBUG/INFO/NOTICE/WARN/ERROR), a wrapper of config_set()
715
+ def set_log_level(self, level: str = "DEBUG") -> str:
716
+ """Update the log level.
714
717
 
715
718
  Args:
716
719
  level (str, optional): log level.
@@ -726,8 +729,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
726
729
  ########################################
727
730
  # User Management
728
731
  ########################################
729
- def user_passwd_update(self, new_password: str, user_name: str = "self") -> bool:
730
- """Change user password
732
+ def update_user_password(self, new_password: str, user_name: str = "self") -> bool:
733
+ """Change the password of a user.
731
734
 
732
735
  Args:
733
736
  user_name (str): the user name.
@@ -745,8 +748,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
745
748
  raise Exception(resp.text)
746
749
  return True
747
750
 
748
- def user_add(self, user_name: str, user_json: dict) -> bool:
749
- """Add a new user, not available for LDAP user
751
+ def add_user(self, user_name: str, user_json: dict) -> bool:
752
+ """Add a new user.
750
753
 
751
754
  Args:
752
755
  user_name (str): the user name.
@@ -762,8 +765,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
762
765
  )
763
766
  return resp.status_code == HTTPStatus.OK
764
767
 
765
- def user_delete(self, user_name: str) -> bool:
766
- """Delete a user
768
+ def delete_user(self, user_name: str) -> bool:
769
+ """Delete a user.
767
770
 
768
771
  Args:
769
772
  user_name (str): the user name.
@@ -777,8 +780,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
777
780
  )
778
781
  return resp.status_code == HTTPStatus.OK
779
782
 
780
- def user_lock(self, user_name: str) -> bool:
781
- """Lock a user
783
+ def lock_user(self, user_name: str) -> bool:
784
+ """Lock a user.
782
785
 
783
786
  Args:
784
787
  user_name (str): the user name.
@@ -794,8 +797,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
794
797
  raise Exception(resp.text)
795
798
  return resp.status_code == HTTPStatus.OK
796
799
 
797
- def user_unlock(self, user_name: str) -> bool:
798
- """Unlock a user
800
+ def unlock_user(self, user_name: str) -> bool:
801
+ """Unlock a user.
799
802
 
800
803
  Args:
801
804
  user_name (str): the user name.
@@ -811,8 +814,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
811
814
  raise Exception(resp.text)
812
815
  return resp.status_code == HTTPStatus.OK
813
816
 
814
- def users_view(self) -> dict:
815
- """Get all users
817
+ def view_users(self) -> dict:
818
+ """Get information about all users.
816
819
 
817
820
  Returns:
818
821
  dict: all user definition
@@ -822,8 +825,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
822
825
  raise Exception(resp.text)
823
826
  return resp.json()
824
827
 
825
- def user_self(self) -> dict:
826
- """Get current user infomation
828
+ def view_self(self) -> dict:
829
+ """Get information about the current user.
827
830
 
828
831
  Returns:
829
832
  dict: user definition.
@@ -833,8 +836,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
833
836
  raise Exception(resp.text)
834
837
  return resp.json()
835
838
 
836
- def groups_view(self) -> list:
837
- """Get all user groups
839
+ def view_groups(self) -> list:
840
+ """Get information about all user groups.
838
841
 
839
842
  Returns:
840
843
  dict: user group array.
@@ -844,8 +847,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
844
847
  raise Exception(resp.text)
845
848
  return resp.json()
846
849
 
847
- def permissions_view(self) -> list:
848
- """Get all available permissions
850
+ def view_permissions(self) -> list:
851
+ """Get information about all available permissions.
849
852
 
850
853
  Returns:
851
854
  dict: permission array
@@ -855,8 +858,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
855
858
  raise Exception(resp.text)
856
859
  return resp.json()
857
860
 
858
- def permissions_for_user(self) -> list:
859
- """Get current user permissions
861
+ def view_user_permissions(self) -> list:
862
+ """Get information about the permissions of the current user.
860
863
 
861
864
  Returns:
862
865
  dict: user permission array.
@@ -866,8 +869,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
866
869
  raise Exception(resp.text)
867
870
  return resp.json()
868
871
 
869
- def roles_view(self) -> list:
870
- """Get all roles with permission definition
872
+ def view_roles(self) -> list:
873
+ """Get information about all roles with permission definitions.
871
874
 
872
875
  Returns:
873
876
  dict: all role definition.
@@ -877,8 +880,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
877
880
  raise Exception(resp.text)
878
881
  return resp.json()
879
882
 
880
- def role_update(self, role_name: str, role_permission_json: dict) -> bool:
881
- """Update (or add) a role with defined permissions, the permission ID can be App Mesh pre-defined or other permission ID.
883
+ def update_role(self, role_name: str, role_permission_json: dict) -> bool:
884
+ """Update or add a role with defined permissions.
882
885
 
883
886
  Args:
884
887
  role_name (str): the role name.
@@ -892,8 +895,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
892
895
  raise Exception(resp.text)
893
896
  return resp.status_code == HTTPStatus.OK
894
897
 
895
- def role_delete(self, role_name: str) -> bool:
896
- """Delete a user role
898
+ def delete_role(self, role_name: str) -> bool:
899
+ """Delete a user role.
897
900
 
898
901
  Args:
899
902
  role_name (str): the role name.
@@ -912,8 +915,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
912
915
  ########################################
913
916
  # Tag management
914
917
  ########################################
915
- def tag_add(self, tag_name: str, tag_value: str) -> bool:
916
- """Add a new label
918
+ def add_tag(self, tag_name: str, tag_value: str) -> bool:
919
+ """Add a new label.
917
920
 
918
921
  Args:
919
922
  tag_name (str): the label name.
@@ -931,8 +934,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
931
934
  raise Exception(resp.text)
932
935
  return resp.status_code == HTTPStatus.OK
933
936
 
934
- def tag_delete(self, tag_name: str) -> bool:
935
- """Delete a label
937
+ def delete_tag(self, tag_name: str) -> bool:
938
+ """Delete a label.
936
939
 
937
940
  Args:
938
941
  tag_name (str): the label name.
@@ -945,8 +948,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
945
948
  raise Exception(resp.text)
946
949
  return resp.status_code == HTTPStatus.OK
947
950
 
948
- def tag_view(self) -> dict:
949
- """Get the server labels
951
+ def view_tags(self) -> dict:
952
+ """Get information about all labels.
950
953
 
951
954
  Returns:
952
955
  dict: label data.
@@ -959,8 +962,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
959
962
  ########################################
960
963
  # Promethus metrics
961
964
  ########################################
962
- def metrics(self):
963
- """Prometheus metrics (this does not call Prometheus API /metrics, just copy the same metrics data)
965
+ def get_metrics(self):
966
+ """Get Prometheus metrics.
964
967
 
965
968
  Returns:
966
969
  str: prometheus metrics texts
@@ -973,8 +976,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
973
976
  ########################################
974
977
  # File management
975
978
  ########################################
976
- def file_download(self, remote_file: str, local_file: str, apply_file_attributes: bool = True) -> None:
977
- """Copy a remote file to local. Optionally, the local file will have the same permission as the remote file.
979
+ def download_file(self, remote_file: str, local_file: str, apply_file_attributes: bool = True) -> None:
980
+ """Download a remote file to the local system. Optionally, the local file will have the same permission as the remote file.
978
981
 
979
982
  Args:
980
983
  remote_file (str): the remote file path.
@@ -1002,7 +1005,7 @@ class AppMeshClient(metaclass=abc.ABCMeta):
1002
1005
  except PermissionError:
1003
1006
  print(f"Warning: Unable to change owner/group of {local_file}. Operation requires elevated privileges.")
1004
1007
 
1005
- def file_upload(self, local_file: str, remote_file: str, apply_file_attributes: bool = True) -> None:
1008
+ def upload_file(self, local_file: str, remote_file: str, apply_file_attributes: bool = True) -> None:
1006
1009
  """Upload a local file to the remote server. Optionally, the remote file will have the same permission as the local file.
1007
1010
 
1008
1011
  Dependency:
@@ -1051,7 +1054,7 @@ class AppMeshClient(metaclass=abc.ABCMeta):
1051
1054
  else:
1052
1055
  raise TypeError(f"Invalid timeout type: {str(timeout)}")
1053
1056
 
1054
- def run_async(
1057
+ def run_app_async(
1055
1058
  self,
1056
1059
  app: Union[App, str],
1057
1060
  max_time_seconds: Union[int, str] = DURATION_TWO_DAYS_ISO,
@@ -1093,8 +1096,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
1093
1096
  # Return an AppRun object with the application name and process UUID
1094
1097
  return AppRun(self, resp.json()["name"], resp.json()["process_uuid"])
1095
1098
 
1096
- def run_async_wait(self, run: AppRun, stdout_print: bool = True, timeout: int = 0) -> int:
1097
- """Wait for an async run to be finished
1099
+ def wait_for_async_run(self, run: AppRun, stdout_print: bool = True, timeout: int = 0) -> int:
1100
+ """Wait for an asynchronous run to finish.
1098
1101
 
1099
1102
  Args:
1100
1103
  run (AppRun): asyncrized run result from run_async().
@@ -1109,14 +1112,14 @@ class AppMeshClient(metaclass=abc.ABCMeta):
1109
1112
  start = datetime.now()
1110
1113
  interval = 1 if self.__class__.__name__ == "AppMeshClient" else 1000
1111
1114
  while len(run.proc_uid) > 0:
1112
- app_out = self.app_output(app_name=run.app_name, stdout_position=last_output_position, stdout_index=0, process_uuid=run.proc_uid, timeout=interval)
1115
+ app_out = self.get_app_output(app_name=run.app_name, stdout_position=last_output_position, stdout_index=0, process_uuid=run.proc_uid, timeout=interval)
1113
1116
  if app_out.output and stdout_print:
1114
1117
  print(app_out.output, end="")
1115
1118
  if app_out.out_position is not None:
1116
1119
  last_output_position = app_out.out_position
1117
1120
  if app_out.exit_code is not None:
1118
1121
  # success
1119
- self.app_delete(run.app_name)
1122
+ self.delete_app(run.app_name)
1120
1123
  return app_out.exit_code
1121
1124
  if app_out.status_code != HTTPStatus.OK:
1122
1125
  # failed
@@ -1126,7 +1129,7 @@ class AppMeshClient(metaclass=abc.ABCMeta):
1126
1129
  break
1127
1130
  return None
1128
1131
 
1129
- def run_sync(
1132
+ def run_app_sync(
1130
1133
  self,
1131
1134
  app: Union[App, str],
1132
1135
  stdout_print: bool = True,
@@ -1176,7 +1179,7 @@ class AppMeshClient(metaclass=abc.ABCMeta):
1176
1179
  return exit_code, resp.text
1177
1180
 
1178
1181
  def _request_http(self, method: Method, path: str, query: dict = None, header: dict = None, body=None) -> requests.Response:
1179
- """REST API
1182
+ """Make an HTTP request.
1180
1183
 
1181
1184
  Args:
1182
1185
  method (Method): AppMeshClient.Method.
@@ -1193,11 +1196,11 @@ class AppMeshClient(metaclass=abc.ABCMeta):
1193
1196
  header = {} if header is None else header
1194
1197
  if self.jwt_token:
1195
1198
  header["Authorization"] = "Bearer " + self.jwt_token
1196
- if self.forwarding_host and len(self.forwarding_host) > 0:
1197
- if ":" in self.forwarding_host:
1198
- header[self.HTTP_HEADER_KEY_X_TARGET_HOST] = self.forwarding_host
1199
+ if self.forward_to and len(self.forward_to) > 0:
1200
+ if ":" in self.forward_to:
1201
+ header[self.HTTP_HEADER_KEY_X_TARGET_HOST] = self.forward_to
1199
1202
  else:
1200
- header[self.HTTP_HEADER_KEY_X_TARGET_HOST] = self.forwarding_host + ":" + str(parse.urlsplit(self.server_url).port)
1203
+ header[self.HTTP_HEADER_KEY_X_TARGET_HOST] = self.forward_to + ":" + str(parse.urlsplit(self.server_url).port)
1201
1204
  header[self.HTTP_HEADER_KEY_USER_AGENT] = self.HTTP_USER_AGENT
1202
1205
 
1203
1206
  if method is AppMeshClient.Method.GET:
appmesh/tcp_client.py CHANGED
@@ -103,7 +103,7 @@ class AppMeshClientTCP(AppMeshClient):
103
103
  appmesh_request = RequestMessage()
104
104
  if super().jwt_token:
105
105
  appmesh_request.headers["Authorization"] = "Bearer " + super().jwt_token
106
- if super().forwarding_host and len(super().forwarding_host) > 0:
106
+ if super().forward_to and len(super().forward_to) > 0:
107
107
  raise Exception("Not support forward request in TCP mode")
108
108
  appmesh_request.headers[self.HTTP_HEADER_KEY_USER_AGENT] = self.HTTP_USER_AGENT_TCP
109
109
  appmesh_request.uuid = str(uuid.uuid1())
@@ -145,7 +145,7 @@ class AppMeshClientTCP(AppMeshClient):
145
145
  ########################################
146
146
  # File management
147
147
  ########################################
148
- def file_download(self, remote_file: str, local_file: str, apply_file_attributes: bool = True) -> None:
148
+ def download_file(self, remote_file: str, local_file: str, apply_file_attributes: bool = True) -> None:
149
149
  """Copy a remote file to local, the local file will have the same permission as the remote file
150
150
 
151
151
  Args:
@@ -179,7 +179,7 @@ class AppMeshClientTCP(AppMeshClient):
179
179
  except PermissionError:
180
180
  print(f"Warning: Unable to change owner/group of {local_file}. Operation requires elevated privileges.")
181
181
 
182
- def file_upload(self, local_file: str, remote_file: str, apply_file_attributes: bool = True) -> None:
182
+ def upload_file(self, local_file: str, remote_file: str, apply_file_attributes: bool = True) -> None:
183
183
  """Upload a local file to the remote server, the remote file will have the same permission as the local file
184
184
 
185
185
  Dependency:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: appmesh
3
- Version: 1.4.0
3
+ Version: 1.4.2
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,13 @@
1
1
  appmesh/__init__.py,sha256=vgiSdMzlzDwgHxBMDoFaKWb77g2nJVciRf4z_ssAlwE,431
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
- appmesh/app_run.py,sha256=D4j_SaA16_RtZ2-Ey6X4HIyngvLdfFHgyzYurDT1ATc,1753
4
+ appmesh/app_run.py,sha256=9ISKGZ3k3kkbQvSsPfRfkOLqD9xhbqNOM7ork9F4w9c,1712
5
5
  appmesh/appmesh_client.py,sha256=0ltkqHZUq094gKneYmC0bEZCP0X9kHTp9fccKdWFWP0,339
6
- appmesh/http_client.py,sha256=miO52kW8d9s0tGn42SxbOPtVNu9ZL8HDFCoCCMXm_EA,47484
7
- appmesh/tcp_client.py,sha256=UsdD_APVPRy5CtgX1_hJyljols8cmCBoEiWlKH2gYOM,10933
6
+ appmesh/http_client.py,sha256=byVfHkZycZFv5LePlFgKT0Pu1HBC6AhEFbnrWFR-6PA,47679
7
+ appmesh/tcp_client.py,sha256=RkHl5s8jE333BJOgxJqJ_fvjbdRQza7ciV49vLT6YO4,10923
8
8
  appmesh/tcp_messages.py,sha256=w1Kehz_aX4X2CYAUsy9mFVJRhxnLQwwc6L58W4YkQqs,969
9
9
  appmesh/tcp_transport.py,sha256=UMGby2oKV4k7lyXZUMSOe2Je34fb1w7nTkxEpatKLKg,7256
10
- appmesh-1.4.0.dist-info/METADATA,sha256=3xIB3lw5lIKSBRILRydR3hcCH4QFJVPbGGn5IpY6IsU,11142
11
- appmesh-1.4.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
12
- appmesh-1.4.0.dist-info/top_level.txt,sha256=-y0MNQOGJxUzLdHZ6E_Rfv5_LNCkV-GTmOBME_b6pg8,8
13
- appmesh-1.4.0.dist-info/RECORD,,
10
+ appmesh-1.4.2.dist-info/METADATA,sha256=R0wCzPXHfSqN2G0jtfkOKYkikbbcyM_JwJLSMx2ToZM,11142
11
+ appmesh-1.4.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
12
+ appmesh-1.4.2.dist-info/top_level.txt,sha256=-y0MNQOGJxUzLdHZ6E_Rfv5_LNCkV-GTmOBME_b6pg8,8
13
+ appmesh-1.4.2.dist-info/RECORD,,