|
52 | 52 | | revoke_permission |
53 | 53 | | alter_user_role |
54 | 54 | | show_user_permission |
| 55 | + | show_version |
55 | 56 |
|
56 | 57 | // meta command definition |
57 | 58 | meta_command: "\\" meta_command_name [meta_args] |
|
93 | 94 | RESOURCES: "RESOURCES"i |
94 | 95 | ON: "ON"i |
95 | 96 | SET: "SET"i |
| 97 | +VERSION: "VERSION"i |
96 | 98 |
|
97 | 99 | list_services: LIST SERVICES ";" |
98 | 100 | show_service: SHOW SERVICE NUMBER ";" |
|
121 | 123 | alter_user_role: ALTER USER quoted_string SET ROLE identifier ";" |
122 | 124 | show_user_permission: SHOW USER PERMISSION quoted_string ";" |
123 | 125 |
|
| 126 | +show_version: SHOW VERSION ";" |
| 127 | +
|
124 | 128 | action_list: identifier ("," identifier)* |
125 | 129 |
|
126 | 130 | identifier: WORD |
@@ -247,6 +251,9 @@ def show_user_permission(self, items): |
247 | 251 | user_name = items[3] |
248 | 252 | return {"type": "show_user_permission", "user_name": user_name} |
249 | 253 |
|
| 254 | + def show_version(self, items): |
| 255 | + return {"type": "show_version"} |
| 256 | + |
250 | 257 | def action_list(self, items): |
251 | 258 | return items |
252 | 259 |
|
@@ -556,6 +563,8 @@ def execute_command(self, parsed_command: Dict[str, Any]): |
556 | 563 | self._alter_user_role(command_dict) |
557 | 564 | case 'show_user_permission': |
558 | 565 | self._show_user_permission(command_dict) |
| 566 | + case 'show_version': |
| 567 | + self._show_version(command_dict) |
559 | 568 | case 'meta': |
560 | 569 | self._handle_meta_command(command_dict) |
561 | 570 | case _: |
@@ -862,6 +871,16 @@ def _show_user_permission(self, command): |
862 | 871 | print( |
863 | 872 | f"Fail to show user: {user_name_str} permission, code: {res_json['code']}, message: {res_json['message']}") |
864 | 873 |
|
| 874 | + def _show_version(self, command): |
| 875 | + print("show_version") |
| 876 | + url = f'http://{self.host}:{self.port}/api/v1/admin/version' |
| 877 | + response = self.session.get(url) |
| 878 | + res_json = response.json() |
| 879 | + if response.status_code == 200: |
| 880 | + self._print_table_simple(res_json['data']) |
| 881 | + else: |
| 882 | + print(f"Fail to show version, code: {res_json['code']}, message: {res_json['message']}") |
| 883 | + |
865 | 884 | def _handle_meta_command(self, command): |
866 | 885 | meta_command = command['command'] |
867 | 886 | args = command.get('args', []) |
|
0 commit comments