mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat(snapshots): list files in snapshots api
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
deleteRepository,
|
||||
getRepository,
|
||||
listSnapshots,
|
||||
listSnapshotFiles,
|
||||
listBackupSchedules,
|
||||
createBackupSchedule,
|
||||
deleteBackupSchedule,
|
||||
@@ -67,6 +68,7 @@ import type {
|
||||
DeleteRepositoryResponse,
|
||||
GetRepositoryData,
|
||||
ListSnapshotsData,
|
||||
ListSnapshotFilesData,
|
||||
ListBackupSchedulesData,
|
||||
CreateBackupScheduleData,
|
||||
CreateBackupScheduleResponse,
|
||||
@@ -715,6 +717,27 @@ export const listSnapshotsOptions = (options: Options<ListSnapshotsData>) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const listSnapshotFilesQueryKey = (options: Options<ListSnapshotFilesData>) =>
|
||||
createQueryKey("listSnapshotFiles", options);
|
||||
|
||||
/**
|
||||
* List files and directories in a snapshot
|
||||
*/
|
||||
export const listSnapshotFilesOptions = (options: Options<ListSnapshotFilesData>) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await listSnapshotFiles({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: listSnapshotFilesQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
export const listBackupSchedulesQueryKey = (options?: Options<ListBackupSchedulesData>) =>
|
||||
createQueryKey("listBackupSchedules", options);
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ import type {
|
||||
GetRepositoryResponses,
|
||||
ListSnapshotsData,
|
||||
ListSnapshotsResponses,
|
||||
ListSnapshotFilesData,
|
||||
ListSnapshotFilesResponses,
|
||||
ListBackupSchedulesData,
|
||||
ListBackupSchedulesResponses,
|
||||
CreateBackupScheduleData,
|
||||
@@ -348,6 +350,18 @@ export const listSnapshots = <ThrowOnError extends boolean = false>(
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* List files and directories in a snapshot
|
||||
*/
|
||||
export const listSnapshotFiles = <ThrowOnError extends boolean = false>(
|
||||
options: Options<ListSnapshotFilesData, ThrowOnError>,
|
||||
) => {
|
||||
return (options.client ?? _heyApiClient).get<ListSnapshotFilesResponses, unknown, ThrowOnError>({
|
||||
url: "/api/v1/repositories/{name}/snapshots/{snapshotId}/files",
|
||||
...options,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* List all backup schedules
|
||||
*/
|
||||
|
||||
@@ -788,7 +788,7 @@ export type ListSnapshotsData = {
|
||||
name: string;
|
||||
};
|
||||
query?: {
|
||||
volumeId?: number;
|
||||
volumeId?: string;
|
||||
};
|
||||
url: "/api/v1/repositories/{name}/snapshots";
|
||||
};
|
||||
@@ -810,6 +810,47 @@ export type ListSnapshotsResponses = {
|
||||
|
||||
export type ListSnapshotsResponse = ListSnapshotsResponses[keyof ListSnapshotsResponses];
|
||||
|
||||
export type ListSnapshotFilesData = {
|
||||
body?: never;
|
||||
path: {
|
||||
name: string;
|
||||
snapshotId: string;
|
||||
};
|
||||
query?: {
|
||||
path?: string;
|
||||
};
|
||||
url: "/api/v1/repositories/{name}/snapshots/{snapshotId}/files";
|
||||
};
|
||||
|
||||
export type ListSnapshotFilesResponses = {
|
||||
/**
|
||||
* List of files and directories in the snapshot
|
||||
*/
|
||||
200: {
|
||||
files: Array<{
|
||||
name: string;
|
||||
path: string;
|
||||
type: string;
|
||||
atime?: string;
|
||||
ctime?: string;
|
||||
gid?: number;
|
||||
mode?: number;
|
||||
mtime?: string;
|
||||
size?: number;
|
||||
uid?: number;
|
||||
}>;
|
||||
snapshot: {
|
||||
hostname: string;
|
||||
id: string;
|
||||
paths: Array<string>;
|
||||
short_id: string;
|
||||
time: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export type ListSnapshotFilesResponse = ListSnapshotFilesResponses[keyof ListSnapshotFilesResponses];
|
||||
|
||||
export type ListBackupSchedulesData = {
|
||||
body?: never;
|
||||
path?: never;
|
||||
|
||||
Reference in New Issue
Block a user