-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup.ts
84 lines (73 loc) · 2.72 KB
/
backup.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { BegetRequest } from '../beget-request';
import { FileBackup, FileInfo, LogTask, Mysql } from '../types/backup.interface';
import { Methods } from '../types/controller.interface';
export class BackupEndpoint {
constructor(private readonly client: BegetRequest) {}
/**
* @private
*/
private method<T>(method: Methods['backup'], data?: object): Promise<T> {
return this.client.api('backup', method, data);
}
/**
* Method returns available list of file backups.
*/
getFileBackupList(): Promise<FileBackup[]> {
return this.method('getFileBackupList');
}
/**
* Method returns available list of mysql database backups
*/
getMysqlBackupList(): Promise<FileBackup[]> {
return this.method('getMysqlBackupList');
}
/**
* Method returns a list of files and directories from a backup according to
* the given path and identifier.
*/
getFileList(params?: Pick<Mysql, 'backup_id' | 'path'>): Promise<FileInfo[]> {
return this.method('getFileList', params);
}
/**
* Method returns a list of databases from backup respective given identifier.
* @returns Returns list of database names.
*/
getMysqlList(params?: Pick<Mysql, 'backup_id'>): Promise<string[]> {
return this.method('getMysqlList', params);
}
/**
* Method creates query for data restoring from backup according to given path
* and backup copy.
* @returns Returns property of successful or unsuccessful execution.
*/
restoreFile(params?: Pick<Mysql, 'backup_id' | 'paths'>): Promise<boolean> {
return this.method('restoreFile', params);
}
/**
* Method creates query for DB recovery from backup according to
* given DB name and backup identifier.
* @returns Returns property of successful or unsuccessful execution.
*/
restoreMysql(params?: Pick<Mysql, 'backup_id' | 'bases'>): Promise<boolean> {
return this.method('restoreMysql', params);
}
/**
* Method creates query for up- and downloading data from backup to account root.
* @returns Returns property of successful or unsuccessful execution.
*/
downloadFile(params?: Pick<Mysql, 'backup_id' | 'paths'>): Promise<boolean> {
return this.method('downloadFile', params);
}
/**
* Method creates query for up- and downloading of data from backup to account root.
*/
downloadMysql(params?: Pick<Mysql, 'backup_id' | 'bases'>): Promise<boolean> {
return this.method('downloadMysql', params);
}
/**
* Method returns list and statuses of tasks for recovery and downloading.
*/
getLog(): Promise<LogTask[]> {
return this.method('getLog');
}
}