feat: Backup & Restore - Manual backup tested complete.
This commit is contained in:
@@ -24,9 +24,6 @@ import {
|
||||
UpdateCatalogTrimRequest,
|
||||
CreateCatalogEngineRequest,
|
||||
UpdateCatalogEngineRequest,
|
||||
StationOverview,
|
||||
CreateStationRequest,
|
||||
UpdateStationRequest,
|
||||
CatalogSearchResponse,
|
||||
ImportPreviewResult,
|
||||
ImportApplyResult,
|
||||
@@ -41,6 +38,15 @@ import {
|
||||
DeactivateUserRequest,
|
||||
UpdateUserProfileRequest,
|
||||
PromoteToAdminRequest,
|
||||
// Backup types
|
||||
BackupHistory,
|
||||
BackupSchedule,
|
||||
BackupSettings,
|
||||
ListBackupsResponse,
|
||||
CreateBackupRequest,
|
||||
CreateScheduleRequest,
|
||||
UpdateScheduleRequest,
|
||||
RestorePreviewResponse,
|
||||
} from '../types/admin.types';
|
||||
|
||||
export interface AuditLogsResponse {
|
||||
@@ -189,26 +195,6 @@ export const adminApi = {
|
||||
await apiClient.delete(`/admin/catalog/engines/${id}`);
|
||||
},
|
||||
|
||||
// Stations
|
||||
listStations: async (): Promise<StationOverview[]> => {
|
||||
const response = await apiClient.get<StationOverview[]>('/admin/stations');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
createStation: async (data: CreateStationRequest): Promise<StationOverview> => {
|
||||
const response = await apiClient.post<StationOverview>('/admin/stations', data);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
updateStation: async (id: string, data: UpdateStationRequest): Promise<StationOverview> => {
|
||||
const response = await apiClient.put<StationOverview>(`/admin/stations/${id}`, data);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
deleteStation: async (id: string): Promise<void> => {
|
||||
await apiClient.delete(`/admin/stations/${id}`);
|
||||
},
|
||||
|
||||
// Catalog Search
|
||||
searchCatalog: async (
|
||||
query: string,
|
||||
@@ -368,4 +354,114 @@ export const adminApi = {
|
||||
return response.data;
|
||||
},
|
||||
},
|
||||
|
||||
// Backup & Restore
|
||||
backups: {
|
||||
// List backups with pagination
|
||||
list: async (params: { page?: number; pageSize?: number } = {}): Promise<ListBackupsResponse> => {
|
||||
const response = await apiClient.get<ListBackupsResponse>('/admin/backups', { params });
|
||||
return response.data;
|
||||
},
|
||||
|
||||
// Get backup details
|
||||
get: async (id: string): Promise<BackupHistory> => {
|
||||
const response = await apiClient.get<BackupHistory>(`/admin/backups/${id}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
// Create manual backup
|
||||
create: async (data: CreateBackupRequest = {}): Promise<BackupHistory> => {
|
||||
const response = await apiClient.post<BackupHistory>('/admin/backups', data);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
// Download backup file
|
||||
download: async (id: string): Promise<Blob> => {
|
||||
const response = await apiClient.get(`/admin/backups/${id}/download`, {
|
||||
responseType: 'blob',
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
// Delete backup
|
||||
delete: async (id: string): Promise<void> => {
|
||||
await apiClient.delete(`/admin/backups/${id}`);
|
||||
},
|
||||
|
||||
// Upload backup file
|
||||
upload: async (file: File): Promise<BackupHistory> => {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
const response = await apiClient.post<BackupHistory>('/admin/backups/upload', formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
// Preview restore
|
||||
previewRestore: async (id: string): Promise<RestorePreviewResponse> => {
|
||||
const response = await apiClient.post<RestorePreviewResponse>(
|
||||
`/admin/backups/${id}/restore/preview`
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
// Execute restore
|
||||
restore: async (id: string): Promise<{ message: string }> => {
|
||||
const response = await apiClient.post<{ message: string }>(
|
||||
`/admin/backups/${id}/restore`
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
// Schedules
|
||||
schedules: {
|
||||
list: async (): Promise<BackupSchedule[]> => {
|
||||
const response = await apiClient.get<BackupSchedule[]>('/admin/backups/schedules');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
get: async (id: string): Promise<BackupSchedule> => {
|
||||
const response = await apiClient.get<BackupSchedule>(`/admin/backups/schedules/${id}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
create: async (data: CreateScheduleRequest): Promise<BackupSchedule> => {
|
||||
const response = await apiClient.post<BackupSchedule>('/admin/backups/schedules', data);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
update: async (id: string, data: UpdateScheduleRequest): Promise<BackupSchedule> => {
|
||||
const response = await apiClient.put<BackupSchedule>(
|
||||
`/admin/backups/schedules/${id}`,
|
||||
data
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
delete: async (id: string): Promise<void> => {
|
||||
await apiClient.delete(`/admin/backups/schedules/${id}`);
|
||||
},
|
||||
|
||||
toggle: async (id: string): Promise<BackupSchedule> => {
|
||||
const response = await apiClient.patch<BackupSchedule>(
|
||||
`/admin/backups/schedules/${id}/toggle`
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
},
|
||||
|
||||
// Settings
|
||||
settings: {
|
||||
get: async (): Promise<BackupSettings> => {
|
||||
const response = await apiClient.get<BackupSettings>('/admin/backups/settings');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
update: async (data: Partial<BackupSettings>): Promise<BackupSettings> => {
|
||||
const response = await apiClient.put<BackupSettings>('/admin/backups/settings', data);
|
||||
return response.data;
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user