fix: api test
This commit is contained in:
@@ -1,18 +1,29 @@
|
||||
import { request } from '@umijs/max';
|
||||
import { InstanceTypeItem, ListItem } from '../config/types';
|
||||
|
||||
export const GPU_SERVICE_INSTANCES_API = (namespace: string) =>
|
||||
`/proxy/apis/worker.gpustack.ai/v1/namespaces/${namespace}/instances`;
|
||||
export const GPU_SERVICE_INSTANCES_API = (params: {
|
||||
namespace: string;
|
||||
clusterID?: number;
|
||||
}) =>
|
||||
`/clusters/${params.clusterID}/proxy/apis/worker.gpustack.ai/v1/namespaces/${params.namespace}/instances`;
|
||||
|
||||
export const GPU_SERVICE_INSTANCES_TYPE_API =
|
||||
'/proxy/apis/worker.gpustack.ai/v1/instancetypes';
|
||||
export const GPU_SERVICE_INSTANCES_TYPE_API = (params: {
|
||||
clusterID?: number;
|
||||
}) =>
|
||||
`/clusters/${params.clusterID}/proxy/apis/worker.gpustack.ai/v1/instancetypes`;
|
||||
|
||||
export async function queryGPUServiceInstances(
|
||||
params: Global.K8sSearchParams,
|
||||
params: Global.K8sSearchParams & {
|
||||
namespace: string;
|
||||
clusterID?: number;
|
||||
},
|
||||
options?: any
|
||||
) {
|
||||
return request<Global.K8sPageResponse<ListItem>>(
|
||||
GPU_SERVICE_INSTANCES_API(params.namespace || ''),
|
||||
GPU_SERVICE_INSTANCES_API({
|
||||
namespace: params.namespace,
|
||||
clusterID: params.clusterID
|
||||
}),
|
||||
{
|
||||
method: 'GET',
|
||||
params,
|
||||
@@ -24,27 +35,38 @@ export async function queryGPUServiceInstances(
|
||||
export async function createGPUServiceInstance(
|
||||
params: {
|
||||
namespace: string;
|
||||
clusterID?: number;
|
||||
data: Global.K8sCommonData;
|
||||
},
|
||||
option?: any
|
||||
) {
|
||||
return request<ListItem>(GPU_SERVICE_INSTANCES_API(params.namespace), {
|
||||
method: 'POST',
|
||||
data: params.data,
|
||||
cancelToken: option?.token
|
||||
});
|
||||
return request<ListItem>(
|
||||
GPU_SERVICE_INSTANCES_API({
|
||||
namespace: params.namespace,
|
||||
clusterID: params.clusterID
|
||||
}),
|
||||
{
|
||||
method: 'POST',
|
||||
data: params.data,
|
||||
cancelToken: option?.token
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export async function updateGPUServiceInstance(
|
||||
params: {
|
||||
namespace: string;
|
||||
clusterID?: number;
|
||||
id: number;
|
||||
data: Global.K8sCommonData;
|
||||
},
|
||||
option?: any
|
||||
) {
|
||||
return request<ListItem>(
|
||||
`${GPU_SERVICE_INSTANCES_API(params.namespace)}/${params.id}`,
|
||||
`${GPU_SERVICE_INSTANCES_API({
|
||||
namespace: params.namespace,
|
||||
clusterID: params.clusterID
|
||||
})}/${params.id}`,
|
||||
{
|
||||
method: 'PUT',
|
||||
data: params.data,
|
||||
@@ -56,12 +78,16 @@ export async function updateGPUServiceInstance(
|
||||
export async function deleteGPUServiceInstance(
|
||||
params: {
|
||||
namespace: string;
|
||||
clusterID?: number;
|
||||
id: number;
|
||||
},
|
||||
option?: any
|
||||
) {
|
||||
return request(
|
||||
`${GPU_SERVICE_INSTANCES_API(params.namespace)}/${params.id}`,
|
||||
`${GPU_SERVICE_INSTANCES_API({
|
||||
namespace: params.namespace,
|
||||
clusterID: params.clusterID
|
||||
})}/${params.id}`,
|
||||
{
|
||||
method: 'DELETE',
|
||||
cancelToken: option?.token
|
||||
@@ -72,11 +98,11 @@ export async function deleteGPUServiceInstance(
|
||||
// =========== Instance Types ===========
|
||||
|
||||
export async function queryGPUServiceInstanceTypes(
|
||||
params: Global.K8sSearchParams,
|
||||
params: Global.K8sSearchParams & { clusterID?: number },
|
||||
options?: any
|
||||
) {
|
||||
return request<Global.K8sPageResponse<InstanceTypeItem>>(
|
||||
GPU_SERVICE_INSTANCES_TYPE_API,
|
||||
GPU_SERVICE_INSTANCES_TYPE_API({ clusterID: params.clusterID }),
|
||||
{
|
||||
method: 'GET',
|
||||
params,
|
||||
@@ -88,11 +114,12 @@ export async function queryGPUServiceInstanceTypes(
|
||||
export async function queryGPUServiceInstanceTypeItems(
|
||||
params: {
|
||||
name: string;
|
||||
clusterID?: number;
|
||||
},
|
||||
options?: any
|
||||
) {
|
||||
return request<InstanceTypeItem>(
|
||||
`${GPU_SERVICE_INSTANCES_TYPE_API}/${params.name}`,
|
||||
`${GPU_SERVICE_INSTANCES_TYPE_API({ clusterID: params.clusterID })}/${params.name}`,
|
||||
{
|
||||
method: 'GET',
|
||||
params,
|
||||
|
||||
Reference in New Issue
Block a user