mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat: delete volume
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import { type Options, listVolumes, createVolume } from "../sdk.gen";
|
||||
import {
|
||||
queryOptions,
|
||||
type UseMutationOptions,
|
||||
type DefaultError,
|
||||
} from "@tanstack/react-query";
|
||||
import { type Options, listVolumes, createVolume, deleteVolume } from "../sdk.gen";
|
||||
import { queryOptions, type UseMutationOptions, type DefaultError } from "@tanstack/react-query";
|
||||
import type {
|
||||
ListVolumesData,
|
||||
CreateVolumeData,
|
||||
CreateVolumeResponse,
|
||||
DeleteVolumeData,
|
||||
DeleteVolumeResponse,
|
||||
} from "../types.gen";
|
||||
import { client as _heyApiClient } from "../client.gen";
|
||||
|
||||
@@ -29,9 +27,7 @@ const createQueryKey = <TOptions extends Options>(
|
||||
): [QueryKey<TOptions>[0]] => {
|
||||
const params: QueryKey<TOptions>[0] = {
|
||||
_id: id,
|
||||
baseUrl:
|
||||
options?.baseUrl ||
|
||||
(options?.client ?? _heyApiClient).getConfig().baseUrl,
|
||||
baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl,
|
||||
} as QueryKey<TOptions>[0];
|
||||
if (infinite) {
|
||||
params._infinite = infinite;
|
||||
@@ -54,8 +50,7 @@ const createQueryKey = <TOptions extends Options>(
|
||||
return [params];
|
||||
};
|
||||
|
||||
export const listVolumesQueryKey = (options?: Options<ListVolumesData>) =>
|
||||
createQueryKey("listVolumes", options);
|
||||
export const listVolumesQueryKey = (options?: Options<ListVolumesData>) => createQueryKey("listVolumes", options);
|
||||
|
||||
/**
|
||||
* List all volumes
|
||||
@@ -75,8 +70,7 @@ export const listVolumesOptions = (options?: Options<ListVolumesData>) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const createVolumeQueryKey = (options?: Options<CreateVolumeData>) =>
|
||||
createQueryKey("createVolume", options);
|
||||
export const createVolumeQueryKey = (options?: Options<CreateVolumeData>) => createQueryKey("createVolume", options);
|
||||
|
||||
/**
|
||||
* Create a new volume
|
||||
@@ -101,16 +95,8 @@ export const createVolumeOptions = (options?: Options<CreateVolumeData>) => {
|
||||
*/
|
||||
export const createVolumeMutation = (
|
||||
options?: Partial<Options<CreateVolumeData>>,
|
||||
): UseMutationOptions<
|
||||
CreateVolumeResponse,
|
||||
DefaultError,
|
||||
Options<CreateVolumeData>
|
||||
> => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
CreateVolumeResponse,
|
||||
DefaultError,
|
||||
Options<CreateVolumeData>
|
||||
> = {
|
||||
): UseMutationOptions<CreateVolumeResponse, DefaultError, Options<CreateVolumeData>> => {
|
||||
const mutationOptions: UseMutationOptions<CreateVolumeResponse, DefaultError, Options<CreateVolumeData>> = {
|
||||
mutationFn: async (localOptions) => {
|
||||
const { data } = await createVolume({
|
||||
...options,
|
||||
@@ -122,3 +108,22 @@ export const createVolumeMutation = (
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete a volume
|
||||
*/
|
||||
export const deleteVolumeMutation = (
|
||||
options?: Partial<Options<DeleteVolumeData>>,
|
||||
): UseMutationOptions<DeleteVolumeResponse, DefaultError, Options<DeleteVolumeData>> => {
|
||||
const mutationOptions: UseMutationOptions<DeleteVolumeResponse, DefaultError, Options<DeleteVolumeData>> = {
|
||||
mutationFn: async (localOptions) => {
|
||||
const { data } = await deleteVolume({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user