Files
pterodactyl-panel/app/Http/Controllers/Api/Application/Servers/ServerManagementController.php
T

62 lines
1.7 KiB
PHP
Raw Normal View History

2018-01-20 13:48:02 -06:00
<?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
{
/**
2022-10-14 10:59:20 -06:00
* ServerManagementController constructor.
2018-01-20 13:48:02 -06:00
*/
2018-01-27 12:38:56 -06:00
public function __construct(
2022-10-14 10:59:20 -06:00
private ReinstallServerService $reinstallServerService,
2024-10-21 19:18:20 -06:00
private SuspensionService $suspensionService,
2018-01-27 12:38:56 -06:00
) {
2018-01-20 13:48:02 -06:00
parent::__construct();
}
/**
* Suspend a server on the Panel.
*
2019-12-22 13:45:40 -08:00
* @throws \Throwable
2018-01-20 13:48:02 -06:00
*/
public function suspend(ServerWriteRequest $request, Server $server): Response
2018-01-20 13:48:02 -06:00
{
2022-10-14 10:59:20 -06:00
$this->suspensionService->toggle($server);
2018-01-20 13:48:02 -06:00
return $this->returnNoContent();
}
/**
* Unsuspend a server on the Panel.
*
2019-12-22 13:45:40 -08:00
* @throws \Throwable
2018-01-20 13:48:02 -06:00
*/
public function unsuspend(ServerWriteRequest $request, Server $server): Response
2018-01-20 13:48:02 -06:00
{
$this->suspensionService->toggle($server, SuspensionService::ACTION_UNSUSPEND);
2018-01-20 13:48:02 -06:00
return $this->returnNoContent();
}
/**
* Mark a server as needing to be reinstalled.
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function reinstall(ServerWriteRequest $request, Server $server): Response
2018-01-20 13:48:02 -06:00
{
2020-10-05 21:54:29 -07:00
$this->reinstallServerService->handle($server);
2018-01-20 13:48:02 -06:00
return $this->returnNoContent();
}
}