feat: add backup contracts
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
export type TBackupStatus = 'pending' | 'running' | 'ready' | 'failed' | 'restoring' | 'restored';
|
||||
|
||||
export type TBackupTrigger = 'manual' | 'scheduled';
|
||||
|
||||
export type TBackupResourceType = 'volume' | 'database' | 'objectstorage';
|
||||
|
||||
export interface IBackupSnapshotBase {
|
||||
type: TBackupResourceType;
|
||||
snapshotId: string;
|
||||
snapshotName?: string;
|
||||
originalSize: number;
|
||||
storedSize: number;
|
||||
createdAt: number;
|
||||
tags?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface IBackupVolumeSnapshot extends IBackupSnapshotBase {
|
||||
type: 'volume';
|
||||
volumeName: string;
|
||||
mountPath: string;
|
||||
}
|
||||
|
||||
export interface IBackupDatabaseSnapshot extends IBackupSnapshotBase {
|
||||
type: 'database';
|
||||
resourceName: string;
|
||||
databaseName: string;
|
||||
}
|
||||
|
||||
export interface IBackupObjectStorageSnapshot extends IBackupSnapshotBase {
|
||||
type: 'objectstorage';
|
||||
resourceName: string;
|
||||
bucketName: string;
|
||||
}
|
||||
|
||||
export type TBackupSnapshot =
|
||||
| IBackupVolumeSnapshot
|
||||
| IBackupDatabaseSnapshot
|
||||
| IBackupObjectStorageSnapshot;
|
||||
|
||||
export interface IBackupRestoreEvent {
|
||||
restoredAt: number;
|
||||
status: 'restored' | 'failed';
|
||||
errorText?: string;
|
||||
}
|
||||
|
||||
export interface IBackupRecord {
|
||||
id: string;
|
||||
serviceId: string;
|
||||
serviceName?: string;
|
||||
clusterId?: string;
|
||||
status: TBackupStatus;
|
||||
trigger: TBackupTrigger;
|
||||
snapshots: TBackupSnapshot[];
|
||||
createdAt: number;
|
||||
updatedAt: number;
|
||||
completedAt?: number;
|
||||
requestedBy?: string;
|
||||
errorText?: string;
|
||||
restoreHistory?: IBackupRestoreEvent[];
|
||||
tags?: Record<string, string>;
|
||||
}
|
||||
@@ -12,6 +12,7 @@ export * from './registry.js';
|
||||
export * from './secretbundle.js';
|
||||
export * from './secretgroup.js';
|
||||
export * from './baremetal.js';
|
||||
export * from './backup.js';
|
||||
export * from './clusternode.js';
|
||||
export * from './settings.js';
|
||||
export * from './service.js';
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
import * as plugins from '../plugins.js';
|
||||
import type { IBackupRecord, TBackupSnapshot } from '../data/backup.js';
|
||||
import type { IService } from '../data/service.js';
|
||||
import type { IIdentity } from '../data/user.js';
|
||||
|
||||
export interface IReq_Any_Cloudly_CreateServiceBackup
|
||||
extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_Any_Cloudly_CreateServiceBackup
|
||||
> {
|
||||
method: 'createServiceBackup';
|
||||
request: {
|
||||
identity: IIdentity;
|
||||
serviceId: string;
|
||||
clusterId?: string;
|
||||
tags?: Record<string, string>;
|
||||
};
|
||||
response: {
|
||||
backup: IBackupRecord;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_Any_Cloudly_GetServiceBackups
|
||||
extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_Any_Cloudly_GetServiceBackups
|
||||
> {
|
||||
method: 'getServiceBackups';
|
||||
request: {
|
||||
identity: IIdentity;
|
||||
serviceId?: string;
|
||||
status?: IBackupRecord['status'];
|
||||
};
|
||||
response: {
|
||||
backups: IBackupRecord[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_Any_Cloudly_GetBackupById
|
||||
extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_Any_Cloudly_GetBackupById
|
||||
> {
|
||||
method: 'getBackupById';
|
||||
request: {
|
||||
identity: IIdentity;
|
||||
backupId: string;
|
||||
};
|
||||
response: {
|
||||
backup: IBackupRecord;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_Any_Cloudly_RestoreServiceBackup
|
||||
extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_Any_Cloudly_RestoreServiceBackup
|
||||
> {
|
||||
method: 'restoreServiceBackup';
|
||||
request: {
|
||||
identity: IIdentity;
|
||||
backupId: string;
|
||||
clear?: boolean;
|
||||
resourceTypes?: Array<TBackupSnapshot['type']>;
|
||||
};
|
||||
response: {
|
||||
backup: IBackupRecord;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_Cloudly_Coreflow_ExecuteServiceBackup
|
||||
extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_Cloudly_Coreflow_ExecuteServiceBackup
|
||||
> {
|
||||
method: 'executeServiceBackup';
|
||||
request: {
|
||||
backupId: string;
|
||||
service: IService;
|
||||
tags?: Record<string, string>;
|
||||
};
|
||||
response: {
|
||||
snapshots: TBackupSnapshot[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface IReq_Cloudly_Coreflow_ExecuteServiceRestore
|
||||
extends plugins.typedrequestInterfaces.implementsTR<
|
||||
plugins.typedrequestInterfaces.ITypedRequest,
|
||||
IReq_Cloudly_Coreflow_ExecuteServiceRestore
|
||||
> {
|
||||
method: 'executeServiceRestore';
|
||||
request: {
|
||||
backupId: string;
|
||||
service: IService;
|
||||
snapshots: TBackupSnapshot[];
|
||||
clear?: boolean;
|
||||
resourceTypes?: Array<TBackupSnapshot['type']>;
|
||||
};
|
||||
response: {
|
||||
restored: TBackupSnapshot[];
|
||||
};
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import * as plugins from '../plugins.js';
|
||||
|
||||
import * as adminRequests from './admin.js';
|
||||
import * as baremetalRequests from './baremetal.js';
|
||||
import * as backupRequests from './backup.js';
|
||||
import * as certificateRequests from './certificate.js';
|
||||
import * as clusterRequests from './cluster.js';
|
||||
import * as configRequests from './config.js';
|
||||
@@ -29,6 +30,7 @@ import * as versionRequests from './version.js';
|
||||
export {
|
||||
adminRequests as admin,
|
||||
baremetalRequests as baremetal,
|
||||
backupRequests as backup,
|
||||
certificateRequests as certificate,
|
||||
clusterRequests as cluster,
|
||||
configRequests as config,
|
||||
|
||||
Reference in New Issue
Block a user