refactor: use rr actions/loader

refactor: use rr actions
This commit is contained in:
Nicolas Meienberger
2025-08-31 19:22:55 +02:00
parent 23f47bbb6b
commit 37effcb4e3
21 changed files with 454 additions and 219 deletions

View File

@@ -2,8 +2,10 @@
import type { Options as ClientOptions, TDataShape, Client } from "./client";
import type {
GetApiV1VolumesData,
GetApiV1VolumesResponses,
ListVolumesData,
ListVolumesResponses,
CreateVolumeData,
CreateVolumeResponses,
} from "./types.gen";
import { client as _heyApiClient } from "./client.gen";
@@ -27,11 +29,11 @@ export type Options<
/**
* List all volumes
*/
export const getApiV1Volumes = <ThrowOnError extends boolean = false>(
options?: Options<GetApiV1VolumesData, ThrowOnError>,
export const listVolumes = <ThrowOnError extends boolean = false>(
options?: Options<ListVolumesData, ThrowOnError>,
) => {
return (options?.client ?? _heyApiClient).get<
GetApiV1VolumesResponses,
ListVolumesResponses,
unknown,
ThrowOnError
>({
@@ -39,3 +41,23 @@ export const getApiV1Volumes = <ThrowOnError extends boolean = false>(
...options,
});
};
/**
* Create a new volume
*/
export const createVolume = <ThrowOnError extends boolean = false>(
options?: Options<CreateVolumeData, ThrowOnError>,
) => {
return (options?.client ?? _heyApiClient).post<
CreateVolumeResponses,
unknown,
ThrowOnError
>({
url: "/api/v1/volumes",
...options,
headers: {
"Content-Type": "application/json",
...options?.headers,
},
});
};