feat(server): test mount endpoint

This commit is contained in:
Nicolas Meienberger
2025-09-02 22:52:44 +02:00
parent de0ae08008
commit 0c0a3b8581
9 changed files with 184 additions and 4 deletions

View File

@@ -1,11 +1,13 @@
// This file is auto-generated by @hey-api/openapi-ts
import { type Options, listVolumes, createVolume, deleteVolume } from "../sdk.gen";
import { type Options, listVolumes, createVolume, testConnection, deleteVolume } from "../sdk.gen";
import { queryOptions, type UseMutationOptions, type DefaultError } from "@tanstack/react-query";
import type {
ListVolumesData,
CreateVolumeData,
CreateVolumeResponse,
TestConnectionData,
TestConnectionResponse,
DeleteVolumeData,
DeleteVolumeResponse,
} from "../types.gen";
@@ -109,6 +111,46 @@ export const createVolumeMutation = (
return mutationOptions;
};
export const testConnectionQueryKey = (options?: Options<TestConnectionData>) =>
createQueryKey("testConnection", options);
/**
* Test connection to backend
*/
export const testConnectionOptions = (options?: Options<TestConnectionData>) => {
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<Options<TestConnectionData>>,
): UseMutationOptions<TestConnectionResponse, DefaultError, Options<TestConnectionData>> => {
const mutationOptions: UseMutationOptions<TestConnectionResponse, DefaultError, Options<TestConnectionData>> = {
mutationFn: async (localOptions) => {
const { data } = await testConnection({
...options,
...localOptions,
throwOnError: true,
});
return data;
},
};
return mutationOptions;
};
/**
* Delete a volume
*/