Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:db automatic database backup (#4377)
Signed-off-by: jingyang <3161362058@qq.com>
- Loading branch information
Showing
10 changed files
with
176 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,38 @@ | ||
import { GET, POST, DELETE } from '@/services/request'; | ||
import type { Props as CreateBackupPros } from '@/pages/api/backup/create'; | ||
import { adaptBackup } from '@/utils/adapt'; | ||
import { adaptBackup, adaptBackupByCluster, adaptDBDetail } from '@/utils/adapt'; | ||
import { AutoBackupFormType } from '@/types/backup'; | ||
import type { Props as UpdatePolicyProps } from '@/pages/api/backup/updatePolicy'; | ||
|
||
/** | ||
* Deprecated API: This endpoint is no longer supported. | ||
* | ||
* The new method for obtaining backup policies is by querying the 'cluster spec backup' endpoint | ||
* for the specific database in the cluster. | ||
* | ||
* To update the auto-backup policy, use the PATCH operation on the 'cluster spec backup' resource. | ||
* | ||
* @param data - Object containing information about the database, including dbName and dbType. | ||
* @returns {Promise<AutoBackupFormType>} - A promise resolving to the auto-backup configuration form. | ||
*/ | ||
export const getBackupPolicy = (data: { dbName: string; dbType: string }) => | ||
GET<AutoBackupFormType>(`/api/backup/policy`, data); | ||
|
||
export const createBackup = (data: CreateBackupPros) => POST('/api/backup/create', data); | ||
|
||
export const getBackupList = (dbName: string) => | ||
GET('/api/backup/getBackupList', { dbName }).then((res) => res.map(adaptBackup)); | ||
|
||
export const deleteBackup = (backupName: string) => | ||
DELETE(`/api/backup/delBackup?backupName=${backupName}`); | ||
|
||
export const updateBackupPolicy = (data: UpdatePolicyProps) => | ||
POST<AutoBackupFormType>(`/api/backup/updatePolicy`, data); | ||
|
||
/** | ||
* Retrieves backup policy by cluster. | ||
* @param data An object containing dbName and dbType properties. | ||
* @returns A Promise that resolves to the adapted backup policy data upon successful execution. | ||
*/ | ||
export const getBackupPolicyByCluster = (data: { dbName: string; dbType: string }) => | ||
GET(`/api/getDBByName?name=${data.dbName}`).then(adaptBackupByCluster); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters