2020-03-19 05:28:32 +00:00
|
|
|
import { rawDataToServerTask, Task } from '@/api/server/schedules/getServerSchedules';
|
|
|
|
import http from '@/api/http';
|
|
|
|
|
|
|
|
interface Data {
|
|
|
|
action: string;
|
|
|
|
payload: string;
|
|
|
|
timeOffset: string | number;
|
2021-05-01 18:24:18 +00:00
|
|
|
continueOnFailure: boolean;
|
2020-03-19 05:28:32 +00:00
|
|
|
}
|
|
|
|
|
2021-05-01 18:24:18 +00:00
|
|
|
export default async (uuid: string, schedule: number, task: number | undefined, data: Data): Promise<Task> => {
|
2022-06-26 19:13:52 +00:00
|
|
|
const { data: response } = await http.post(
|
|
|
|
`/api/client/servers/${uuid}/schedules/${schedule}/tasks${task ? `/${task}` : ''}`,
|
|
|
|
{
|
|
|
|
action: data.action,
|
|
|
|
payload: data.payload,
|
|
|
|
continue_on_failure: data.continueOnFailure,
|
|
|
|
time_offset: data.timeOffset,
|
2022-11-25 20:25:03 +00:00
|
|
|
},
|
2022-06-26 19:13:52 +00:00
|
|
|
);
|
2021-05-01 18:24:18 +00:00
|
|
|
|
|
|
|
return rawDataToServerTask(response.attributes);
|
2020-03-19 05:28:32 +00:00
|
|
|
};
|