-
Notifications
You must be signed in to change notification settings - Fork 0
/
mysql.ts
63 lines (55 loc) · 2.12 KB
/
mysql.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { BegetRequest } from '../beget-request';
import { Methods } from '../types/controller.interface';
import { DB, DBConf } from '../types/mysql.interface';
export class MysqlEndpoint {
constructor(private readonly client: BegetRequest) {}
/**
* @private
*/
private method<T>(method: Methods['mysql'], data?: object): Promise<T> {
return this.client.api('mysql', method, data);
}
/**
* The method returns a list of MySQL databases with their accesses.
*/
getList(): Promise<DB[]> {
return this.method('getList');
}
/**
* The method adds the task to the queue for creating a new MySql database with
* the specified suffix and creates access for localhost with the specified password.
* The database creation process can take several minutes.
* @returns Returns property of successful or unsuccessful execution.
*/
addDb(params: Pick<DBConf, 'suffix' | 'password'>): Promise<boolean> {
return this.method('addDb', params);
}
/**
* The method adds the specified access to the specified MySql database.
* @returns Returns property of successful or unsuccessful execution.
*/
addAccess(params: DBConf): Promise<boolean> {
return this.method('addAccess', params);
}
/**
* The method deletes the specified database and all accesses to it.
* @returns Returns property of successful or unsuccessful execution.
*/
dropDb(params: Pick<DBConf, 'suffix'>): Promise<boolean> {
return this.method('dropDb', params);
}
/**
* The method removes the specified access from the database.
* @returns Returns property of successful or unsuccessful execution.
*/
dropAccess(params: Pick<DBConf, 'suffix' | 'access'>): Promise<boolean> {
return this.method('dropAccess', params);
}
/**
* The method changes the password on the specified access.
* @returns Returns property of successful or unsuccessful execution.
*/
changeAccessPassword(params: DBConf): Promise<boolean> {
return this.method('changeAccessPassword', params);
}
}