2018-01-20 19:48:02 +00: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-12-15 00:05:46 +00:00
|
|
|
* SuspensionController constructor.
|
2018-01-20 19:48:02 +00:00
|
|
|
*/
|
2018-01-27 18:38:56 +00:00
|
|
|
public function __construct(
|
2022-10-14 16:59:20 +00:00
|
|
|
private ReinstallServerService $reinstallServerService,
|
|
|
|
private SuspensionService $suspensionService
|
2018-01-27 18:38:56 +00:00
|
|
|
) {
|
2018-01-20 19:48:02 +00:00
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Suspend a server on the Panel.
|
|
|
|
*
|
2019-12-22 21:45:40 +00:00
|
|
|
* @throws \Throwable
|
2018-01-20 19:48:02 +00:00
|
|
|
*/
|
2019-11-30 23:37:13 +00:00
|
|
|
public function suspend(ServerWriteRequest $request, Server $server): Response
|
2018-01-20 19:48:02 +00:00
|
|
|
{
|
2022-10-14 16:59:20 +00:00
|
|
|
$this->suspensionService->toggle($server);
|
2018-01-20 19:48:02 +00:00
|
|
|
|
|
|
|
return $this->returnNoContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unsuspend a server on the Panel.
|
|
|
|
*
|
2019-12-22 21:45:40 +00:00
|
|
|
* @throws \Throwable
|
2018-01-20 19:48:02 +00:00
|
|
|
*/
|
2019-11-30 23:37:13 +00:00
|
|
|
public function unsuspend(ServerWriteRequest $request, Server $server): Response
|
2018-01-20 19:48:02 +00:00
|
|
|
{
|
2019-11-30 23:37:13 +00:00
|
|
|
$this->suspensionService->toggle($server, SuspensionService::ACTION_UNSUSPEND);
|
2018-01-20 19:48:02 +00:00
|
|
|
|
|
|
|
return $this->returnNoContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mark a server as needing to be reinstalled.
|
|
|
|
*
|
2022-12-15 00:05:46 +00:00
|
|
|
* @throws \Throwable
|
2018-01-20 19:48:02 +00:00
|
|
|
*/
|
2019-11-30 23:37:13 +00:00
|
|
|
public function reinstall(ServerWriteRequest $request, Server $server): Response
|
2018-01-20 19:48:02 +00:00
|
|
|
{
|
2020-10-06 04:54:29 +00:00
|
|
|
$this->reinstallServerService->handle($server);
|
2018-01-20 19:48:02 +00:00
|
|
|
|
|
|
|
return $this->returnNoContent();
|
|
|
|
}
|
|
|
|
}
|