// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';

/** 创建基础api POST /api/createApi */
export async function postApiCreateApi(body: API.Api, options?: { [key: string]: any }) {
  return request<API.Response & { msg?: string }>(`/api/v1/api/createApi`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 删除api DELETE /api/deleteApi */
export async function deleteApiDeleteApi(body: API.Api, options?: { [key: string]: any }) {
  return request<API.Response & { msg?: string }>(`/api/v1/api/deleteApi`, {
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 删除选中Api DELETE /api/deleteApisByIds */
export async function deleteApiDeleteApisByIds(body: API.IdsReq, options?: { [key: string]: any }) {
  return request<API.Response & { msg?: string }>(`/api/v1/api/deleteApisByIds`, {
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 刷新casbin缓存 GET /api/freshCasbin */
export async function getApiFreshCasbin(options?: { [key: string]: any }) {
  return request<API.Response & { msg?: string }>(`/api/v1/api/freshCasbin`, {
    method: 'GET',
    ...(options || {}),
  });
}

/** 获取所有的Api 不分页 POST /api/getAllApis */
export async function postApiGetAllApis(options?: { [key: string]: any }) {
  return request<API.Response & { data?: API.SysAPIListResponse; msg?: string }>(
    `/api/v1/api/getAllApis`,
    {
      method: 'POST',
      ...(options || {}),
    },
  );
}

/** 获取所有的Api 不分页 POST /api/getAllApisByGroup */
export async function postApiGetAllApisByGroup(options?: { [key: string]: any }) {
  return request<API.Response & { data?: API.SysAPIByGroupResponse; msg?: string }>(
    `/api/v1/api/getAllApisByGroup`,
    {
      method: 'POST',
      ...(options || {}),
    },
  );
}

/** 根据id获取api POST /api/getApiById */
export async function postApiGetApiById(body: API.GetById, options?: { [key: string]: any }) {
  return request<API.Response & { data?: API.SysAPIResponse }>(`/api/v1/api/getApiById`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 分页获取API列表 POST /api/getApiList */
export async function postApiGetApiList(
  body: API.SearchApiParams,
  options?: { [key: string]: any },
) {
  return request<API.Response & { data?: API.PageResult; msg?: string }>(`/api/v1/api/getApiList`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 修改基础api PUT /api/updateApi */
export async function putApiUpdateApi(body: API.Api, options?: { [key: string]: any }) {
  return request<API.Response & { msg?: string }>(`/api/v1/api/updateApi`, {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}
