pixelarraylib 1.1.7__tar.gz → 1.1.9__tar.gz
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.
- {pixelarraylib-1.1.7/pixelarraylib.egg-info → pixelarraylib-1.1.9}/PKG-INFO +7 -1
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/__init__.py +1 -1
- pixelarraylib-1.1.9/pixelarraylib/aliyun/polardb.py +391 -0
- pixelarraylib-1.1.9/pixelarraylib/monitor/feishu.py +573 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/scripts/__init__.py +1 -1
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9/pixelarraylib.egg-info}/PKG-INFO +7 -1
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib.egg-info/SOURCES.txt +1 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib.egg-info/requires.txt +7 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pyproject.toml +8 -1
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/requirements.txt +1 -0
- pixelarraylib-1.1.7/pixelarraylib/monitor/feishu.py +0 -275
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/LICENSE +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/MANIFEST.in +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/README.md +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/__main__.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/aliyun/__init__.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/aliyun/acr.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/aliyun/aliyun_email.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/aliyun/billing.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/aliyun/content_scanner.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/aliyun/domain.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/aliyun/eci.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/aliyun/ecs.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/aliyun/eip.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/aliyun/fc.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/aliyun/oss.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/aliyun/sms.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/aliyun/sts.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/db_utils/mysql.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/db_utils/redis.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/decorators/__init__.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/decorators/decorators.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/gitlab/__init__.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/gitlab/code_analyzer.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/gitlab/pypi_package_manager.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/monitor/__init__.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/scripts/build_website.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/scripts/collect_code_to_txt.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/scripts/create_test_case_files.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/scripts/nginx_proxy_to_ecs.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/scripts/remove_empty_lines.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/scripts/tson_convert.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/system/__init__.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/system/common.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/system/cron_manager.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/system/tson.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib/utils/name_generator.py +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib.egg-info/dependency_links.txt +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib.egg-info/entry_points.txt +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/pixelarraylib.egg-info/top_level.txt +0 -0
- {pixelarraylib-1.1.7 → pixelarraylib-1.1.9}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pixelarraylib
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.9
|
|
4
4
|
Summary: PixelArray Python开发工具库 - 包含阿里云服务、数据库工具、装饰器、监控等功能
|
|
5
5
|
Author-email: Lu qi <qi.lu@pixelarrayai.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -111,6 +111,12 @@ Requires-Dist: alibabacloud_tea_util; extra == "aliyun-fc"
|
|
|
111
111
|
Requires-Dist: requests; extra == "aliyun-fc"
|
|
112
112
|
Requires-Dist: cryptography; extra == "aliyun-fc"
|
|
113
113
|
Requires-Dist: paramiko; extra == "aliyun-fc"
|
|
114
|
+
Provides-Extra: aliyun-polardb
|
|
115
|
+
Requires-Dist: alibabacloud_polardb20170801; extra == "aliyun-polardb"
|
|
116
|
+
Requires-Dist: alibabacloud_credentials; extra == "aliyun-polardb"
|
|
117
|
+
Requires-Dist: alibabacloud_tea_openapi; extra == "aliyun-polardb"
|
|
118
|
+
Requires-Dist: alibabacloud_tea_util; extra == "aliyun-polardb"
|
|
119
|
+
Requires-Dist: requests; extra == "aliyun-polardb"
|
|
114
120
|
Provides-Extra: aliyun
|
|
115
121
|
Requires-Dist: alibabacloud_tea_util; extra == "aliyun"
|
|
116
122
|
Requires-Dist: alibabacloud_cms20190101; extra == "aliyun"
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# This file is auto-generated, don't edit it. Thanks.
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
import json
|
|
6
|
+
|
|
7
|
+
from typing import List
|
|
8
|
+
|
|
9
|
+
from alibabacloud_polardb20170801.client import Client as polardb20170801Client
|
|
10
|
+
from alibabacloud_tea_openapi import models as open_api_models
|
|
11
|
+
from alibabacloud_polardb20170801 import models as polardb_20170801_models
|
|
12
|
+
from alibabacloud_tea_util import models as util_models
|
|
13
|
+
from alibabacloud_tea_util.client import Client as UtilClient
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class PolarDBUtils:
|
|
17
|
+
def __init__(self, region_id: str, access_key_id: str, access_key_secret: str):
|
|
18
|
+
"""
|
|
19
|
+
description:
|
|
20
|
+
初始化PolarDB工具类
|
|
21
|
+
parameters:
|
|
22
|
+
region_id(str): 阿里云区域ID
|
|
23
|
+
access_key_id(str): 阿里云访问密钥ID
|
|
24
|
+
access_key_secret(str): 阿里云访问密钥Secret
|
|
25
|
+
"""
|
|
26
|
+
self.region_id = region_id
|
|
27
|
+
self.access_key_id = access_key_id
|
|
28
|
+
self.access_key_secret = access_key_secret
|
|
29
|
+
self.client = self._create_client()
|
|
30
|
+
|
|
31
|
+
def _create_client(self) -> polardb20170801Client:
|
|
32
|
+
"""
|
|
33
|
+
description:
|
|
34
|
+
创建PolarDB客户端
|
|
35
|
+
return:
|
|
36
|
+
polardb20170801Client: PolarDB客户端实例
|
|
37
|
+
"""
|
|
38
|
+
config = open_api_models.Config(
|
|
39
|
+
access_key_id=self.access_key_id,
|
|
40
|
+
access_key_secret=self.access_key_secret,
|
|
41
|
+
region_id=self.region_id,
|
|
42
|
+
)
|
|
43
|
+
config.endpoint = f"polardb.aliyuncs.com"
|
|
44
|
+
return polardb20170801Client(config)
|
|
45
|
+
|
|
46
|
+
def list_clusters(
|
|
47
|
+
self,
|
|
48
|
+
) -> tuple[dict, bool]:
|
|
49
|
+
describe_dbclusters_request = polardb_20170801_models.DescribeDBClustersRequest(
|
|
50
|
+
region_id=self.region_id
|
|
51
|
+
)
|
|
52
|
+
runtime = util_models.RuntimeOptions()
|
|
53
|
+
try:
|
|
54
|
+
resp = self.client.describe_dbclusters_with_options(
|
|
55
|
+
describe_dbclusters_request, runtime
|
|
56
|
+
)
|
|
57
|
+
return resp.body.to_map(), True
|
|
58
|
+
except Exception as error:
|
|
59
|
+
return {}, False
|
|
60
|
+
|
|
61
|
+
def list_cluster_ids(
|
|
62
|
+
self,
|
|
63
|
+
) -> tuple[list, bool]:
|
|
64
|
+
"""
|
|
65
|
+
description:
|
|
66
|
+
列出PolarDB集群ID
|
|
67
|
+
return:
|
|
68
|
+
cluster_ids: 集群ID列表
|
|
69
|
+
success: 操作是否成功
|
|
70
|
+
"""
|
|
71
|
+
try:
|
|
72
|
+
resp, success = self.list_clusters()
|
|
73
|
+
if not success:
|
|
74
|
+
return [], False
|
|
75
|
+
|
|
76
|
+
clusters = resp.get("Items", {}).get("DBCluster", [])
|
|
77
|
+
return [cluster["DBClusterId"] for cluster in clusters], True
|
|
78
|
+
except Exception as error:
|
|
79
|
+
return [], False
|
|
80
|
+
|
|
81
|
+
async def list_clusters_async(
|
|
82
|
+
self,
|
|
83
|
+
) -> tuple[dict, bool]:
|
|
84
|
+
describe_dbclusters_request = polardb_20170801_models.DescribeDBClustersRequest(
|
|
85
|
+
region_id=self.region_id
|
|
86
|
+
)
|
|
87
|
+
runtime = util_models.RuntimeOptions()
|
|
88
|
+
try:
|
|
89
|
+
resp = await self.client.describe_dbclusters_with_options_async(
|
|
90
|
+
describe_dbclusters_request, runtime
|
|
91
|
+
)
|
|
92
|
+
return resp.body.to_map(), True
|
|
93
|
+
except Exception as error:
|
|
94
|
+
return {}, False
|
|
95
|
+
|
|
96
|
+
async def list_cluster_ids_async(
|
|
97
|
+
self,
|
|
98
|
+
) -> tuple[list, bool]:
|
|
99
|
+
"""
|
|
100
|
+
description:
|
|
101
|
+
列出PolarDB集群ID
|
|
102
|
+
return:
|
|
103
|
+
cluster_ids: 集群ID列表
|
|
104
|
+
success: 操作是否成功
|
|
105
|
+
"""
|
|
106
|
+
try:
|
|
107
|
+
resp, success = await self.list_clusters_async()
|
|
108
|
+
if not success:
|
|
109
|
+
return [], False
|
|
110
|
+
clusters = resp.get("Items", {}).get("DBCluster", [])
|
|
111
|
+
return [cluster["DBClusterId"] for cluster in clusters], True
|
|
112
|
+
except Exception as error:
|
|
113
|
+
return [], False
|
|
114
|
+
|
|
115
|
+
def list_character_set_names(
|
|
116
|
+
self,
|
|
117
|
+
cluster_id: str,
|
|
118
|
+
) -> tuple[list, bool]:
|
|
119
|
+
"""
|
|
120
|
+
description:
|
|
121
|
+
列出PolarDB字符集名称
|
|
122
|
+
parameters:
|
|
123
|
+
cluster_id(str): 集群ID
|
|
124
|
+
return:
|
|
125
|
+
character_set_names: 字符集名称列表
|
|
126
|
+
success: 操作是否成功
|
|
127
|
+
"""
|
|
128
|
+
describe_character_set_name_request = (
|
|
129
|
+
polardb_20170801_models.DescribeCharacterSetNameRequest(
|
|
130
|
+
region_id=self.region_id, dbcluster_id=cluster_id
|
|
131
|
+
)
|
|
132
|
+
)
|
|
133
|
+
runtime = util_models.RuntimeOptions()
|
|
134
|
+
try:
|
|
135
|
+
resp = self.client.describe_character_set_name_with_options(
|
|
136
|
+
describe_character_set_name_request, runtime
|
|
137
|
+
)
|
|
138
|
+
return (
|
|
139
|
+
resp.body.to_map()
|
|
140
|
+
.get("CharacterSetNameItems", {})
|
|
141
|
+
.get("CharacterSetName", []),
|
|
142
|
+
True,
|
|
143
|
+
)
|
|
144
|
+
except Exception as error:
|
|
145
|
+
return [], False
|
|
146
|
+
|
|
147
|
+
async def list_character_set_names_async(
|
|
148
|
+
self,
|
|
149
|
+
cluster_id: str,
|
|
150
|
+
) -> tuple[list, bool]:
|
|
151
|
+
"""
|
|
152
|
+
description:
|
|
153
|
+
异步列出PolarDB字符集名称
|
|
154
|
+
parameters:
|
|
155
|
+
cluster_id(str): 集群ID
|
|
156
|
+
return:
|
|
157
|
+
character_set_names: 字符集名称列表
|
|
158
|
+
success: 操作是否成功
|
|
159
|
+
"""
|
|
160
|
+
describe_character_set_name_request = (
|
|
161
|
+
polardb_20170801_models.DescribeCharacterSetNameRequest(
|
|
162
|
+
region_id=self.region_id, dbcluster_id=cluster_id
|
|
163
|
+
)
|
|
164
|
+
)
|
|
165
|
+
runtime = util_models.RuntimeOptions()
|
|
166
|
+
try:
|
|
167
|
+
resp = await self.client.describe_character_set_name_with_options_async(
|
|
168
|
+
describe_character_set_name_request, runtime
|
|
169
|
+
)
|
|
170
|
+
return (
|
|
171
|
+
resp.body.to_map()
|
|
172
|
+
.get("CharacterSetNameItems", {})
|
|
173
|
+
.get("CharacterSetName", []),
|
|
174
|
+
True,
|
|
175
|
+
)
|
|
176
|
+
except Exception as error:
|
|
177
|
+
return [], False
|
|
178
|
+
|
|
179
|
+
def create_database(
|
|
180
|
+
self,
|
|
181
|
+
cluster_id: str,
|
|
182
|
+
database_name: str,
|
|
183
|
+
character_set_name: str = "utf8mb4",
|
|
184
|
+
) -> bool:
|
|
185
|
+
"""
|
|
186
|
+
description:
|
|
187
|
+
创建PolarDB数据库
|
|
188
|
+
parameters:
|
|
189
|
+
cluster_id(str): 集群ID
|
|
190
|
+
database_name(str): 数据库名称
|
|
191
|
+
character_set_name(str): 字符集名称
|
|
192
|
+
return:
|
|
193
|
+
bool: 创建结果
|
|
194
|
+
"""
|
|
195
|
+
create_database_request = polardb_20170801_models.CreateDatabaseRequest(
|
|
196
|
+
character_set_name=character_set_name,
|
|
197
|
+
dbcluster_id=cluster_id,
|
|
198
|
+
dbname=database_name,
|
|
199
|
+
)
|
|
200
|
+
runtime = util_models.RuntimeOptions()
|
|
201
|
+
try:
|
|
202
|
+
resp = self.client.create_database_with_options(
|
|
203
|
+
create_database_request, runtime
|
|
204
|
+
)
|
|
205
|
+
return True if resp.body.to_map().get("RequestId") else False
|
|
206
|
+
except Exception as error:
|
|
207
|
+
return False
|
|
208
|
+
|
|
209
|
+
async def create_database_async(
|
|
210
|
+
self,
|
|
211
|
+
cluster_id: str,
|
|
212
|
+
database_name: str,
|
|
213
|
+
character_set_name: str = "utf8mb4",
|
|
214
|
+
) -> bool:
|
|
215
|
+
"""
|
|
216
|
+
description:
|
|
217
|
+
异步创建PolarDB数据库
|
|
218
|
+
parameters:
|
|
219
|
+
cluster_id(str): 集群ID
|
|
220
|
+
database_name(str): 数据库名称
|
|
221
|
+
character_set_name(str): 字符集名称
|
|
222
|
+
return:
|
|
223
|
+
bool: 创建结果
|
|
224
|
+
"""
|
|
225
|
+
create_database_request = polardb_20170801_models.CreateDatabaseRequest(
|
|
226
|
+
character_set_name=character_set_name,
|
|
227
|
+
dbcluster_id=cluster_id,
|
|
228
|
+
dbname=database_name,
|
|
229
|
+
)
|
|
230
|
+
runtime = util_models.RuntimeOptions()
|
|
231
|
+
try:
|
|
232
|
+
resp = await self.client.create_database_with_options_async(
|
|
233
|
+
create_database_request, runtime
|
|
234
|
+
)
|
|
235
|
+
return True if resp.body.to_map().get("RequestId") else False
|
|
236
|
+
except Exception as error:
|
|
237
|
+
return False
|
|
238
|
+
|
|
239
|
+
def delete_database(
|
|
240
|
+
self,
|
|
241
|
+
cluster_id: str,
|
|
242
|
+
database_name: str,
|
|
243
|
+
) -> bool:
|
|
244
|
+
"""
|
|
245
|
+
description:
|
|
246
|
+
删除PolarDB数据库
|
|
247
|
+
parameters:
|
|
248
|
+
cluster_id(str): 集群ID
|
|
249
|
+
database_name(str): 数据库名称
|
|
250
|
+
return:
|
|
251
|
+
bool: 删除结果
|
|
252
|
+
"""
|
|
253
|
+
delete_database_request = polardb_20170801_models.DeleteDatabaseRequest(
|
|
254
|
+
dbcluster_id=cluster_id,
|
|
255
|
+
dbname=database_name,
|
|
256
|
+
)
|
|
257
|
+
runtime = util_models.RuntimeOptions()
|
|
258
|
+
try:
|
|
259
|
+
resp = self.client.delete_database_with_options(
|
|
260
|
+
delete_database_request, runtime
|
|
261
|
+
)
|
|
262
|
+
return True if resp.body.to_map().get("RequestId") else False
|
|
263
|
+
except Exception as error:
|
|
264
|
+
return False
|
|
265
|
+
|
|
266
|
+
async def delete_database_async(
|
|
267
|
+
self,
|
|
268
|
+
cluster_id: str,
|
|
269
|
+
database_name: str,
|
|
270
|
+
) -> bool:
|
|
271
|
+
"""
|
|
272
|
+
description:
|
|
273
|
+
异步删除PolarDB数据库
|
|
274
|
+
parameters:
|
|
275
|
+
cluster_id(str): 集群ID
|
|
276
|
+
database_name(str): 数据库名称
|
|
277
|
+
return:
|
|
278
|
+
bool: 删除结果
|
|
279
|
+
"""
|
|
280
|
+
delete_database_request = polardb_20170801_models.DeleteDatabaseRequest(
|
|
281
|
+
dbcluster_id=cluster_id,
|
|
282
|
+
dbname=database_name,
|
|
283
|
+
)
|
|
284
|
+
runtime = util_models.RuntimeOptions()
|
|
285
|
+
try:
|
|
286
|
+
resp = await self.client.delete_database_with_options_async(
|
|
287
|
+
delete_database_request, runtime
|
|
288
|
+
)
|
|
289
|
+
return True if resp.body.to_map().get("RequestId") else False
|
|
290
|
+
except Exception as error:
|
|
291
|
+
return False
|
|
292
|
+
|
|
293
|
+
def list_databases(
|
|
294
|
+
self,
|
|
295
|
+
cluster_id: str,
|
|
296
|
+
) -> tuple[list, bool]:
|
|
297
|
+
"""
|
|
298
|
+
description:
|
|
299
|
+
列出PolarDB数据库
|
|
300
|
+
parameters:
|
|
301
|
+
cluster_id(str): 集群ID
|
|
302
|
+
return:
|
|
303
|
+
databases: 数据库列表
|
|
304
|
+
success: 操作是否成功
|
|
305
|
+
"""
|
|
306
|
+
describe_databases_request = polardb_20170801_models.DescribeDatabasesRequest(
|
|
307
|
+
dbcluster_id=cluster_id
|
|
308
|
+
)
|
|
309
|
+
runtime = util_models.RuntimeOptions()
|
|
310
|
+
try:
|
|
311
|
+
resp = self.client.describe_databases_with_options(
|
|
312
|
+
describe_databases_request, runtime
|
|
313
|
+
)
|
|
314
|
+
return resp.body.to_map(), True
|
|
315
|
+
except Exception as error:
|
|
316
|
+
return [], False
|
|
317
|
+
|
|
318
|
+
async def list_databases_async(
|
|
319
|
+
self,
|
|
320
|
+
cluster_id: str,
|
|
321
|
+
) -> tuple[list, bool]:
|
|
322
|
+
"""
|
|
323
|
+
description:
|
|
324
|
+
异步列出PolarDB数据库
|
|
325
|
+
parameters:
|
|
326
|
+
cluster_id(str): 集群ID
|
|
327
|
+
return:
|
|
328
|
+
databases: 数据库列表
|
|
329
|
+
success: 操作是否成功
|
|
330
|
+
"""
|
|
331
|
+
describe_databases_request = polardb_20170801_models.DescribeDatabasesRequest(
|
|
332
|
+
dbcluster_id=cluster_id
|
|
333
|
+
)
|
|
334
|
+
runtime = util_models.RuntimeOptions()
|
|
335
|
+
try:
|
|
336
|
+
resp = await self.client.describe_databases_with_options_async(
|
|
337
|
+
describe_databases_request, runtime
|
|
338
|
+
)
|
|
339
|
+
return resp.body.to_map(), True
|
|
340
|
+
except Exception as error:
|
|
341
|
+
return [], False
|
|
342
|
+
|
|
343
|
+
def list_database_names(
|
|
344
|
+
self,
|
|
345
|
+
cluster_id: str,
|
|
346
|
+
) -> tuple[list, bool]:
|
|
347
|
+
"""
|
|
348
|
+
description:
|
|
349
|
+
列出PolarDB数据库名称
|
|
350
|
+
parameters:
|
|
351
|
+
cluster_id(str): 集群ID
|
|
352
|
+
return:
|
|
353
|
+
database_names: 数据库名称列表
|
|
354
|
+
success: 操作是否成功
|
|
355
|
+
"""
|
|
356
|
+
try:
|
|
357
|
+
resp, success = self.list_databases(cluster_id)
|
|
358
|
+
if not success:
|
|
359
|
+
return [], False
|
|
360
|
+
|
|
361
|
+
return [
|
|
362
|
+
database["DBName"]
|
|
363
|
+
for database in resp.get("Databases", {}).get("Database", [])
|
|
364
|
+
], True
|
|
365
|
+
except Exception as error:
|
|
366
|
+
return [], False
|
|
367
|
+
|
|
368
|
+
async def list_database_names_async(
|
|
369
|
+
self,
|
|
370
|
+
cluster_id: str,
|
|
371
|
+
) -> tuple[list, bool]:
|
|
372
|
+
"""
|
|
373
|
+
description:
|
|
374
|
+
异步列出PolarDB数据库名称
|
|
375
|
+
parameters:
|
|
376
|
+
cluster_id(str): 集群ID
|
|
377
|
+
return:
|
|
378
|
+
database_names: 数据库名称列表
|
|
379
|
+
success: 操作是否成功
|
|
380
|
+
"""
|
|
381
|
+
try:
|
|
382
|
+
resp, success = await self.list_databases_async(cluster_id)
|
|
383
|
+
if not success:
|
|
384
|
+
return [], False
|
|
385
|
+
|
|
386
|
+
return [
|
|
387
|
+
database["DBName"]
|
|
388
|
+
for database in resp.get("Databases", {}).get("Database", [])
|
|
389
|
+
], True
|
|
390
|
+
except Exception as error:
|
|
391
|
+
return [], False
|