@cloudbase/manager-node 4.11.0-alpha.1 → 4.11.0-alpha.10
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.
- package/.claude/settings.local.json +9 -0
- package/lib/agent/index.js +607 -16
- package/lib/agent/type.js +1 -0
- package/lib/cloudApp/index.js +243 -0
- package/lib/cloudApp/types.js +10 -0
- package/lib/database/index.js +79 -0
- package/lib/docs/index.js +288 -0
- package/lib/docs/types.js +2 -0
- package/lib/env/index.js +94 -0
- package/lib/environment.js +20 -0
- package/lib/function/index.js +97 -33
- package/lib/index.js +34 -0
- package/lib/interfaces/cloudApp.interface.js +20 -0
- package/lib/interfaces/index.js +1 -0
- package/lib/log/index.js +105 -0
- package/lib/log/types.js +24 -0
- package/lib/mysql/index.js +551 -0
- package/lib/mysql/types/account.js +2 -0
- package/lib/mysql/types/backup.js +2 -0
- package/lib/mysql/types/base.js +2 -0
- package/lib/mysql/types/index.js +19 -0
- package/lib/permission/index.js +313 -0
- package/lib/permission/types.js +2 -0
- package/lib/storage/index.js +424 -10
- package/lib/user/index.js +200 -0
- package/package.json +1 -1
- package/types/agent/index.d.ts +115 -5
- package/types/agent/type.d.ts +389 -0
- package/types/cloudApp/index.d.ts +73 -0
- package/types/cloudApp/types.d.ts +325 -0
- package/types/database/index.d.ts +112 -0
- package/types/docs/index.d.ts +37 -0
- package/types/docs/types.d.ts +24 -0
- package/types/env/index.d.ts +39 -1
- package/types/env/type.d.ts +187 -0
- package/types/environment.d.ts +12 -0
- package/types/function/index.d.ts +34 -5
- package/types/index.d.ts +26 -0
- package/types/interfaces/cloudApp.interface.d.ts +4 -0
- package/types/interfaces/index.d.ts +1 -0
- package/types/log/index.d.ts +53 -0
- package/types/log/types.d.ts +177 -0
- package/types/mysql/index.d.ts +261 -0
- package/types/mysql/types/account.d.ts +160 -0
- package/types/mysql/types/backup.d.ts +161 -0
- package/types/mysql/types/base.d.ts +579 -0
- package/types/mysql/types/index.d.ts +3 -0
- package/types/permission/index.d.ts +31 -0
- package/types/permission/types.d.ts +127 -0
- package/types/storage/index.d.ts +151 -3
- package/types/user/index.d.ts +17 -1
- package/types/user/types.d.ts +62 -0
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
14
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
16
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
17
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
|
+
};
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.MysqlService = void 0;
|
|
24
|
+
const utils_1 = require("../utils");
|
|
25
|
+
__exportStar(require("./types/index"), exports);
|
|
26
|
+
class MysqlService {
|
|
27
|
+
constructor(environment) {
|
|
28
|
+
this.environment = environment;
|
|
29
|
+
this.envId = environment.getEnvId();
|
|
30
|
+
this._clusterId = '';
|
|
31
|
+
this._instanceGroupId = '';
|
|
32
|
+
this.tcbService = new utils_1.CloudService(environment.cloudBaseContext, MysqlService.tcbServiceVersion.service, MysqlService.tcbServiceVersion.version);
|
|
33
|
+
this.cynosdbService = new utils_1.CloudService(environment.cloudBaseContext, MysqlService.cynosdbServiceVersion.service, MysqlService.cynosdbServiceVersion.version);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 获取集群 ID(如未手动设置,则自动通过 describeClusterDetail 获取并缓存)
|
|
37
|
+
*/
|
|
38
|
+
get clusterId() {
|
|
39
|
+
return this._clusterId;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 手动设置集群 ID(适用于已知 clusterId 的场景,避免额外 API 调用)
|
|
43
|
+
*/
|
|
44
|
+
set clusterId(id) {
|
|
45
|
+
this._clusterId = id;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 开通 MySQL
|
|
49
|
+
* 开通后可通过 describeCreateResult 查询开通结果
|
|
50
|
+
* @param options 开通参数
|
|
51
|
+
* @returns 返回包含 TaskId 的结果
|
|
52
|
+
*/
|
|
53
|
+
async createMySQL(options) {
|
|
54
|
+
const { DbInstanceType, MysqlVersion, VpcId, SubnetId, LowerCaseTableNames } = options;
|
|
55
|
+
return this.tcbService.request('CreateMySQL', Object.assign(Object.assign(Object.assign(Object.assign({ EnvId: this.envId, DbInstanceType }, (MysqlVersion ? { MysqlVersion } : {})), (VpcId ? { VpcId } : {})), (SubnetId ? { SubnetId } : {})), (LowerCaseTableNames ? { LowerCaseTableNames } : {})));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 开通 MySQL 结果查询
|
|
59
|
+
* @param taskId OpenMySQL 返回的任务 ID(可选)
|
|
60
|
+
* @returns 开通结果状态
|
|
61
|
+
*/
|
|
62
|
+
async describeCreateResult(taskId) {
|
|
63
|
+
return this.tcbService.request('DescribeCreateMySQLResult', Object.assign({ EnvId: this.envId }, (taskId ? { TaskId: taskId } : {})));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 查询 MySQL 集群信息
|
|
67
|
+
* @returns MySQL 集群详情
|
|
68
|
+
*/
|
|
69
|
+
async describeClusterDetail() {
|
|
70
|
+
return this.tcbService.request('DescribeMySQLClusterDetail', {
|
|
71
|
+
EnvId: this.envId
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 销毁 MySQL
|
|
76
|
+
* 销毁后可通过 describeTaskStatus 查询销毁结果
|
|
77
|
+
* @returns 销毁结果(包含 TaskId、TaskName)
|
|
78
|
+
*/
|
|
79
|
+
async destroyMySQL() {
|
|
80
|
+
return this.tcbService.request('DestroyMySQL', {
|
|
81
|
+
EnvId: this.envId
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 查询 MySQL 任务状态(销毁等异步任务的结果查询)
|
|
86
|
+
* @param options 查询参数
|
|
87
|
+
* @param options.taskId 任务 ID
|
|
88
|
+
* @param options.taskName 任务名称
|
|
89
|
+
* @returns 任务状态
|
|
90
|
+
*/
|
|
91
|
+
async describeTaskStatus(options) {
|
|
92
|
+
return this.tcbService.request('DescribeMySQLTaskStatus', Object.assign(Object.assign({ EnvId: this.envId }, ((options === null || options === void 0 ? void 0 : options.taskId) ? { TaskId: options.taskId } : {})), ((options === null || options === void 0 ? void 0 : options.taskName) ? { TaskName: options.taskName } : {})));
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 执行 SQL 语句
|
|
96
|
+
* @param options SQL 执行参数
|
|
97
|
+
* @returns 查询结果(Items、Infos、RowsAffected)
|
|
98
|
+
*/
|
|
99
|
+
async runSql(options) {
|
|
100
|
+
const { Sql, DbInstance, ReadOnly } = options;
|
|
101
|
+
return this.tcbService.request('RunSql', Object.assign(Object.assign({ EnvId: this.envId, Sql }, (DbInstance ? { DbInstance } : {})), (ReadOnly !== undefined ? { ReadOnly } : {})));
|
|
102
|
+
}
|
|
103
|
+
// ---- 外网访问 ----
|
|
104
|
+
/**
|
|
105
|
+
* 查询集群实例组信息
|
|
106
|
+
* 通过 CynosDB 原生接口获取真实的 InstanceGroupId 等信息
|
|
107
|
+
* @returns 实例组列表
|
|
108
|
+
*/
|
|
109
|
+
async describeClusterInstanceGroups() {
|
|
110
|
+
const clusterId = await this.ensureClusterId();
|
|
111
|
+
return this.cynosdbService.request('DescribeClusterInstanceGroups', {
|
|
112
|
+
ClusterId: clusterId
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* 关闭外网访问
|
|
117
|
+
* @param options 实例 ID 或实例组 ID(二选一);均不传时自动获取实例组 ID
|
|
118
|
+
* @returns 任务流 ID
|
|
119
|
+
*/
|
|
120
|
+
async closeWan(options) {
|
|
121
|
+
const params = await this.resolveWanParams(options);
|
|
122
|
+
return this.cynosdbService.request('CloseWan', params);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* 开启外网访问
|
|
126
|
+
* @param options 实例 ID 或实例组 ID(二选一);均不传时自动获取实例组 ID
|
|
127
|
+
* @returns 任务流 ID
|
|
128
|
+
*/
|
|
129
|
+
async openWan(options) {
|
|
130
|
+
const params = await this.resolveWanParams(options);
|
|
131
|
+
return this.cynosdbService.request('OpenWan', params);
|
|
132
|
+
}
|
|
133
|
+
// ---- 任务查询 ----
|
|
134
|
+
/**
|
|
135
|
+
* 查询任务列表
|
|
136
|
+
* @param options 查询参数
|
|
137
|
+
* @returns 任务列表
|
|
138
|
+
*/
|
|
139
|
+
async describeTasks(options) {
|
|
140
|
+
return this.cynosdbService.request('DescribeTasks', Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((options === null || options === void 0 ? void 0 : options.StartTimeBegin) ? { StartTimeBegin: options.StartTimeBegin } : {})), ((options === null || options === void 0 ? void 0 : options.StartTimeEnd) ? { StartTimeEnd: options.StartTimeEnd } : {})), ((options === null || options === void 0 ? void 0 : options.Filters) ? { Filters: options.Filters } : {})), ((options === null || options === void 0 ? void 0 : options.Limit) !== undefined ? { Limit: options.Limit } : {})), ((options === null || options === void 0 ? void 0 : options.Offset) !== undefined ? { Offset: options.Offset } : {})));
|
|
141
|
+
}
|
|
142
|
+
// ---- 实例查询 ----
|
|
143
|
+
/**
|
|
144
|
+
* 查询实例列表
|
|
145
|
+
* @param options 查询参数(分页、排序、过滤条件等)
|
|
146
|
+
* @returns 实例列表和总数
|
|
147
|
+
*/
|
|
148
|
+
async describeInstances(options) {
|
|
149
|
+
return this.cynosdbService.request('DescribeInstances', Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((options === null || options === void 0 ? void 0 : options.Limit) !== undefined ? { Limit: options.Limit } : {})), ((options === null || options === void 0 ? void 0 : options.Offset) !== undefined ? { Offset: options.Offset } : {})), ((options === null || options === void 0 ? void 0 : options.OrderBy) ? { OrderBy: options.OrderBy } : {})), ((options === null || options === void 0 ? void 0 : options.OrderByType) ? { OrderByType: options.OrderByType } : {})), ((options === null || options === void 0 ? void 0 : options.Filters) ? { Filters: options.Filters } : {})), ((options === null || options === void 0 ? void 0 : options.DbType) ? { DbType: options.DbType } : {})), ((options === null || options === void 0 ? void 0 : options.Status) ? { Status: options.Status } : {})), ((options === null || options === void 0 ? void 0 : options.InstanceIds) ? { InstanceIds: options.InstanceIds } : {})), ((options === null || options === void 0 ? void 0 : options.ClusterType) ? { ClusterType: options.ClusterType } : {})));
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* 查询实例详情
|
|
153
|
+
* @param options 包含实例 ID
|
|
154
|
+
* @returns 实例详细信息
|
|
155
|
+
*/
|
|
156
|
+
async describeInstanceDetail(options) {
|
|
157
|
+
return this.cynosdbService.request('DescribeInstanceDetail', {
|
|
158
|
+
InstanceId: options.InstanceId
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* 重启实例
|
|
163
|
+
* @param options 包含实例 ID
|
|
164
|
+
* @returns 异步任务 FlowId
|
|
165
|
+
*/
|
|
166
|
+
async restartInstance(options) {
|
|
167
|
+
return this.cynosdbService.request('RestartInstance', {
|
|
168
|
+
InstanceId: options.InstanceId
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* 实例变配(升级/降级实例规格)
|
|
173
|
+
* @param options 变配参数(实例 ID、CPU、内存、升级类型等)
|
|
174
|
+
* @returns 订单号和冻结流水 ID
|
|
175
|
+
*/
|
|
176
|
+
async upgradeInstance(options) {
|
|
177
|
+
return this.cynosdbService.request('UpgradeInstance', Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ InstanceId: options.InstanceId, Cpu: options.Cpu, Memory: options.Memory, UpgradeType: options.UpgradeType }, (options.DeviceType ? { DeviceType: options.DeviceType } : {})), (options.AutoVoucher !== undefined ? { AutoVoucher: options.AutoVoucher } : {})), (options.DealMode !== undefined ? { DealMode: options.DealMode } : {})), (options.UpgradeMode ? { UpgradeMode: options.UpgradeMode } : {})), (options.UpgradeProxy ? { UpgradeProxy: options.UpgradeProxy } : {})));
|
|
178
|
+
}
|
|
179
|
+
// ---- 日志查询 ----
|
|
180
|
+
/**
|
|
181
|
+
* 查询实例慢查询日志
|
|
182
|
+
* @param options 查询参数(实例 ID、时间范围、分页、排序等)
|
|
183
|
+
* @returns 慢查询日志列表和总数
|
|
184
|
+
*/
|
|
185
|
+
async describeInstanceSlowQueries(options) {
|
|
186
|
+
return this.cynosdbService.request('DescribeInstanceSlowQueries', Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ InstanceId: options.InstanceId }, (options.StartTime ? { StartTime: options.StartTime } : {})), (options.EndTime ? { EndTime: options.EndTime } : {})), (options.Limit !== undefined ? { Limit: options.Limit } : {})), (options.Offset !== undefined ? { Offset: options.Offset } : {})), (options.Username ? { Username: options.Username } : {})), (options.Host ? { Host: options.Host } : {})), (options.Database ? { Database: options.Database } : {})), (options.OrderBy ? { OrderBy: options.OrderBy } : {})), (options.OrderByType ? { OrderByType: options.OrderByType } : {})), (options.SqlText ? { SqlText: options.SqlText } : {})));
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* 查询实例错误日志
|
|
190
|
+
* @param options 查询参数(实例 ID、时间范围、分页、排序、日志等级等)
|
|
191
|
+
* @returns 错误日志列表和总数
|
|
192
|
+
*/
|
|
193
|
+
async describeInstanceErrorLogs(options) {
|
|
194
|
+
return this.cynosdbService.request('DescribeInstanceErrorLogs', Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ InstanceId: options.InstanceId }, (options.Limit !== undefined ? { Limit: options.Limit } : {})), (options.Offset !== undefined ? { Offset: options.Offset } : {})), (options.StartTime ? { StartTime: options.StartTime } : {})), (options.EndTime ? { EndTime: options.EndTime } : {})), (options.OrderBy ? { OrderBy: options.OrderBy } : {})), (options.OrderByType ? { OrderByType: options.OrderByType } : {})), (options.LogLevels ? { LogLevels: options.LogLevels } : {})), (options.KeyWords ? { KeyWords: options.KeyWords } : {})));
|
|
195
|
+
}
|
|
196
|
+
// ---- 数据库查询 ----
|
|
197
|
+
/**
|
|
198
|
+
* 查询集群数据库列表
|
|
199
|
+
* @param options 分页参数
|
|
200
|
+
* @returns 数据库名称列表
|
|
201
|
+
*/
|
|
202
|
+
async describeClusterDatabases(options) {
|
|
203
|
+
const clusterId = await this.ensureClusterId();
|
|
204
|
+
return this.cynosdbService.request('DescribeClusterDatabases', Object.assign(Object.assign({ ClusterId: clusterId }, ((options === null || options === void 0 ? void 0 : options.Offset) !== undefined ? { Offset: options.Offset } : {})), ((options === null || options === void 0 ? void 0 : options.Limit) !== undefined ? { Limit: options.Limit } : {})));
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* 查询集群数据库表列表
|
|
208
|
+
* @param options 查询参数(包含数据库名)
|
|
209
|
+
* @returns 数据库表列表
|
|
210
|
+
*/
|
|
211
|
+
async describeClusterDatabaseTables(options) {
|
|
212
|
+
const clusterId = await this.ensureClusterId();
|
|
213
|
+
return this.cynosdbService.request('DescribeClusterDatabaseTables', Object.assign(Object.assign(Object.assign({ ClusterId: clusterId, Db: options.Db }, (options.Offset !== undefined ? { Offset: options.Offset } : {})), (options.Limit !== undefined ? { Limit: options.Limit } : {})), (options.TableType ? { TableType: options.TableType } : {})));
|
|
214
|
+
}
|
|
215
|
+
// ============ 账号管理相关接口 ============
|
|
216
|
+
/**
|
|
217
|
+
* 创建用户账号
|
|
218
|
+
* @param options 账号信息
|
|
219
|
+
* @returns RequestId
|
|
220
|
+
*/
|
|
221
|
+
async createAccounts(options) {
|
|
222
|
+
const clusterId = await this.ensureClusterId();
|
|
223
|
+
return this.cynosdbService.request('CreateAccounts', {
|
|
224
|
+
ClusterId: clusterId,
|
|
225
|
+
Accounts: options.Accounts
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* 删除用户账号
|
|
230
|
+
* @param options 要删除的账号列表
|
|
231
|
+
* @returns RequestId
|
|
232
|
+
*/
|
|
233
|
+
async deleteAccounts(options) {
|
|
234
|
+
const clusterId = await this.ensureClusterId();
|
|
235
|
+
return this.cynosdbService.request('DeleteAccounts', Object.assign({ ClusterId: clusterId }, (options.Accounts ? { Accounts: options.Accounts } : {})));
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* 查询账号所有可授予权限
|
|
239
|
+
* @param account 账号信息
|
|
240
|
+
* @returns 全局权限、数据库权限、表权限等
|
|
241
|
+
*/
|
|
242
|
+
async describeAccountAllGrantPrivileges(account) {
|
|
243
|
+
const clusterId = await this.ensureClusterId();
|
|
244
|
+
return this.cynosdbService.request('DescribeAccountAllGrantPrivileges', {
|
|
245
|
+
ClusterId: clusterId,
|
|
246
|
+
Account: account
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* 查询数据库账号列表
|
|
251
|
+
* @param options 查询参数
|
|
252
|
+
* @returns 账号列表和总数
|
|
253
|
+
*/
|
|
254
|
+
async describeAccounts(options) {
|
|
255
|
+
const clusterId = await this.ensureClusterId();
|
|
256
|
+
return this.cynosdbService.request('DescribeAccounts', Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ ClusterId: clusterId }, ((options === null || options === void 0 ? void 0 : options.AccountNames) ? { AccountNames: options.AccountNames } : {})), ((options === null || options === void 0 ? void 0 : options.Hosts) ? { Hosts: options.Hosts } : {})), ((options === null || options === void 0 ? void 0 : options.Limit) !== undefined ? { Limit: options.Limit } : {})), ((options === null || options === void 0 ? void 0 : options.Offset) !== undefined ? { Offset: options.Offset } : {})), ((options === null || options === void 0 ? void 0 : options.AccountRegular) ? { AccountRegular: options.AccountRegular } : {})));
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* 查询账号已有权限
|
|
260
|
+
* @param options 查询参数
|
|
261
|
+
* @returns 权限列表
|
|
262
|
+
*/
|
|
263
|
+
async describeAccountPrivileges(options) {
|
|
264
|
+
const clusterId = await this.ensureClusterId();
|
|
265
|
+
const { AccountName, Host, Db, Type, TableName } = options;
|
|
266
|
+
return this.cynosdbService.request('DescribeAccountPrivileges', Object.assign({ ClusterId: clusterId, AccountName,
|
|
267
|
+
Host,
|
|
268
|
+
Db,
|
|
269
|
+
Type }, (TableName ? { TableName } : {})));
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* 修改数据库账号描述信息
|
|
273
|
+
* @param options 修改参数
|
|
274
|
+
* @returns RequestId
|
|
275
|
+
*/
|
|
276
|
+
async modifyAccountDescription(options) {
|
|
277
|
+
const clusterId = await this.ensureClusterId();
|
|
278
|
+
const { AccountName, Description, Host } = options;
|
|
279
|
+
return this.cynosdbService.request('ModifyAccountDescription', Object.assign({ ClusterId: clusterId, AccountName,
|
|
280
|
+
Description }, (Host ? { Host } : {})));
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* 修改账号主机
|
|
284
|
+
* @param options 修改参数
|
|
285
|
+
* @returns RequestId
|
|
286
|
+
*/
|
|
287
|
+
async modifyAccountHost(options) {
|
|
288
|
+
const clusterId = await this.ensureClusterId();
|
|
289
|
+
return this.cynosdbService.request('ModifyAccountHost', {
|
|
290
|
+
ClusterId: clusterId,
|
|
291
|
+
Account: options.Account,
|
|
292
|
+
NewHost: options.NewHost
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* 修改账号配置
|
|
297
|
+
* @param options 修改参数
|
|
298
|
+
* @returns RequestId
|
|
299
|
+
*/
|
|
300
|
+
async modifyAccountParams(options) {
|
|
301
|
+
const clusterId = await this.ensureClusterId();
|
|
302
|
+
return this.cynosdbService.request('ModifyAccountParams', {
|
|
303
|
+
ClusterId: clusterId,
|
|
304
|
+
Account: options.Account,
|
|
305
|
+
AccountParams: options.AccountParams
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* 修改账号库表权限
|
|
310
|
+
* @param options 修改参数
|
|
311
|
+
* @returns RequestId
|
|
312
|
+
*/
|
|
313
|
+
async modifyAccountPrivileges(options) {
|
|
314
|
+
const clusterId = await this.ensureClusterId();
|
|
315
|
+
return this.cynosdbService.request('ModifyAccountPrivileges', Object.assign(Object.assign(Object.assign({ ClusterId: clusterId, Account: options.Account }, (options.GlobalPrivileges ? { GlobalPrivileges: options.GlobalPrivileges } : {})), (options.DatabasePrivileges
|
|
316
|
+
? { DatabasePrivileges: options.DatabasePrivileges }
|
|
317
|
+
: {})), (options.TablePrivileges ? { TablePrivileges: options.TablePrivileges } : {})));
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* 重置数据库账号密码
|
|
321
|
+
* @param options 重置参数
|
|
322
|
+
* @returns RequestId
|
|
323
|
+
*/
|
|
324
|
+
async resetAccountPassword(options) {
|
|
325
|
+
const clusterId = await this.ensureClusterId();
|
|
326
|
+
const { AccountName, AccountPassword, Host } = options;
|
|
327
|
+
return this.cynosdbService.request('ResetAccountPassword', Object.assign({ ClusterId: clusterId, AccountName,
|
|
328
|
+
AccountPassword }, (Host ? { Host } : {})));
|
|
329
|
+
}
|
|
330
|
+
// ============ 备份与回档相关接口 ============
|
|
331
|
+
/**
|
|
332
|
+
* 创建手动备份
|
|
333
|
+
* @param options 备份参数
|
|
334
|
+
* @returns 异步任务流 ID
|
|
335
|
+
*/
|
|
336
|
+
async createBackup(options) {
|
|
337
|
+
const clusterId = await this.ensureClusterId();
|
|
338
|
+
return this.cynosdbService.request('CreateBackup', Object.assign(Object.assign(Object.assign(Object.assign({ ClusterId: clusterId }, ((options === null || options === void 0 ? void 0 : options.BackupType) ? { BackupType: options.BackupType } : {})), ((options === null || options === void 0 ? void 0 : options.BackupDatabases) ? { BackupDatabases: options.BackupDatabases } : {})), ((options === null || options === void 0 ? void 0 : options.BackupTables) ? { BackupTables: options.BackupTables } : {})), ((options === null || options === void 0 ? void 0 : options.BackupName) ? { BackupName: options.BackupName } : {})));
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* 删除手动备份(无法删除自动备份)
|
|
342
|
+
* @param options 要删除的备份 ID
|
|
343
|
+
* @returns RequestId
|
|
344
|
+
*/
|
|
345
|
+
async deleteBackup(options) {
|
|
346
|
+
const clusterId = await this.ensureClusterId();
|
|
347
|
+
return this.cynosdbService.request('DeleteBackup', Object.assign(Object.assign({ ClusterId: clusterId }, (options.BackupIds ? { BackupIds: options.BackupIds } : {})), (options.SnapshotIdList ? { SnapshotIdList: options.SnapshotIdList } : {})));
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* 修改备份配置
|
|
351
|
+
* @param options 备份配置参数
|
|
352
|
+
* @returns RequestId
|
|
353
|
+
*/
|
|
354
|
+
async modifyBackupConfig(options) {
|
|
355
|
+
const clusterId = await this.ensureClusterId();
|
|
356
|
+
return this.cynosdbService.request('ModifyBackupConfig', Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ ClusterId: clusterId }, (options.BackupTimeBeg !== undefined
|
|
357
|
+
? { BackupTimeBeg: options.BackupTimeBeg }
|
|
358
|
+
: {})), (options.BackupTimeEnd !== undefined
|
|
359
|
+
? { BackupTimeEnd: options.BackupTimeEnd }
|
|
360
|
+
: {})), (options.ReserveDuration !== undefined
|
|
361
|
+
? { ReserveDuration: options.ReserveDuration }
|
|
362
|
+
: {})), (options.BackupFreq ? { BackupFreq: options.BackupFreq } : {})), (options.BackupType ? { BackupType: options.BackupType } : {})));
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* 查询备份文件列表
|
|
366
|
+
* @param options 查询参数
|
|
367
|
+
* @returns 备份文件列表
|
|
368
|
+
*/
|
|
369
|
+
async describeBackupList(options) {
|
|
370
|
+
const clusterId = await this.ensureClusterId();
|
|
371
|
+
return this.cynosdbService.request('DescribeBackupList', Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ ClusterId: clusterId }, ((options === null || options === void 0 ? void 0 : options.Limit) !== undefined ? { Limit: options.Limit } : {})), ((options === null || options === void 0 ? void 0 : options.Offset) !== undefined ? { Offset: options.Offset } : {})), ((options === null || options === void 0 ? void 0 : options.DbType) ? { DbType: options.DbType } : {})), ((options === null || options === void 0 ? void 0 : options.BackupIds) ? { BackupIds: options.BackupIds } : {})), ((options === null || options === void 0 ? void 0 : options.BackupType) ? { BackupType: options.BackupType } : {})), ((options === null || options === void 0 ? void 0 : options.BackupMethod) ? { BackupMethod: options.BackupMethod } : {})), ((options === null || options === void 0 ? void 0 : options.SnapShotType) ? { SnapShotType: options.SnapShotType } : {})), ((options === null || options === void 0 ? void 0 : options.StartTime) ? { StartTime: options.StartTime } : {})), ((options === null || options === void 0 ? void 0 : options.EndTime) ? { EndTime: options.EndTime } : {})), ((options === null || options === void 0 ? void 0 : options.FileNames) ? { FileNames: options.FileNames } : {})), ((options === null || options === void 0 ? void 0 : options.BackupNames) ? { BackupNames: options.BackupNames } : {})), ((options === null || options === void 0 ? void 0 : options.SnapshotIdList) ? { SnapshotIdList: options.SnapshotIdList } : {})), ((options === null || options === void 0 ? void 0 : options.BackupRegion) ? { BackupRegion: options.BackupRegion } : {})), ((options === null || options === void 0 ? void 0 : options.IsCrossRegionsBackup)
|
|
372
|
+
? { IsCrossRegionsBackup: options.IsCrossRegionsBackup }
|
|
373
|
+
: {})));
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* 查询备份下载地址
|
|
377
|
+
* @param options 备份 ID
|
|
378
|
+
* @returns 备份下载地址
|
|
379
|
+
*/
|
|
380
|
+
async describeBackupDownloadUrl(options) {
|
|
381
|
+
const clusterId = await this.ensureClusterId();
|
|
382
|
+
return this.cynosdbService.request('DescribeBackupDownloadUrl', {
|
|
383
|
+
ClusterId: clusterId,
|
|
384
|
+
BackupId: options.BackupId
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
// ---- 回档 ----
|
|
388
|
+
/**
|
|
389
|
+
* 集群回档
|
|
390
|
+
* @param options 回档参数
|
|
391
|
+
* @returns 任务流 ID
|
|
392
|
+
*/
|
|
393
|
+
async rollBackCluster(options) {
|
|
394
|
+
const clusterId = await this.ensureClusterId();
|
|
395
|
+
return this.cynosdbService.request('RollBackCluster', Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ ClusterId: clusterId, RollbackStrategy: options.RollbackStrategy }, (options.RollbackId !== undefined ? { RollbackId: options.RollbackId } : {})), (options.ExpectTime ? { ExpectTime: options.ExpectTime } : {})), (options.ExpectTimeThresh !== undefined
|
|
396
|
+
? { ExpectTimeThresh: options.ExpectTimeThresh }
|
|
397
|
+
: {})), (options.RollbackDatabases
|
|
398
|
+
? { RollbackDatabases: options.RollbackDatabases }
|
|
399
|
+
: {})), (options.RollbackTables ? { RollbackTables: options.RollbackTables } : {})), (options.RollbackMode ? { RollbackMode: options.RollbackMode } : {})));
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* 确保 clusterId 已获取(内部使用,自动从集群信息中获取并缓存)
|
|
403
|
+
*/
|
|
404
|
+
async ensureClusterId() {
|
|
405
|
+
if (!this._clusterId) {
|
|
406
|
+
const res = await this.describeClusterDetail();
|
|
407
|
+
this._clusterId = res.Data.DbClusterId;
|
|
408
|
+
}
|
|
409
|
+
return this._clusterId;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* 确保 instanceGroupId 已获取(内部使用,通过 CynosDB 原生接口获取真实值并缓存)
|
|
413
|
+
*/
|
|
414
|
+
async ensureInstanceGroupId() {
|
|
415
|
+
if (!this._instanceGroupId) {
|
|
416
|
+
const res = await this.describeClusterInstanceGroups();
|
|
417
|
+
const groups = res.InstanceGroupInfoList;
|
|
418
|
+
if (!groups || groups.length === 0) {
|
|
419
|
+
throw new Error('当前集群没有实例组,无法执行外网操作');
|
|
420
|
+
}
|
|
421
|
+
this._instanceGroupId = groups[0].InstanceGroupId;
|
|
422
|
+
}
|
|
423
|
+
return this._instanceGroupId;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* 解析 Wan 操作的请求参数
|
|
427
|
+
* 若用户未显式传入 InstanceId / InstanceGroupId,则自动获取实例组 ID
|
|
428
|
+
*/
|
|
429
|
+
async resolveWanParams(options) {
|
|
430
|
+
if (options === null || options === void 0 ? void 0 : options.InstanceId) {
|
|
431
|
+
return { InstanceId: options.InstanceId };
|
|
432
|
+
}
|
|
433
|
+
if (options === null || options === void 0 ? void 0 : options.InstanceGroupId) {
|
|
434
|
+
return { InstanceGroupId: options.InstanceGroupId };
|
|
435
|
+
}
|
|
436
|
+
// 均未传入,自动获取
|
|
437
|
+
const instanceGroupId = await this.ensureInstanceGroupId();
|
|
438
|
+
return { InstanceGroupId: instanceGroupId };
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
exports.MysqlService = MysqlService;
|
|
442
|
+
MysqlService.tcbServiceVersion = {
|
|
443
|
+
service: 'tcb',
|
|
444
|
+
version: '2018-06-08'
|
|
445
|
+
};
|
|
446
|
+
MysqlService.cynosdbServiceVersion = {
|
|
447
|
+
service: 'cynosdb',
|
|
448
|
+
version: '2019-01-07'
|
|
449
|
+
};
|
|
450
|
+
__decorate([
|
|
451
|
+
(0, utils_1.preLazy)()
|
|
452
|
+
], MysqlService.prototype, "createMySQL", null);
|
|
453
|
+
__decorate([
|
|
454
|
+
(0, utils_1.preLazy)()
|
|
455
|
+
], MysqlService.prototype, "describeCreateResult", null);
|
|
456
|
+
__decorate([
|
|
457
|
+
(0, utils_1.preLazy)()
|
|
458
|
+
], MysqlService.prototype, "describeClusterDetail", null);
|
|
459
|
+
__decorate([
|
|
460
|
+
(0, utils_1.preLazy)()
|
|
461
|
+
], MysqlService.prototype, "destroyMySQL", null);
|
|
462
|
+
__decorate([
|
|
463
|
+
(0, utils_1.preLazy)()
|
|
464
|
+
], MysqlService.prototype, "describeTaskStatus", null);
|
|
465
|
+
__decorate([
|
|
466
|
+
(0, utils_1.preLazy)()
|
|
467
|
+
], MysqlService.prototype, "runSql", null);
|
|
468
|
+
__decorate([
|
|
469
|
+
(0, utils_1.preLazy)()
|
|
470
|
+
], MysqlService.prototype, "describeClusterInstanceGroups", null);
|
|
471
|
+
__decorate([
|
|
472
|
+
(0, utils_1.preLazy)()
|
|
473
|
+
], MysqlService.prototype, "closeWan", null);
|
|
474
|
+
__decorate([
|
|
475
|
+
(0, utils_1.preLazy)()
|
|
476
|
+
], MysqlService.prototype, "openWan", null);
|
|
477
|
+
__decorate([
|
|
478
|
+
(0, utils_1.preLazy)()
|
|
479
|
+
], MysqlService.prototype, "describeTasks", null);
|
|
480
|
+
__decorate([
|
|
481
|
+
(0, utils_1.preLazy)()
|
|
482
|
+
], MysqlService.prototype, "describeInstances", null);
|
|
483
|
+
__decorate([
|
|
484
|
+
(0, utils_1.preLazy)()
|
|
485
|
+
], MysqlService.prototype, "describeInstanceDetail", null);
|
|
486
|
+
__decorate([
|
|
487
|
+
(0, utils_1.preLazy)()
|
|
488
|
+
], MysqlService.prototype, "restartInstance", null);
|
|
489
|
+
__decorate([
|
|
490
|
+
(0, utils_1.preLazy)()
|
|
491
|
+
], MysqlService.prototype, "upgradeInstance", null);
|
|
492
|
+
__decorate([
|
|
493
|
+
(0, utils_1.preLazy)()
|
|
494
|
+
], MysqlService.prototype, "describeInstanceSlowQueries", null);
|
|
495
|
+
__decorate([
|
|
496
|
+
(0, utils_1.preLazy)()
|
|
497
|
+
], MysqlService.prototype, "describeInstanceErrorLogs", null);
|
|
498
|
+
__decorate([
|
|
499
|
+
(0, utils_1.preLazy)()
|
|
500
|
+
], MysqlService.prototype, "describeClusterDatabases", null);
|
|
501
|
+
__decorate([
|
|
502
|
+
(0, utils_1.preLazy)()
|
|
503
|
+
], MysqlService.prototype, "describeClusterDatabaseTables", null);
|
|
504
|
+
__decorate([
|
|
505
|
+
(0, utils_1.preLazy)()
|
|
506
|
+
], MysqlService.prototype, "createAccounts", null);
|
|
507
|
+
__decorate([
|
|
508
|
+
(0, utils_1.preLazy)()
|
|
509
|
+
], MysqlService.prototype, "deleteAccounts", null);
|
|
510
|
+
__decorate([
|
|
511
|
+
(0, utils_1.preLazy)()
|
|
512
|
+
], MysqlService.prototype, "describeAccountAllGrantPrivileges", null);
|
|
513
|
+
__decorate([
|
|
514
|
+
(0, utils_1.preLazy)()
|
|
515
|
+
], MysqlService.prototype, "describeAccounts", null);
|
|
516
|
+
__decorate([
|
|
517
|
+
(0, utils_1.preLazy)()
|
|
518
|
+
], MysqlService.prototype, "describeAccountPrivileges", null);
|
|
519
|
+
__decorate([
|
|
520
|
+
(0, utils_1.preLazy)()
|
|
521
|
+
], MysqlService.prototype, "modifyAccountDescription", null);
|
|
522
|
+
__decorate([
|
|
523
|
+
(0, utils_1.preLazy)()
|
|
524
|
+
], MysqlService.prototype, "modifyAccountHost", null);
|
|
525
|
+
__decorate([
|
|
526
|
+
(0, utils_1.preLazy)()
|
|
527
|
+
], MysqlService.prototype, "modifyAccountParams", null);
|
|
528
|
+
__decorate([
|
|
529
|
+
(0, utils_1.preLazy)()
|
|
530
|
+
], MysqlService.prototype, "modifyAccountPrivileges", null);
|
|
531
|
+
__decorate([
|
|
532
|
+
(0, utils_1.preLazy)()
|
|
533
|
+
], MysqlService.prototype, "resetAccountPassword", null);
|
|
534
|
+
__decorate([
|
|
535
|
+
(0, utils_1.preLazy)()
|
|
536
|
+
], MysqlService.prototype, "createBackup", null);
|
|
537
|
+
__decorate([
|
|
538
|
+
(0, utils_1.preLazy)()
|
|
539
|
+
], MysqlService.prototype, "deleteBackup", null);
|
|
540
|
+
__decorate([
|
|
541
|
+
(0, utils_1.preLazy)()
|
|
542
|
+
], MysqlService.prototype, "modifyBackupConfig", null);
|
|
543
|
+
__decorate([
|
|
544
|
+
(0, utils_1.preLazy)()
|
|
545
|
+
], MysqlService.prototype, "describeBackupList", null);
|
|
546
|
+
__decorate([
|
|
547
|
+
(0, utils_1.preLazy)()
|
|
548
|
+
], MysqlService.prototype, "describeBackupDownloadUrl", null);
|
|
549
|
+
__decorate([
|
|
550
|
+
(0, utils_1.preLazy)()
|
|
551
|
+
], MysqlService.prototype, "rollBackCluster", null);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./base"), exports);
|
|
18
|
+
__exportStar(require("./account"), exports);
|
|
19
|
+
__exportStar(require("./backup"), exports);
|