buster/web/src/api/busterv2/permission_groups/requests.ts

41 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-01-11 06:23:01 +08:00
import { mainApi } from '../../buster';
2025-01-15 01:30:13 +08:00
import { CreatePermissionGroupResponse, GetPermissionGroupResponse } from './responseInterfaces';
2025-01-11 06:23:01 +08:00
2025-01-15 01:30:13 +08:00
export const listAllPermissionGroups = async (): Promise<GetPermissionGroupResponse[]> => {
return await mainApi
.get<GetPermissionGroupResponse[]>(`/permission_groups`)
.then((res) => res.data);
2025-01-11 06:23:01 +08:00
};
export const getPermissionGroup = async ({
id
}: {
id: string;
}): Promise<GetPermissionGroupResponse> => {
return await mainApi.get(`/permission_groups/${id}`).then((res) => res.data);
};
2025-01-15 01:30:13 +08:00
export const updatePermissionGroups = async ({
2025-01-11 06:23:01 +08:00
id,
data
}: {
id: string;
data: { id: string; name: string }[];
}): Promise<void> => {
2025-01-11 06:54:39 +08:00
return await mainApi.put(`/permission_groups/${id}`, data).then((res) => res.data);
2025-01-11 06:23:01 +08:00
};
export const deletePermissionGroup = async ({ id }: { id: string }): Promise<void> => {
2025-01-11 06:54:39 +08:00
return await mainApi.delete(`/permission_groups/${id}`).then((res) => res.data);
2025-01-11 06:23:01 +08:00
};
2025-01-15 01:30:13 +08:00
export const createPermissionGroup = async ({
name
}: {
name: string;
}): Promise<CreatePermissionGroupResponse> => {
return await mainApi
.post<CreatePermissionGroupResponse>(`/permission_groups`, { name })
.then((res) => res.data);
2025-01-11 06:23:01 +08:00
};