suspensionService->handle($server, SuspendAction::Suspend); return $this->returnNoContent(); } /** * Unsuspend a server on the Panel. * * @throws \Throwable */ public function unsuspend(ServerWriteRequest $request, Server $server): Response { $this->suspensionService->handle($server, SuspendAction::Unsuspend); return $this->returnNoContent(); } /** * Mark a server as needing to be reinstalled. * * @throws \App\Exceptions\DisplayException * @throws \App\Exceptions\Model\DataValidationException */ public function reinstall(ServerWriteRequest $request, Server $server): Response { $this->reinstallServerService->handle($server); return $this->returnNoContent(); } /** * Starts a transfer of a server to a new node. */ public function startTransfer(ServerWriteRequest $request, Server $server): Response { $validatedData = $request->validate([ 'node_id' => 'required|exists:nodes,id', 'allocation_id' => 'required|bail|unique:servers|exists:allocations,id', 'allocation_additional' => 'nullable', ]); if ($this->transferServerService->handle($server, $validatedData)) { // Transfer started return $this->returnNoContent(); } // Node was not viable return $this->returnNotAcceptable(); } /** * Cancels a transfer of a server to a new node. * * @throws ConnectionException */ public function cancelTransfer(ServerWriteRequest $request, Server $server): Response { if (!$transfer = $server->transfer) { // Server is not transferring return $this->returnNotAcceptable(); } $transfer->successful = true; $transfer->save(); $this->daemonServerRepository->setServer($server)->cancelTransfer(); return $this->returnNoContent(); } }