mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 01:15:22 +00:00
73 lines
1.7 KiB
TypeScript
73 lines
1.7 KiB
TypeScript
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
import sendRequest from "services";
|
|
import endpoints from "utilities/endpoints";
|
|
import { ILoadTeamPoliciesResponse, IPolicyFormData } from "interfaces/policy";
|
|
|
|
export default {
|
|
create: (data: IPolicyFormData) => {
|
|
const {
|
|
name,
|
|
description,
|
|
query,
|
|
team_id,
|
|
resolution,
|
|
platform,
|
|
critical,
|
|
} = data;
|
|
const { TEAMS } = endpoints;
|
|
const path = `${TEAMS}/${team_id}/policies`;
|
|
|
|
return sendRequest("POST", path, {
|
|
name,
|
|
description,
|
|
query,
|
|
resolution,
|
|
platform,
|
|
critical,
|
|
});
|
|
},
|
|
update: (id: number, data: IPolicyFormData) => {
|
|
const {
|
|
name,
|
|
description,
|
|
query,
|
|
team_id,
|
|
resolution,
|
|
platform,
|
|
critical,
|
|
} = data;
|
|
const { TEAMS } = endpoints;
|
|
const path = `${TEAMS}/${team_id}/policies/${id}`;
|
|
|
|
return sendRequest("PATCH", path, {
|
|
name,
|
|
description,
|
|
query,
|
|
resolution,
|
|
platform,
|
|
critical,
|
|
});
|
|
},
|
|
destroy: (team_id: number, ids: number[]) => {
|
|
const { TEAMS } = endpoints;
|
|
const path = `${TEAMS}/${team_id}/policies/delete`;
|
|
|
|
return sendRequest("POST", path, { ids });
|
|
},
|
|
load: (team_id: number, id: number) => {
|
|
const { TEAMS } = endpoints;
|
|
const path = `${TEAMS}/${team_id}/policies/${id}`;
|
|
|
|
return sendRequest("GET", path);
|
|
},
|
|
loadAll: (team_id?: number): Promise<ILoadTeamPoliciesResponse> => {
|
|
const { TEAMS } = endpoints;
|
|
const path = `${TEAMS}/${team_id}/policies`;
|
|
if (!team_id) {
|
|
throw new Error("Invalid team id");
|
|
}
|
|
|
|
return sendRequest("GET", path);
|
|
},
|
|
};
|