[ [ 'code' => 'ServiceLimitExceededException', 'status' => '400', 'detail' => 'Schedules may not have more than 10 tasks associated with them. Creating this task would put this schedule over the limit.', ], ], ]; /** * Create a new task for a given schedule and store it in the database. * * @throws ServiceLimitExceededException */ #[Endpoint('Create schedule task', 'Creates a task in a server schedule.')] #[ResponseFromResource(TaskResource::class, Task::class, description: 'Schedule task created.', resourceKey: 'schedule_task')] #[ScribeResponse(self::LIMIT_ERROR, status: 400, description: 'The schedule has reached its configured task limit.')] public function store(StoreTaskRequest $request, CreatesScheduleTasks $tasks, Server $server, Schedule $schedule): TaskResource { $task = $tasks->create($schedule, $request->actionInput()); return TaskResource::make($task); } /** * Updates a given task for a server. */ #[Endpoint('Update schedule task', 'Updates a task in a server schedule, including its sequence position.')] #[ResponseFromResource(TaskResource::class, Task::class, description: 'Schedule task updated.', resourceKey: 'schedule_task')] public function update(StoreTaskRequest $request, UpdatesScheduleTasks $tasks, Server $server, Schedule $schedule, Task $task): TaskResource { $task = $tasks->update($schedule, $task, $request->actionInput()); return TaskResource::make($task); } /** * Delete a given task for a schedule. If there are subsequent tasks stored in the database * for this schedule their sequence IDs are decremented properly. */ #[Endpoint('Delete schedule task', 'Deletes a task from a server schedule and compacts subsequent sequence IDs.')] #[ScribeResponse(status: 204, description: 'Schedule task deleted.')] public function delete(DeleteTaskRequest $request, DeletesScheduleTasks $tasks, Server $server, Schedule $schedule, Task $task): JsonResponse { $tasks->delete($schedule, $task); return new JsonResponse(null, Response::HTTP_NO_CONTENT); } }