misc_pterodactyl-panel/app/Http/Controllers/Api/Application/Servers/ServerManagementController.php
2022-12-14 17:05:46 -07:00

59 lines
1.6 KiB
PHP

<?php
namespace Pterodactyl\Http\Controllers\Api\Application\Servers;
use Illuminate\Http\Response;
use Pterodactyl\Models\Server;
use Pterodactyl\Services\Servers\SuspensionService;
use Pterodactyl\Services\Servers\ReinstallServerService;
use Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest;
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
class ServerManagementController extends ApplicationApiController
{
/**
* SuspensionController constructor.
*/
public function __construct(
private ReinstallServerService $reinstallServerService,
private SuspensionService $suspensionService
) {
parent::__construct();
}
/**
* Suspend a server on the Panel.
*
* @throws \Throwable
*/
public function suspend(ServerWriteRequest $request, Server $server): Response
{
$this->suspensionService->toggle($server);
return $this->returnNoContent();
}
/**
* Unsuspend a server on the Panel.
*
* @throws \Throwable
*/
public function unsuspend(ServerWriteRequest $request, Server $server): Response
{
$this->suspensionService->toggle($server, SuspensionService::ACTION_UNSUSPEND);
return $this->returnNoContent();
}
/**
* Mark a server as needing to be reinstalled.
*
* @throws \Throwable
*/
public function reinstall(ServerWriteRequest $request, Server $server): Response
{
$this->reinstallServerService->handle($server);
return $this->returnNoContent();
}
}