Skip to content

Commit 2078202

Browse files
authored
REST API for Model Registry RBAC (kubeflow#1201)
* REST API for Model Registry RBAC Signed-off-by: manaswinidas <dasmanaswini10@gmail.com> * Fix imports Signed-off-by: manaswinidas <dasmanaswini10@gmail.com> * Import from modarch shared library Signed-off-by: manaswinidas <dasmanaswini10@gmail.com> * Import from modarch shared library Signed-off-by: manaswinidas <dasmanaswini10@gmail.com> * Add patchRoleBinding Signed-off-by: manaswinidas <dasmanaswini10@gmail.com> * Address review comments Signed-off-by: manaswinidas <dasmanaswini10@gmail.com> --------- Signed-off-by: manaswinidas <dasmanaswini10@gmail.com>
1 parent 8b30b54 commit 2078202

File tree

1 file changed

+97
-0
lines changed
  • clients/ui/frontend/src/app/api

1 file changed

+97
-0
lines changed

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

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
restDELETE,
1111
restGET,
1212
restPATCH,
13+
GroupKind,
14+
RoleBindingKind,
1315
} from 'mod-arch-shared';
1416
import { ModelRegistry } from '~/app/types';
1517
import { BFF_API_VERSION, URL_PREFIX } from '~/app/utilities/const';
@@ -50,6 +52,47 @@ export const getNamespaces =
5052
throw new Error('Invalid response format');
5153
});
5254

55+
export const getNamespacesForSettings =
56+
(hostPath: string) =>
57+
(opts: APIOptions): Promise<Namespace[]> =>
58+
handleRestFailures(
59+
restGET(hostPath, `${URL_PREFIX}/api/${BFF_API_VERSION}/settings/namespaces`, {}, opts),
60+
).then((response) => {
61+
if (isModArchResponse<Namespace[]>(response)) {
62+
return response.data;
63+
}
64+
throw new Error('Invalid response format');
65+
});
66+
67+
export const getGroups =
68+
(hostPath: string) =>
69+
(opts: APIOptions): Promise<GroupKind[]> =>
70+
handleRestFailures(
71+
restGET(hostPath, `${URL_PREFIX}/api/${BFF_API_VERSION}/groups`, {}, opts),
72+
).then((response) => {
73+
if (isModArchResponse<GroupKind[]>(response)) {
74+
return response.data;
75+
}
76+
throw new Error('Invalid response format');
77+
});
78+
79+
export const getRoleBindings =
80+
(hostPath: string, queryParams: Record<string, unknown> = {}) =>
81+
(opts: APIOptions): Promise<RoleBindingKind[]> =>
82+
handleRestFailures(
83+
restGET(
84+
hostPath,
85+
`${URL_PREFIX}/api/${BFF_API_VERSION}/settings/role_bindings`,
86+
queryParams,
87+
opts,
88+
),
89+
).then((response) => {
90+
if (isModArchResponse<RoleBindingKind[]>(response)) {
91+
return response.data;
92+
}
93+
throw new Error('Invalid response format');
94+
});
95+
5396
export const getModelRegistrySettings =
5497
(hostPath: string, queryParams: Record<string, unknown> = {}) =>
5598
(opts: APIOptions, modelRegistryId: string): Promise<ModelRegistryKind> =>
@@ -145,3 +188,57 @@ export const patchModelRegistrySettings =
145188
}
146189
throw new Error('Invalid response format');
147190
});
191+
192+
export const createRoleBinding =
193+
(hostPath: string, queryParams: Record<string, unknown> = {}) =>
194+
(opts: APIOptions, data: RoleBindingKind): Promise<RoleBindingKind> =>
195+
handleRestFailures(
196+
restCREATE(
197+
hostPath,
198+
`${URL_PREFIX}/api/${BFF_API_VERSION}/settings/role_bindings`,
199+
assembleModArchBody(data),
200+
queryParams,
201+
opts,
202+
),
203+
).then((response) => {
204+
if (isModArchResponse<RoleBindingKind>(response)) {
205+
return response.data;
206+
}
207+
throw new Error('Invalid response format');
208+
});
209+
210+
export const patchRoleBinding =
211+
(hostPath: string, queryParams: Record<string, unknown> = {}) =>
212+
(opts: APIOptions, data: RoleBindingKind, roleBindingName: string): Promise<RoleBindingKind> =>
213+
handleRestFailures(
214+
restPATCH(
215+
hostPath,
216+
`${URL_PREFIX}/api/${BFF_API_VERSION}/settings/role_bindings/${roleBindingName}`,
217+
assembleModArchBody(data),
218+
queryParams,
219+
opts,
220+
),
221+
).then((response) => {
222+
if (isModArchResponse<RoleBindingKind>(response)) {
223+
return response.data;
224+
}
225+
throw new Error('Invalid response format');
226+
});
227+
228+
export const deleteRoleBinding =
229+
(hostPath: string, queryParams: Record<string, unknown> = {}) =>
230+
(opts: APIOptions, roleBindingName: string): Promise<void> =>
231+
handleRestFailures(
232+
restDELETE(
233+
hostPath,
234+
`${URL_PREFIX}/api/${BFF_API_VERSION}/settings/role_bindings/${roleBindingName}`,
235+
{},
236+
queryParams,
237+
opts,
238+
),
239+
).then((response) => {
240+
if (isModArchResponse<void>(response)) {
241+
return response.data;
242+
}
243+
throw new Error('Invalid response format');
244+
});

0 commit comments

Comments
 (0)