mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat: download recovery file restic password
This commit is contained in:
@@ -37,6 +37,7 @@ import {
|
||||
getBackupScheduleForVolume,
|
||||
runBackupNow,
|
||||
getSystemInfo,
|
||||
downloadResticPassword,
|
||||
} from "../sdk.gen";
|
||||
import { queryOptions, type UseMutationOptions, type DefaultError } from "@tanstack/react-query";
|
||||
import type {
|
||||
@@ -94,6 +95,9 @@ import type {
|
||||
RunBackupNowData,
|
||||
RunBackupNowResponse,
|
||||
GetSystemInfoData,
|
||||
DownloadResticPasswordData,
|
||||
DownloadResticPasswordError,
|
||||
DownloadResticPasswordResponse,
|
||||
} from "../types.gen";
|
||||
import { client as _heyApiClient } from "../client.gen";
|
||||
|
||||
@@ -1123,3 +1127,51 @@ export const getSystemInfoOptions = (options?: Options<GetSystemInfoData>) => {
|
||||
queryKey: getSystemInfoQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
export const downloadResticPasswordQueryKey = (options?: Options<DownloadResticPasswordData>) =>
|
||||
createQueryKey("downloadResticPassword", options);
|
||||
|
||||
/**
|
||||
* Download the Restic password file for backup recovery. Requires password re-authentication.
|
||||
*/
|
||||
export const downloadResticPasswordOptions = (options?: Options<DownloadResticPasswordData>) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await downloadResticPassword({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: downloadResticPasswordQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Download the Restic password file for backup recovery. Requires password re-authentication.
|
||||
*/
|
||||
export const downloadResticPasswordMutation = (
|
||||
options?: Partial<Options<DownloadResticPasswordData>>,
|
||||
): UseMutationOptions<
|
||||
DownloadResticPasswordResponse,
|
||||
DownloadResticPasswordError,
|
||||
Options<DownloadResticPasswordData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
DownloadResticPasswordResponse,
|
||||
DownloadResticPasswordError,
|
||||
Options<DownloadResticPasswordData>
|
||||
> = {
|
||||
mutationFn: async (localOptions) => {
|
||||
const { data } = await downloadResticPassword({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
@@ -76,6 +76,9 @@ import type {
|
||||
RunBackupNowResponses,
|
||||
GetSystemInfoData,
|
||||
GetSystemInfoResponses,
|
||||
DownloadResticPasswordData,
|
||||
DownloadResticPasswordResponses,
|
||||
DownloadResticPasswordErrors,
|
||||
} from "./types.gen";
|
||||
import { client as _heyApiClient } from "./client.gen";
|
||||
|
||||
@@ -541,3 +544,23 @@ export const getSystemInfo = <ThrowOnError extends boolean = false>(
|
||||
...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 ?? _heyApiClient).post<
|
||||
DownloadResticPasswordResponses,
|
||||
DownloadResticPasswordErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
url: "/api/v1/system/restic-password",
|
||||
...options,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...options?.headers,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -18,6 +18,7 @@ export type RegisterResponses = {
|
||||
message: string;
|
||||
success: boolean;
|
||||
user?: {
|
||||
hasDownloadedResticPassword: boolean;
|
||||
id: number;
|
||||
username: string;
|
||||
};
|
||||
@@ -44,6 +45,7 @@ export type LoginResponses = {
|
||||
message: string;
|
||||
success: boolean;
|
||||
user?: {
|
||||
hasDownloadedResticPassword: boolean;
|
||||
id: number;
|
||||
username: string;
|
||||
};
|
||||
@@ -85,6 +87,7 @@ export type GetMeResponses = {
|
||||
message: string;
|
||||
success: boolean;
|
||||
user?: {
|
||||
hasDownloadedResticPassword: boolean;
|
||||
id: number;
|
||||
username: string;
|
||||
};
|
||||
@@ -149,6 +152,8 @@ export type ListVolumesResponses = {
|
||||
config:
|
||||
| {
|
||||
backend: "directory";
|
||||
path: string;
|
||||
readOnly?: false;
|
||||
}
|
||||
| {
|
||||
backend: "nfs";
|
||||
@@ -175,6 +180,7 @@ export type ListVolumesResponses = {
|
||||
server: string;
|
||||
port?: number;
|
||||
password?: string;
|
||||
readOnly?: boolean;
|
||||
ssl?: boolean;
|
||||
username?: string;
|
||||
};
|
||||
@@ -196,6 +202,8 @@ export type CreateVolumeData = {
|
||||
config:
|
||||
| {
|
||||
backend: "directory";
|
||||
path: string;
|
||||
readOnly?: false;
|
||||
}
|
||||
| {
|
||||
backend: "nfs";
|
||||
@@ -222,6 +230,7 @@ export type CreateVolumeData = {
|
||||
server: string;
|
||||
port?: number;
|
||||
password?: string;
|
||||
readOnly?: boolean;
|
||||
ssl?: boolean;
|
||||
username?: string;
|
||||
};
|
||||
@@ -241,6 +250,8 @@ export type CreateVolumeResponses = {
|
||||
config:
|
||||
| {
|
||||
backend: "directory";
|
||||
path: string;
|
||||
readOnly?: false;
|
||||
}
|
||||
| {
|
||||
backend: "nfs";
|
||||
@@ -267,6 +278,7 @@ export type CreateVolumeResponses = {
|
||||
server: string;
|
||||
port?: number;
|
||||
password?: string;
|
||||
readOnly?: boolean;
|
||||
ssl?: boolean;
|
||||
username?: string;
|
||||
};
|
||||
@@ -288,6 +300,8 @@ export type TestConnectionData = {
|
||||
config:
|
||||
| {
|
||||
backend: "directory";
|
||||
path: string;
|
||||
readOnly?: false;
|
||||
}
|
||||
| {
|
||||
backend: "nfs";
|
||||
@@ -314,6 +328,7 @@ export type TestConnectionData = {
|
||||
server: string;
|
||||
port?: number;
|
||||
password?: string;
|
||||
readOnly?: boolean;
|
||||
ssl?: boolean;
|
||||
username?: string;
|
||||
};
|
||||
@@ -386,6 +401,8 @@ export type GetVolumeResponses = {
|
||||
config:
|
||||
| {
|
||||
backend: "directory";
|
||||
path: string;
|
||||
readOnly?: false;
|
||||
}
|
||||
| {
|
||||
backend: "nfs";
|
||||
@@ -412,6 +429,7 @@ export type GetVolumeResponses = {
|
||||
server: string;
|
||||
port?: number;
|
||||
password?: string;
|
||||
readOnly?: boolean;
|
||||
ssl?: boolean;
|
||||
username?: string;
|
||||
};
|
||||
@@ -435,6 +453,8 @@ export type UpdateVolumeData = {
|
||||
config?:
|
||||
| {
|
||||
backend: "directory";
|
||||
path: string;
|
||||
readOnly?: false;
|
||||
}
|
||||
| {
|
||||
backend: "nfs";
|
||||
@@ -461,6 +481,7 @@ export type UpdateVolumeData = {
|
||||
server: string;
|
||||
port?: number;
|
||||
password?: string;
|
||||
readOnly?: boolean;
|
||||
ssl?: boolean;
|
||||
username?: string;
|
||||
};
|
||||
@@ -488,6 +509,8 @@ export type UpdateVolumeResponses = {
|
||||
config:
|
||||
| {
|
||||
backend: "directory";
|
||||
path: string;
|
||||
readOnly?: false;
|
||||
}
|
||||
| {
|
||||
backend: "nfs";
|
||||
@@ -514,6 +537,7 @@ export type UpdateVolumeResponses = {
|
||||
server: string;
|
||||
port?: number;
|
||||
password?: string;
|
||||
readOnly?: boolean;
|
||||
ssl?: boolean;
|
||||
username?: string;
|
||||
};
|
||||
@@ -962,12 +986,11 @@ export type DoctorRepositoryResponses = {
|
||||
* Doctor operation completed
|
||||
*/
|
||||
200: {
|
||||
message: string;
|
||||
steps: Array<{
|
||||
error: string | null;
|
||||
output: string | null;
|
||||
step: string;
|
||||
success: boolean;
|
||||
error?: string;
|
||||
output?: string;
|
||||
}>;
|
||||
success: boolean;
|
||||
};
|
||||
@@ -1036,6 +1059,8 @@ export type ListBackupSchedulesResponses = {
|
||||
config:
|
||||
| {
|
||||
backend: "directory";
|
||||
path: string;
|
||||
readOnly?: false;
|
||||
}
|
||||
| {
|
||||
backend: "nfs";
|
||||
@@ -1062,6 +1087,7 @@ export type ListBackupSchedulesResponses = {
|
||||
server: string;
|
||||
port?: number;
|
||||
password?: string;
|
||||
readOnly?: boolean;
|
||||
ssl?: boolean;
|
||||
username?: string;
|
||||
};
|
||||
@@ -1219,6 +1245,8 @@ export type GetBackupScheduleResponses = {
|
||||
config:
|
||||
| {
|
||||
backend: "directory";
|
||||
path: string;
|
||||
readOnly?: false;
|
||||
}
|
||||
| {
|
||||
backend: "nfs";
|
||||
@@ -1245,6 +1273,7 @@ export type GetBackupScheduleResponses = {
|
||||
server: string;
|
||||
port?: number;
|
||||
password?: string;
|
||||
readOnly?: boolean;
|
||||
ssl?: boolean;
|
||||
username?: string;
|
||||
};
|
||||
@@ -1383,6 +1412,8 @@ export type GetBackupScheduleForVolumeResponses = {
|
||||
config:
|
||||
| {
|
||||
backend: "directory";
|
||||
path: string;
|
||||
readOnly?: false;
|
||||
}
|
||||
| {
|
||||
backend: "nfs";
|
||||
@@ -1409,6 +1440,7 @@ export type GetBackupScheduleForVolumeResponses = {
|
||||
server: string;
|
||||
port?: number;
|
||||
password?: string;
|
||||
readOnly?: boolean;
|
||||
ssl?: boolean;
|
||||
username?: string;
|
||||
};
|
||||
@@ -1468,6 +1500,35 @@ export type GetSystemInfoResponses = {
|
||||
|
||||
export type GetSystemInfoResponse = GetSystemInfoResponses[keyof GetSystemInfoResponses];
|
||||
|
||||
export type DownloadResticPasswordData = {
|
||||
body?: {
|
||||
password: string;
|
||||
};
|
||||
path?: never;
|
||||
query?: never;
|
||||
url: "/api/v1/system/restic-password";
|
||||
};
|
||||
|
||||
export type DownloadResticPasswordErrors = {
|
||||
/**
|
||||
* Authentication required or incorrect password
|
||||
*/
|
||||
401: {
|
||||
message?: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type DownloadResticPasswordError = DownloadResticPasswordErrors[keyof DownloadResticPasswordErrors];
|
||||
|
||||
export type DownloadResticPasswordResponses = {
|
||||
/**
|
||||
* Restic password file content
|
||||
*/
|
||||
200: string;
|
||||
};
|
||||
|
||||
export type DownloadResticPasswordResponse = DownloadResticPasswordResponses[keyof DownloadResticPasswordResponses];
|
||||
|
||||
export type ClientOptions = {
|
||||
baseUrl: "http://192.168.2.42:4096" | (string & {});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user