fix: api test
This commit is contained in:
@@ -1,15 +1,27 @@
|
||||
import { request } from '@umijs/max';
|
||||
import { ListItem } from '../config/types';
|
||||
import { ListItem, StorageClassItem } from '../config/types';
|
||||
|
||||
export const GPU_SERVICE_STORAGE_API = (namespace: string) =>
|
||||
`/proxy/apis/worker.gpustack.ai/v1/namespaces/${namespace}/instancepersistentvolumes`;
|
||||
export const GPU_SERVICE_STORAGE_API = (params: {
|
||||
namespace: string;
|
||||
clusterID?: number;
|
||||
}) =>
|
||||
`/clusters/${params.clusterID}/proxy/apis/worker.gpustack.ai/v1/namespaces/${params.namespace}/instancepersistentvolumes`;
|
||||
|
||||
export const STORAGE_CLASS_API = (params: { clusterID?: number }) =>
|
||||
`/clusters/${params.clusterID}/proxy/apis/storage.k8s.io/v1/storageclasses`;
|
||||
|
||||
export async function queryGPUServiceStorage(
|
||||
params: Global.K8sSearchParams,
|
||||
params: Global.K8sSearchParams & {
|
||||
namespace: string;
|
||||
clusterID?: number;
|
||||
},
|
||||
options?: any
|
||||
) {
|
||||
return request<Global.K8sPageResponse<ListItem>>(
|
||||
GPU_SERVICE_STORAGE_API(params.namespace || ''),
|
||||
GPU_SERVICE_STORAGE_API({
|
||||
namespace: params.namespace,
|
||||
clusterID: params.clusterID
|
||||
}),
|
||||
{
|
||||
method: 'GET',
|
||||
params,
|
||||
@@ -21,27 +33,38 @@ export async function queryGPUServiceStorage(
|
||||
export async function createGPUServiceStorage(
|
||||
params: {
|
||||
namespace: string;
|
||||
clusterID?: number;
|
||||
data: Global.K8sCommonData;
|
||||
},
|
||||
option?: any
|
||||
) {
|
||||
return request<ListItem>(GPU_SERVICE_STORAGE_API(params.namespace), {
|
||||
method: 'POST',
|
||||
data: params.data,
|
||||
cancelToken: option?.token
|
||||
});
|
||||
return request<ListItem>(
|
||||
GPU_SERVICE_STORAGE_API({
|
||||
namespace: params.namespace,
|
||||
clusterID: params.clusterID
|
||||
}),
|
||||
{
|
||||
method: 'POST',
|
||||
data: params.data,
|
||||
cancelToken: option?.token
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export async function updateGPUServiceStorage(
|
||||
params: {
|
||||
namespace: string;
|
||||
clusterID?: number;
|
||||
id: number;
|
||||
data: Global.K8sCommonData;
|
||||
},
|
||||
option?: any
|
||||
) {
|
||||
return request<ListItem>(
|
||||
`${GPU_SERVICE_STORAGE_API(params.namespace)}/${params.id}`,
|
||||
`${GPU_SERVICE_STORAGE_API({
|
||||
namespace: params.namespace,
|
||||
clusterID: params.clusterID
|
||||
})}/${params.id}`,
|
||||
{
|
||||
method: 'PUT',
|
||||
data: params.data,
|
||||
@@ -52,9 +75,32 @@ export async function updateGPUServiceStorage(
|
||||
|
||||
export async function deleteGPUServiceStorage(params: {
|
||||
namespace: string;
|
||||
clusterID?: number;
|
||||
id: number;
|
||||
}) {
|
||||
return request(`${GPU_SERVICE_STORAGE_API(params.namespace)}/${params.id}`, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
return request(
|
||||
`${GPU_SERVICE_STORAGE_API({
|
||||
namespace: params.namespace,
|
||||
clusterID: params.clusterID
|
||||
})}/${params.id}`,
|
||||
{
|
||||
method: 'DELETE'
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export async function queryStorageClass(
|
||||
params: Global.K8sSearchParams & {
|
||||
clusterID?: number;
|
||||
},
|
||||
options?: any
|
||||
) {
|
||||
return request<Global.K8sPageResponse<StorageClassItem>>(
|
||||
STORAGE_CLASS_API({ clusterID: params.clusterID }),
|
||||
{
|
||||
method: 'GET',
|
||||
params,
|
||||
cancelToken: options?.token
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user