mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat: edit volume
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import { type Options, listVolumes, createVolume, testConnection, deleteVolume } from "../sdk.gen";
|
||||
import {
|
||||
type Options,
|
||||
listVolumes,
|
||||
createVolume,
|
||||
testConnection,
|
||||
deleteVolume,
|
||||
getVolume,
|
||||
updateVolume,
|
||||
} from "../sdk.gen";
|
||||
import { queryOptions, type UseMutationOptions, type DefaultError } from "@tanstack/react-query";
|
||||
import type {
|
||||
ListVolumesData,
|
||||
@@ -10,6 +18,9 @@ import type {
|
||||
TestConnectionResponse,
|
||||
DeleteVolumeData,
|
||||
DeleteVolumeResponse,
|
||||
GetVolumeData,
|
||||
UpdateVolumeData,
|
||||
UpdateVolumeResponse,
|
||||
} from "../types.gen";
|
||||
import { client as _heyApiClient } from "../client.gen";
|
||||
|
||||
@@ -169,3 +180,42 @@ export const deleteVolumeMutation = (
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getVolumeQueryKey = (options: Options<GetVolumeData>) => createQueryKey("getVolume", options);
|
||||
|
||||
/**
|
||||
* Get a volume by name
|
||||
*/
|
||||
export const getVolumeOptions = (options: Options<GetVolumeData>) => {
|
||||
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<Options<UpdateVolumeData>>,
|
||||
): UseMutationOptions<UpdateVolumeResponse, DefaultError, Options<UpdateVolumeData>> => {
|
||||
const mutationOptions: UseMutationOptions<UpdateVolumeResponse, DefaultError, Options<UpdateVolumeData>> = {
|
||||
mutationFn: async (localOptions) => {
|
||||
const { data } = await updateVolume({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user