// This file is auto-generated by @hey-api/openapi-ts import { type Options, register, login, logout, getMe, getStatus, listVolumes, createVolume, testConnection, deleteVolume, getVolume, updateVolume, getContainersUsingVolume, mountVolume, unmountVolume, healthCheckVolume, listFiles, listRepositories, createRepository, deleteRepository, getRepository, listSnapshots, listBackupSchedules, createBackupSchedule, deleteBackupSchedule, getBackupSchedule, updateBackupSchedule, runBackupNow, } from "../sdk.gen"; import { queryOptions, type UseMutationOptions, type DefaultError } from "@tanstack/react-query"; import type { RegisterData, RegisterResponse, LoginData, LoginResponse, LogoutData, LogoutResponse, GetMeData, GetStatusData, ListVolumesData, CreateVolumeData, CreateVolumeResponse, TestConnectionData, TestConnectionResponse, DeleteVolumeData, DeleteVolumeResponse, GetVolumeData, UpdateVolumeData, UpdateVolumeResponse, GetContainersUsingVolumeData, MountVolumeData, MountVolumeResponse, UnmountVolumeData, UnmountVolumeResponse, HealthCheckVolumeData, HealthCheckVolumeResponse, ListFilesData, ListRepositoriesData, CreateRepositoryData, CreateRepositoryResponse, DeleteRepositoryData, DeleteRepositoryResponse, GetRepositoryData, ListSnapshotsData, ListBackupSchedulesData, CreateBackupScheduleData, CreateBackupScheduleResponse, DeleteBackupScheduleData, DeleteBackupScheduleResponse, GetBackupScheduleData, UpdateBackupScheduleData, UpdateBackupScheduleResponse, RunBackupNowData, RunBackupNowResponse, } from "../types.gen"; import { client as _heyApiClient } from "../client.gen"; export type QueryKey = [ Pick & { _id: string; _infinite?: boolean; tags?: ReadonlyArray; }, ]; const createQueryKey = ( id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray, ): [QueryKey[0]] => { const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl, } as QueryKey[0]; if (infinite) { params._infinite = infinite; } if (tags) { params.tags = tags; } if (options?.body) { params.body = options.body; } if (options?.headers) { params.headers = options.headers; } if (options?.path) { params.path = options.path; } if (options?.query) { params.query = options.query; } return [params]; }; export const registerQueryKey = (options?: Options) => createQueryKey("register", options); /** * Register a new user */ export const registerOptions = (options?: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await register({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: registerQueryKey(options), }); }; /** * Register a new user */ export const registerMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (localOptions) => { const { data } = await register({ ...options, ...localOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const loginQueryKey = (options?: Options) => createQueryKey("login", options); /** * Login with username and password */ export const loginOptions = (options?: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await login({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: loginQueryKey(options), }); }; /** * Login with username and password */ export const loginMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (localOptions) => { const { data } = await login({ ...options, ...localOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const logoutQueryKey = (options?: Options) => createQueryKey("logout", options); /** * Logout current user */ export const logoutOptions = (options?: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await logout({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: logoutQueryKey(options), }); }; /** * Logout current user */ export const logoutMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (localOptions) => { const { data } = await logout({ ...options, ...localOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getMeQueryKey = (options?: Options) => createQueryKey("getMe", options); /** * Get current authenticated user */ export const getMeOptions = (options?: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await getMe({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getMeQueryKey(options), }); }; export const getStatusQueryKey = (options?: Options) => createQueryKey("getStatus", options); /** * Get authentication system status */ export const getStatusOptions = (options?: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await getStatus({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getStatusQueryKey(options), }); }; export const listVolumesQueryKey = (options?: Options) => createQueryKey("listVolumes", options); /** * List all volumes */ export const listVolumesOptions = (options?: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await listVolumes({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: listVolumesQueryKey(options), }); }; export const createVolumeQueryKey = (options?: Options) => createQueryKey("createVolume", options); /** * Create a new volume */ export const createVolumeOptions = (options?: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await createVolume({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: createVolumeQueryKey(options), }); }; /** * Create a new volume */ export const createVolumeMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (localOptions) => { const { data } = await createVolume({ ...options, ...localOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const testConnectionQueryKey = (options?: Options) => createQueryKey("testConnection", options); /** * Test connection to backend */ export const testConnectionOptions = (options?: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await testConnection({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: testConnectionQueryKey(options), }); }; /** * Test connection to backend */ export const testConnectionMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (localOptions) => { const { data } = await testConnection({ ...options, ...localOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Delete a volume */ export const deleteVolumeMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (localOptions) => { const { data } = await deleteVolume({ ...options, ...localOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getVolumeQueryKey = (options: Options) => createQueryKey("getVolume", options); /** * Get a volume by name */ export const getVolumeOptions = (options: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await getVolume({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getVolumeQueryKey(options), }); }; /** * Update a volume's configuration */ export const updateVolumeMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (localOptions) => { const { data } = await updateVolume({ ...options, ...localOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getContainersUsingVolumeQueryKey = (options: Options) => createQueryKey("getContainersUsingVolume", options); /** * Get containers using a volume by name */ export const getContainersUsingVolumeOptions = (options: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await getContainersUsingVolume({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getContainersUsingVolumeQueryKey(options), }); }; export const mountVolumeQueryKey = (options: Options) => createQueryKey("mountVolume", options); /** * Mount a volume */ export const mountVolumeOptions = (options: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await mountVolume({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: mountVolumeQueryKey(options), }); }; /** * Mount a volume */ export const mountVolumeMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (localOptions) => { const { data } = await mountVolume({ ...options, ...localOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const unmountVolumeQueryKey = (options: Options) => createQueryKey("unmountVolume", options); /** * Unmount a volume */ export const unmountVolumeOptions = (options: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await unmountVolume({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: unmountVolumeQueryKey(options), }); }; /** * Unmount a volume */ export const unmountVolumeMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (localOptions) => { const { data } = await unmountVolume({ ...options, ...localOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const healthCheckVolumeQueryKey = (options: Options) => createQueryKey("healthCheckVolume", options); /** * Perform a health check on a volume */ export const healthCheckVolumeOptions = (options: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await healthCheckVolume({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: healthCheckVolumeQueryKey(options), }); }; /** * Perform a health check on a volume */ export const healthCheckVolumeMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (localOptions) => { const { data } = await healthCheckVolume({ ...options, ...localOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const listFilesQueryKey = (options: Options) => createQueryKey("listFiles", options); /** * List files in a volume directory */ export const listFilesOptions = (options: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await listFiles({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: listFilesQueryKey(options), }); }; export const listRepositoriesQueryKey = (options?: Options) => createQueryKey("listRepositories", options); /** * List all repositories */ export const listRepositoriesOptions = (options?: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await listRepositories({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: listRepositoriesQueryKey(options), }); }; export const createRepositoryQueryKey = (options?: Options) => createQueryKey("createRepository", options); /** * Create a new restic repository */ export const createRepositoryOptions = (options?: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await createRepository({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: createRepositoryQueryKey(options), }); }; /** * Create a new restic repository */ export const createRepositoryMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (localOptions) => { const { data } = await createRepository({ ...options, ...localOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Delete a repository */ export const deleteRepositoryMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (localOptions) => { const { data } = await deleteRepository({ ...options, ...localOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getRepositoryQueryKey = (options: Options) => createQueryKey("getRepository", options); /** * Get a single repository by name */ export const getRepositoryOptions = (options: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await getRepository({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getRepositoryQueryKey(options), }); }; export const listSnapshotsQueryKey = (options: Options) => createQueryKey("listSnapshots", options); /** * List all snapshots in a repository */ export const listSnapshotsOptions = (options: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await listSnapshots({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: listSnapshotsQueryKey(options), }); }; export const listBackupSchedulesQueryKey = (options?: Options) => createQueryKey("listBackupSchedules", options); /** * List all backup schedules */ export const listBackupSchedulesOptions = (options?: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await listBackupSchedules({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: listBackupSchedulesQueryKey(options), }); }; export const createBackupScheduleQueryKey = (options?: Options) => createQueryKey("createBackupSchedule", options); /** * Create a new backup schedule for a volume */ export const createBackupScheduleOptions = (options?: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await createBackupSchedule({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: createBackupScheduleQueryKey(options), }); }; /** * Create a new backup schedule for a volume */ export const createBackupScheduleMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions< CreateBackupScheduleResponse, DefaultError, Options > = { mutationFn: async (localOptions) => { const { data } = await createBackupSchedule({ ...options, ...localOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; /** * Delete a backup schedule */ export const deleteBackupScheduleMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions< DeleteBackupScheduleResponse, DefaultError, Options > = { mutationFn: async (localOptions) => { const { data } = await deleteBackupSchedule({ ...options, ...localOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const getBackupScheduleQueryKey = (options: Options) => createQueryKey("getBackupSchedule", options); /** * Get a backup schedule by ID */ export const getBackupScheduleOptions = (options: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await getBackupSchedule({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: getBackupScheduleQueryKey(options), }); }; /** * Update a backup schedule */ export const updateBackupScheduleMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions< UpdateBackupScheduleResponse, DefaultError, Options > = { mutationFn: async (localOptions) => { const { data } = await updateBackupSchedule({ ...options, ...localOptions, throwOnError: true, }); return data; }, }; return mutationOptions; }; export const runBackupNowQueryKey = (options: Options) => createQueryKey("runBackupNow", options); /** * Trigger a backup immediately for a schedule */ export const runBackupNowOptions = (options: Options) => { return queryOptions({ queryFn: async ({ queryKey, signal }) => { const { data } = await runBackupNow({ ...options, ...queryKey[0], signal, throwOnError: true, }); return data; }, queryKey: runBackupNowQueryKey(options), }); }; /** * Trigger a backup immediately for a schedule */ export const runBackupNowMutation = ( options?: Partial>, ): UseMutationOptions> => { const mutationOptions: UseMutationOptions> = { mutationFn: async (localOptions) => { const { data } = await runBackupNow({ ...options, ...localOptions, throwOnError: true, }); return data; }, }; return mutationOptions; };