mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
* refactor: unify backend and frontend servers * refactor: correct paths for openapi & drizzle * refactor: move api-client to client * fix: drizzle paths * chore: fix linting issues * fix: form reset issue
589 lines
16 KiB
TypeScript
589 lines
16 KiB
TypeScript
// This file is auto-generated by @hey-api/openapi-ts
|
|
|
|
import type { Client, Options as Options2, TDataShape } from "./client";
|
|
import { client } from "./client.gen";
|
|
import type {
|
|
BrowseFilesystemData,
|
|
BrowseFilesystemResponses,
|
|
ChangePasswordData,
|
|
ChangePasswordResponses,
|
|
CreateBackupScheduleData,
|
|
CreateBackupScheduleResponses,
|
|
CreateRepositoryData,
|
|
CreateRepositoryResponses,
|
|
CreateVolumeData,
|
|
CreateVolumeResponses,
|
|
DeleteBackupScheduleData,
|
|
DeleteBackupScheduleResponses,
|
|
DeleteRepositoryData,
|
|
DeleteRepositoryResponses,
|
|
DeleteVolumeData,
|
|
DeleteVolumeResponses,
|
|
DoctorRepositoryData,
|
|
DoctorRepositoryResponses,
|
|
DownloadResticPasswordData,
|
|
DownloadResticPasswordResponses,
|
|
GetBackupScheduleData,
|
|
GetBackupScheduleForVolumeData,
|
|
GetBackupScheduleForVolumeResponses,
|
|
GetBackupScheduleResponses,
|
|
GetContainersUsingVolumeData,
|
|
GetContainersUsingVolumeErrors,
|
|
GetContainersUsingVolumeResponses,
|
|
GetMeData,
|
|
GetMeResponses,
|
|
GetRepositoryData,
|
|
GetRepositoryResponses,
|
|
GetSnapshotDetailsData,
|
|
GetSnapshotDetailsResponses,
|
|
GetStatusData,
|
|
GetStatusResponses,
|
|
GetSystemInfoData,
|
|
GetSystemInfoResponses,
|
|
GetVolumeData,
|
|
GetVolumeErrors,
|
|
GetVolumeResponses,
|
|
HealthCheckVolumeData,
|
|
HealthCheckVolumeErrors,
|
|
HealthCheckVolumeResponses,
|
|
ListBackupSchedulesData,
|
|
ListBackupSchedulesResponses,
|
|
ListFilesData,
|
|
ListFilesResponses,
|
|
ListRcloneRemotesData,
|
|
ListRcloneRemotesResponses,
|
|
ListRepositoriesData,
|
|
ListRepositoriesResponses,
|
|
ListSnapshotFilesData,
|
|
ListSnapshotFilesResponses,
|
|
ListSnapshotsData,
|
|
ListSnapshotsResponses,
|
|
ListVolumesData,
|
|
ListVolumesResponses,
|
|
LoginData,
|
|
LoginResponses,
|
|
LogoutData,
|
|
LogoutResponses,
|
|
MountVolumeData,
|
|
MountVolumeResponses,
|
|
RegisterData,
|
|
RegisterResponses,
|
|
RestoreSnapshotData,
|
|
RestoreSnapshotResponses,
|
|
RunBackupNowData,
|
|
RunBackupNowResponses,
|
|
StopBackupData,
|
|
StopBackupErrors,
|
|
StopBackupResponses,
|
|
TestConnectionData,
|
|
TestConnectionResponses,
|
|
UnmountVolumeData,
|
|
UnmountVolumeResponses,
|
|
UpdateBackupScheduleData,
|
|
UpdateBackupScheduleResponses,
|
|
UpdateVolumeData,
|
|
UpdateVolumeErrors,
|
|
UpdateVolumeResponses,
|
|
} from "./types.gen";
|
|
|
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<
|
|
TData,
|
|
ThrowOnError
|
|
> & {
|
|
/**
|
|
* You can provide a client instance returned by `createClient()` instead of
|
|
* individual options. This might be also useful if you want to implement a
|
|
* custom client.
|
|
*/
|
|
client?: Client;
|
|
/**
|
|
* You can pass arbitrary values through the `meta` object. This can be
|
|
* used to access values that aren't defined as part of the SDK function.
|
|
*/
|
|
meta?: Record<string, unknown>;
|
|
};
|
|
|
|
/**
|
|
* Register a new user
|
|
*/
|
|
export const register = <ThrowOnError extends boolean = false>(options?: Options<RegisterData, ThrowOnError>) => {
|
|
return (options?.client ?? client).post<RegisterResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/auth/register",
|
|
...options,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
...options?.headers,
|
|
},
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Login with username and password
|
|
*/
|
|
export const login = <ThrowOnError extends boolean = false>(options?: Options<LoginData, ThrowOnError>) => {
|
|
return (options?.client ?? client).post<LoginResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/auth/login",
|
|
...options,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
...options?.headers,
|
|
},
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Logout current user
|
|
*/
|
|
export const logout = <ThrowOnError extends boolean = false>(options?: Options<LogoutData, ThrowOnError>) => {
|
|
return (options?.client ?? client).post<LogoutResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/auth/logout",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Get current authenticated user
|
|
*/
|
|
export const getMe = <ThrowOnError extends boolean = false>(options?: Options<GetMeData, ThrowOnError>) => {
|
|
return (options?.client ?? client).get<GetMeResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/auth/me",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Get authentication system status
|
|
*/
|
|
export const getStatus = <ThrowOnError extends boolean = false>(options?: Options<GetStatusData, ThrowOnError>) => {
|
|
return (options?.client ?? client).get<GetStatusResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/auth/status",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Change current user password
|
|
*/
|
|
export const changePassword = <ThrowOnError extends boolean = false>(
|
|
options?: Options<ChangePasswordData, ThrowOnError>,
|
|
) => {
|
|
return (options?.client ?? client).post<ChangePasswordResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/auth/change-password",
|
|
...options,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
...options?.headers,
|
|
},
|
|
});
|
|
};
|
|
|
|
/**
|
|
* List all volumes
|
|
*/
|
|
export const listVolumes = <ThrowOnError extends boolean = false>(options?: Options<ListVolumesData, ThrowOnError>) => {
|
|
return (options?.client ?? client).get<ListVolumesResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/volumes",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Create a new volume
|
|
*/
|
|
export const createVolume = <ThrowOnError extends boolean = false>(
|
|
options?: Options<CreateVolumeData, ThrowOnError>,
|
|
) => {
|
|
return (options?.client ?? client).post<CreateVolumeResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/volumes",
|
|
...options,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
...options?.headers,
|
|
},
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Test connection to backend
|
|
*/
|
|
export const testConnection = <ThrowOnError extends boolean = false>(
|
|
options?: Options<TestConnectionData, ThrowOnError>,
|
|
) => {
|
|
return (options?.client ?? client).post<TestConnectionResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/volumes/test-connection",
|
|
...options,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
...options?.headers,
|
|
},
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Delete a volume
|
|
*/
|
|
export const deleteVolume = <ThrowOnError extends boolean = false>(
|
|
options: Options<DeleteVolumeData, ThrowOnError>,
|
|
) => {
|
|
return (options.client ?? client).delete<DeleteVolumeResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/volumes/{name}",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Get a volume by name
|
|
*/
|
|
export const getVolume = <ThrowOnError extends boolean = false>(options: Options<GetVolumeData, ThrowOnError>) => {
|
|
return (options.client ?? client).get<GetVolumeResponses, GetVolumeErrors, ThrowOnError>({
|
|
url: "/api/v1/volumes/{name}",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Update a volume's configuration
|
|
*/
|
|
export const updateVolume = <ThrowOnError extends boolean = false>(
|
|
options: Options<UpdateVolumeData, ThrowOnError>,
|
|
) => {
|
|
return (options.client ?? client).put<UpdateVolumeResponses, UpdateVolumeErrors, ThrowOnError>({
|
|
url: "/api/v1/volumes/{name}",
|
|
...options,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
...options.headers,
|
|
},
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Get containers using a volume by name
|
|
*/
|
|
export const getContainersUsingVolume = <ThrowOnError extends boolean = false>(
|
|
options: Options<GetContainersUsingVolumeData, ThrowOnError>,
|
|
) => {
|
|
return (options.client ?? client).get<
|
|
GetContainersUsingVolumeResponses,
|
|
GetContainersUsingVolumeErrors,
|
|
ThrowOnError
|
|
>({
|
|
url: "/api/v1/volumes/{name}/containers",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Mount a volume
|
|
*/
|
|
export const mountVolume = <ThrowOnError extends boolean = false>(options: Options<MountVolumeData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<MountVolumeResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/volumes/{name}/mount",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Unmount a volume
|
|
*/
|
|
export const unmountVolume = <ThrowOnError extends boolean = false>(
|
|
options: Options<UnmountVolumeData, ThrowOnError>,
|
|
) => {
|
|
return (options.client ?? client).post<UnmountVolumeResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/volumes/{name}/unmount",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Perform a health check on a volume
|
|
*/
|
|
export const healthCheckVolume = <ThrowOnError extends boolean = false>(
|
|
options: Options<HealthCheckVolumeData, ThrowOnError>,
|
|
) => {
|
|
return (options.client ?? client).post<HealthCheckVolumeResponses, HealthCheckVolumeErrors, ThrowOnError>({
|
|
url: "/api/v1/volumes/{name}/health-check",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* List files in a volume directory
|
|
*/
|
|
export const listFiles = <ThrowOnError extends boolean = false>(options: Options<ListFilesData, ThrowOnError>) => {
|
|
return (options.client ?? client).get<ListFilesResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/volumes/{name}/files",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Browse directories on the host filesystem
|
|
*/
|
|
export const browseFilesystem = <ThrowOnError extends boolean = false>(
|
|
options?: Options<BrowseFilesystemData, ThrowOnError>,
|
|
) => {
|
|
return (options?.client ?? client).get<BrowseFilesystemResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/volumes/filesystem/browse",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* List all repositories
|
|
*/
|
|
export const listRepositories = <ThrowOnError extends boolean = false>(
|
|
options?: Options<ListRepositoriesData, ThrowOnError>,
|
|
) => {
|
|
return (options?.client ?? client).get<ListRepositoriesResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/repositories",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Create a new restic repository
|
|
*/
|
|
export const createRepository = <ThrowOnError extends boolean = false>(
|
|
options?: Options<CreateRepositoryData, ThrowOnError>,
|
|
) => {
|
|
return (options?.client ?? client).post<CreateRepositoryResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/repositories",
|
|
...options,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
...options?.headers,
|
|
},
|
|
});
|
|
};
|
|
|
|
/**
|
|
* List all configured rclone remotes on the host system
|
|
*/
|
|
export const listRcloneRemotes = <ThrowOnError extends boolean = false>(
|
|
options?: Options<ListRcloneRemotesData, ThrowOnError>,
|
|
) => {
|
|
return (options?.client ?? client).get<ListRcloneRemotesResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/repositories/rclone-remotes",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Delete a repository
|
|
*/
|
|
export const deleteRepository = <ThrowOnError extends boolean = false>(
|
|
options: Options<DeleteRepositoryData, ThrowOnError>,
|
|
) => {
|
|
return (options.client ?? client).delete<DeleteRepositoryResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/repositories/{name}",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Get a single repository by name
|
|
*/
|
|
export const getRepository = <ThrowOnError extends boolean = false>(
|
|
options: Options<GetRepositoryData, ThrowOnError>,
|
|
) => {
|
|
return (options.client ?? client).get<GetRepositoryResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/repositories/{name}",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* List all snapshots in a repository
|
|
*/
|
|
export const listSnapshots = <ThrowOnError extends boolean = false>(
|
|
options: Options<ListSnapshotsData, ThrowOnError>,
|
|
) => {
|
|
return (options.client ?? client).get<ListSnapshotsResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/repositories/{name}/snapshots",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Get details of a specific snapshot
|
|
*/
|
|
export const getSnapshotDetails = <ThrowOnError extends boolean = false>(
|
|
options: Options<GetSnapshotDetailsData, ThrowOnError>,
|
|
) => {
|
|
return (options.client ?? client).get<GetSnapshotDetailsResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/repositories/{name}/snapshots/{snapshotId}",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* List files and directories in a snapshot
|
|
*/
|
|
export const listSnapshotFiles = <ThrowOnError extends boolean = false>(
|
|
options: Options<ListSnapshotFilesData, ThrowOnError>,
|
|
) => {
|
|
return (options.client ?? client).get<ListSnapshotFilesResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/repositories/{name}/snapshots/{snapshotId}/files",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Restore a snapshot to a target path on the filesystem
|
|
*/
|
|
export const restoreSnapshot = <ThrowOnError extends boolean = false>(
|
|
options: Options<RestoreSnapshotData, ThrowOnError>,
|
|
) => {
|
|
return (options.client ?? client).post<RestoreSnapshotResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/repositories/{name}/restore",
|
|
...options,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
...options.headers,
|
|
},
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Run doctor operations on a repository to fix common issues (unlock, check, repair index). Use this when the repository is locked or has errors.
|
|
*/
|
|
export const doctorRepository = <ThrowOnError extends boolean = false>(
|
|
options: Options<DoctorRepositoryData, ThrowOnError>,
|
|
) => {
|
|
return (options.client ?? client).post<DoctorRepositoryResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/repositories/{name}/doctor",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* List all backup schedules
|
|
*/
|
|
export const listBackupSchedules = <ThrowOnError extends boolean = false>(
|
|
options?: Options<ListBackupSchedulesData, ThrowOnError>,
|
|
) => {
|
|
return (options?.client ?? client).get<ListBackupSchedulesResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/backups",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Create a new backup schedule for a volume
|
|
*/
|
|
export const createBackupSchedule = <ThrowOnError extends boolean = false>(
|
|
options?: Options<CreateBackupScheduleData, ThrowOnError>,
|
|
) => {
|
|
return (options?.client ?? client).post<CreateBackupScheduleResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/backups",
|
|
...options,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
...options?.headers,
|
|
},
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Delete a backup schedule
|
|
*/
|
|
export const deleteBackupSchedule = <ThrowOnError extends boolean = false>(
|
|
options: Options<DeleteBackupScheduleData, ThrowOnError>,
|
|
) => {
|
|
return (options.client ?? client).delete<DeleteBackupScheduleResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/backups/{scheduleId}",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Get a backup schedule by ID
|
|
*/
|
|
export const getBackupSchedule = <ThrowOnError extends boolean = false>(
|
|
options: Options<GetBackupScheduleData, ThrowOnError>,
|
|
) => {
|
|
return (options.client ?? client).get<GetBackupScheduleResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/backups/{scheduleId}",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Update a backup schedule
|
|
*/
|
|
export const updateBackupSchedule = <ThrowOnError extends boolean = false>(
|
|
options: Options<UpdateBackupScheduleData, ThrowOnError>,
|
|
) => {
|
|
return (options.client ?? client).patch<UpdateBackupScheduleResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/backups/{scheduleId}",
|
|
...options,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
...options.headers,
|
|
},
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Get a backup schedule for a specific volume
|
|
*/
|
|
export const getBackupScheduleForVolume = <ThrowOnError extends boolean = false>(
|
|
options: Options<GetBackupScheduleForVolumeData, ThrowOnError>,
|
|
) => {
|
|
return (options.client ?? client).get<GetBackupScheduleForVolumeResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/backups/volume/{volumeId}",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Trigger a backup immediately for a schedule
|
|
*/
|
|
export const runBackupNow = <ThrowOnError extends boolean = false>(
|
|
options: Options<RunBackupNowData, ThrowOnError>,
|
|
) => {
|
|
return (options.client ?? client).post<RunBackupNowResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/backups/{scheduleId}/run",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Stop a backup that is currently in progress
|
|
*/
|
|
export const stopBackup = <ThrowOnError extends boolean = false>(options: Options<StopBackupData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<StopBackupResponses, StopBackupErrors, ThrowOnError>({
|
|
url: "/api/v1/backups/{scheduleId}/stop",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Get system information including available capabilities
|
|
*/
|
|
export const getSystemInfo = <ThrowOnError extends boolean = false>(
|
|
options?: Options<GetSystemInfoData, ThrowOnError>,
|
|
) => {
|
|
return (options?.client ?? client).get<GetSystemInfoResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/system/info",
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Download the Restic password file for backup recovery. Requires password re-authentication.
|
|
*/
|
|
export const downloadResticPassword = <ThrowOnError extends boolean = false>(
|
|
options?: Options<DownloadResticPasswordData, ThrowOnError>,
|
|
) => {
|
|
return (options?.client ?? client).post<DownloadResticPasswordResponses, unknown, ThrowOnError>({
|
|
url: "/api/v1/system/restic-password",
|
|
...options,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
...options?.headers,
|
|
},
|
|
});
|
|
};
|