Skip to content

Commit 445f4f0

Browse files
authored
feat(frontend): Create REST API for Model Registry Settings (#930)
Signed-off-by: Jenny <32821331+jenny-s51@users.noreply.github.com> delete shared k8s.ts
1 parent 5d8e9e1 commit 445f4f0

1 file changed

Lines changed: 105 additions & 1 deletion

File tree

  • clients/ui/frontend/src/app/api

clients/ui/frontend/src/app/api/k8s.ts

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import { APIOptions } from '~/shared/api/types';
22
import { handleRestFailures } from '~/shared/api/errorUtils';
3-
import { isModelRegistryResponse, restGET } from '~/shared/api/apiUtils';
3+
import {
4+
assembleModelRegistryBody,
5+
isModelRegistryResponse,
6+
restCREATE,
7+
restDELETE,
8+
restGET,
9+
restPATCH,
10+
} from '~/shared/api/apiUtils';
411
import { ModelRegistry } from '~/app/types';
512
import { BFF_API_VERSION } from '~/app/const';
613
import { URL_PREFIX } from '~/shared/utilities/const';
714
import { Namespace, UserSettings } from '~/shared/types';
15+
import { ModelRegistryKind } from '~/shared/k8sTypes';
816

917
export const getListModelRegistries =
1018
(hostPath: string, queryParams: Record<string, unknown> = {}) =>
@@ -41,3 +49,99 @@ export const getNamespaces =
4149
}
4250
throw new Error('Invalid response format');
4351
});
52+
53+
export const getModelRegistrySettings =
54+
(hostPath: string, queryParams: Record<string, unknown> = {}) =>
55+
(opts: APIOptions, modelRegistryId: string): Promise<ModelRegistryKind> =>
56+
handleRestFailures(
57+
restGET(
58+
hostPath,
59+
`${URL_PREFIX}/api/${BFF_API_VERSION}/settings/model_registry/${modelRegistryId}`,
60+
queryParams,
61+
opts,
62+
),
63+
).then((response) => {
64+
if (isModelRegistryResponse<ModelRegistryKind>(response)) {
65+
return response.data;
66+
}
67+
throw new Error('Invalid response format');
68+
});
69+
70+
export const listModelRegistrySettings =
71+
(hostPath: string, queryParams: Record<string, unknown> = {}) =>
72+
(opts: APIOptions): Promise<ModelRegistryKind[]> =>
73+
handleRestFailures(
74+
restGET(
75+
hostPath,
76+
`${URL_PREFIX}/api/${BFF_API_VERSION}/settings/model_registry`,
77+
queryParams,
78+
opts,
79+
),
80+
).then((response) => {
81+
if (isModelRegistryResponse<ModelRegistryKind[]>(response)) {
82+
return response.data;
83+
}
84+
throw new Error('Invalid response format');
85+
});
86+
87+
export const createModelRegistrySettings =
88+
(hostPath: string, queryParams: Record<string, unknown> = {}) =>
89+
(opts: APIOptions, data: ModelRegistryKind): Promise<ModelRegistryKind[]> =>
90+
handleRestFailures(
91+
restCREATE(
92+
hostPath,
93+
`${URL_PREFIX}/api/${BFF_API_VERSION}/settings/model_registry`,
94+
assembleModelRegistryBody(data),
95+
queryParams,
96+
opts,
97+
),
98+
).then((response) => {
99+
if (isModelRegistryResponse<ModelRegistryKind[]>(response)) {
100+
return response.data;
101+
}
102+
throw new Error('Invalid response format');
103+
});
104+
105+
export const deleteModelRegistrySettings =
106+
(hostPath: string, queryParams: Record<string, unknown> = {}) =>
107+
(
108+
opts: APIOptions,
109+
data: ModelRegistryKind,
110+
modelRegistryId: string,
111+
): Promise<ModelRegistryKind[]> =>
112+
handleRestFailures(
113+
restDELETE(
114+
hostPath,
115+
`${URL_PREFIX}/api/${BFF_API_VERSION}/settings/model_registry/${modelRegistryId}`,
116+
assembleModelRegistryBody(data),
117+
queryParams,
118+
opts,
119+
),
120+
).then((response) => {
121+
if (isModelRegistryResponse<ModelRegistryKind[]>(response)) {
122+
return response.data;
123+
}
124+
throw new Error('Invalid response format');
125+
});
126+
127+
export const patchModelRegistrySettings =
128+
(hostPath: string, queryParams: Record<string, unknown> = {}) =>
129+
(
130+
opts: APIOptions,
131+
data: ModelRegistryKind,
132+
modelRegistryId: string,
133+
): Promise<ModelRegistryKind[]> =>
134+
handleRestFailures(
135+
restPATCH(
136+
hostPath,
137+
`${URL_PREFIX}/api/${BFF_API_VERSION}/settings/model_registry/${modelRegistryId}`,
138+
assembleModelRegistryBody(data),
139+
queryParams,
140+
opts,
141+
),
142+
).then((response) => {
143+
if (isModelRegistryResponse<ModelRegistryKind[]>(response)) {
144+
return response.data;
145+
}
146+
throw new Error('Invalid response format');
147+
});

0 commit comments

Comments
 (0)