mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat(server): test mount endpoint
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user