mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat: display containers using the volume
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
deleteVolume,
|
||||
getVolume,
|
||||
updateVolume,
|
||||
getContainersUsingVolume,
|
||||
mountVolume,
|
||||
unmountVolume,
|
||||
} from "../sdk.gen";
|
||||
@@ -23,6 +24,7 @@ import type {
|
||||
GetVolumeData,
|
||||
UpdateVolumeData,
|
||||
UpdateVolumeResponse,
|
||||
GetContainersUsingVolumeData,
|
||||
MountVolumeData,
|
||||
MountVolumeResponse,
|
||||
UnmountVolumeData,
|
||||
@@ -226,6 +228,27 @@ export const updateVolumeMutation = (
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getContainersUsingVolumeQueryKey = (options: Options<GetContainersUsingVolumeData>) =>
|
||||
createQueryKey("getContainersUsingVolume", options);
|
||||
|
||||
/**
|
||||
* Get containers using a volume by name
|
||||
*/
|
||||
export const getContainersUsingVolumeOptions = (options: Options<GetContainersUsingVolumeData>) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getContainersUsingVolume({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getContainersUsingVolumeQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
export const mountVolumeQueryKey = (options: Options<MountVolumeData>) => createQueryKey("mountVolume", options);
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,9 @@ import type {
|
||||
UpdateVolumeData,
|
||||
UpdateVolumeResponses,
|
||||
UpdateVolumeErrors,
|
||||
GetContainersUsingVolumeData,
|
||||
GetContainersUsingVolumeResponses,
|
||||
GetContainersUsingVolumeErrors,
|
||||
MountVolumeData,
|
||||
MountVolumeResponses,
|
||||
MountVolumeErrors,
|
||||
@@ -122,6 +125,22 @@ export const updateVolume = <ThrowOnError extends boolean = false>(
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Get containers using a volume by name
|
||||
*/
|
||||
export const getContainersUsingVolume = <ThrowOnError extends boolean = false>(
|
||||
options: Options<GetContainersUsingVolumeData, ThrowOnError>,
|
||||
) => {
|
||||
return (options.client ?? _heyApiClient).get<
|
||||
GetContainersUsingVolumeResponses,
|
||||
GetContainersUsingVolumeErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
url: "/api/v1/volumes/{name}/containers",
|
||||
...options,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Mount a volume
|
||||
*/
|
||||
|
||||
@@ -349,6 +349,39 @@ export type UpdateVolumeResponses = {
|
||||
|
||||
export type UpdateVolumeResponse = UpdateVolumeResponses[keyof UpdateVolumeResponses];
|
||||
|
||||
export type GetContainersUsingVolumeData = {
|
||||
body?: never;
|
||||
path: {
|
||||
name: string;
|
||||
};
|
||||
query?: never;
|
||||
url: "/api/v1/volumes/{name}/containers";
|
||||
};
|
||||
|
||||
export type GetContainersUsingVolumeErrors = {
|
||||
/**
|
||||
* Volume not found
|
||||
*/
|
||||
404: unknown;
|
||||
};
|
||||
|
||||
export type GetContainersUsingVolumeResponses = {
|
||||
/**
|
||||
* List of containers using the volume
|
||||
*/
|
||||
200: {
|
||||
containers: Array<{
|
||||
id: string;
|
||||
image: string;
|
||||
name: string;
|
||||
state: string;
|
||||
}>;
|
||||
};
|
||||
};
|
||||
|
||||
export type GetContainersUsingVolumeResponse =
|
||||
GetContainersUsingVolumeResponses[keyof GetContainersUsingVolumeResponses];
|
||||
|
||||
export type MountVolumeData = {
|
||||
body?: never;
|
||||
path: {
|
||||
|
||||
Reference in New Issue
Block a user