2025-01-23 02:43:53 +08:00
|
|
|
import { serverFetch } from '@/api/createServerInstance';
|
2025-01-18 00:46:13 +08:00
|
|
|
import { mainApi } from '../instances';
|
2025-02-02 12:53:01 +08:00
|
|
|
import type {
|
2025-01-22 07:38:41 +08:00
|
|
|
DatasetGroup,
|
|
|
|
GetDatasetGroupPermissionGroupsResponse,
|
|
|
|
GetDatasetGroupDatasetsResponse,
|
2025-02-18 12:15:44 +08:00
|
|
|
GetDatasetGroupUsersResponse,
|
|
|
|
ListDatasetGroupsResponse
|
2025-02-02 12:53:01 +08:00
|
|
|
} from '../../asset_interfaces';
|
2025-01-11 06:54:39 +08:00
|
|
|
|
|
|
|
export const listDatasetGroups = async () => {
|
2025-02-18 12:15:44 +08:00
|
|
|
return mainApi.get<ListDatasetGroupsResponse[]>(`/dataset_groups`).then((res) => res.data);
|
2025-01-11 06:54:39 +08:00
|
|
|
};
|
|
|
|
|
2025-03-26 00:59:36 +08:00
|
|
|
export const createDatasetGroup = async (data: { name: string }) => {
|
2025-01-11 06:54:39 +08:00
|
|
|
return mainApi.post(`/dataset_groups`, data).then((res) => res.data);
|
|
|
|
};
|
|
|
|
|
2025-03-26 00:59:36 +08:00
|
|
|
export const updateDatasetGroup = async (
|
|
|
|
data: {
|
|
|
|
id: string;
|
|
|
|
name: string;
|
|
|
|
}[]
|
|
|
|
) => {
|
2025-01-11 07:10:50 +08:00
|
|
|
return mainApi.put(`/dataset_groups`, data).then((res) => res.data);
|
2025-01-11 06:54:39 +08:00
|
|
|
};
|
|
|
|
|
2025-03-29 03:49:19 +08:00
|
|
|
export const deleteDatasetGroup = async (data: string[]) => {
|
|
|
|
return mainApi.delete(`/dataset_groups`, { data }).then((res) => res.data);
|
2025-01-11 06:54:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export const getDatasetGroup = async (id: string) => {
|
2025-02-18 12:15:44 +08:00
|
|
|
return mainApi.get<DatasetGroup>(`/dataset_groups/${id}`).then((res) => res.data);
|
2025-01-11 06:54:39 +08:00
|
|
|
};
|
2025-01-22 07:38:41 +08:00
|
|
|
|
2025-01-23 02:43:53 +08:00
|
|
|
export const getDatasetGroup_server = async (id: string) => {
|
|
|
|
return serverFetch<DatasetGroup>(`/dataset_groups/${id}`);
|
|
|
|
};
|
|
|
|
|
2025-01-22 07:38:41 +08:00
|
|
|
export const getDatasetGroupUsers = async (id: string) => {
|
|
|
|
return mainApi
|
|
|
|
.get<GetDatasetGroupUsersResponse[]>(`/dataset_groups/${id}/users`)
|
|
|
|
.then((res) => res.data);
|
|
|
|
};
|
|
|
|
|
2025-01-23 02:43:53 +08:00
|
|
|
export const getDatasetGroupUsers_server = async (id: string) => {
|
|
|
|
return serverFetch<GetDatasetGroupUsersResponse[]>(`/dataset_groups/${id}/users`);
|
|
|
|
};
|
|
|
|
|
2025-01-22 07:38:41 +08:00
|
|
|
export const getDatasetGroupDatasets = async (id: string) => {
|
|
|
|
return mainApi
|
|
|
|
.get<GetDatasetGroupDatasetsResponse[]>(`/dataset_groups/${id}/datasets`)
|
|
|
|
.then((res) => res.data);
|
|
|
|
};
|
|
|
|
|
2025-01-23 02:43:53 +08:00
|
|
|
export const getDatasetGroupDatasets_server = async (id: string) => {
|
|
|
|
return serverFetch<GetDatasetGroupDatasetsResponse[]>(`/dataset_groups/${id}/datasets`);
|
|
|
|
};
|
|
|
|
|
2025-01-22 07:38:41 +08:00
|
|
|
export const getDatasetGroupPermissionGroups = async (id: string) => {
|
|
|
|
return mainApi
|
|
|
|
.get<GetDatasetGroupPermissionGroupsResponse[]>(`/dataset_groups/${id}/permission_groups`)
|
|
|
|
.then((res) => res.data);
|
|
|
|
};
|
|
|
|
|
2025-01-23 02:43:53 +08:00
|
|
|
export const getDatasetGroupPermissionGroups_server = async (id: string) => {
|
|
|
|
return serverFetch<GetDatasetGroupPermissionGroupsResponse[]>(
|
|
|
|
`/dataset_groups/${id}/permission_groups`
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2025-03-11 11:05:04 +08:00
|
|
|
export const updateDatasetGroupUsers = async ({
|
|
|
|
datasetGroupId,
|
|
|
|
data
|
|
|
|
}: {
|
|
|
|
datasetGroupId: string;
|
2025-03-26 00:59:36 +08:00
|
|
|
data: {
|
|
|
|
id: string;
|
|
|
|
assigned: boolean;
|
|
|
|
}[];
|
2025-03-11 11:05:04 +08:00
|
|
|
}) => {
|
|
|
|
return mainApi.put(`/dataset_groups/${datasetGroupId}/users`, data).then((res) => res.data);
|
2025-01-22 07:38:41 +08:00
|
|
|
};
|
|
|
|
|
2025-03-11 11:05:04 +08:00
|
|
|
export const updateDatasetGroupDatasets = async ({
|
|
|
|
datasetGroupId,
|
|
|
|
groups
|
|
|
|
}: {
|
|
|
|
datasetGroupId: string;
|
2025-03-26 00:59:36 +08:00
|
|
|
groups: {
|
|
|
|
id: string;
|
|
|
|
assigned: boolean;
|
|
|
|
}[];
|
2025-03-11 11:05:04 +08:00
|
|
|
}) => {
|
|
|
|
return mainApi.put(`/dataset_groups/${datasetGroupId}/datasets`, groups).then((res) => res.data);
|
2025-01-22 07:38:41 +08:00
|
|
|
};
|
|
|
|
|
2025-03-11 11:05:04 +08:00
|
|
|
export const updateDatasetGroupPermissionGroups = async ({
|
|
|
|
datasetGroupId,
|
|
|
|
data
|
|
|
|
}: {
|
|
|
|
datasetGroupId: string;
|
2025-03-26 00:59:36 +08:00
|
|
|
data: {
|
|
|
|
id: string;
|
|
|
|
assigned: boolean;
|
|
|
|
}[];
|
2025-03-11 11:05:04 +08:00
|
|
|
}) => {
|
|
|
|
return mainApi
|
|
|
|
.put(`/dataset_groups/${datasetGroupId}/permission_groups`, data)
|
|
|
|
.then((res) => res.data);
|
2025-01-22 07:38:41 +08:00
|
|
|
};
|