misc_pterodactyl-panel/app/Http/Controllers/Api/Application/Servers/ServerManagementController.php

62 lines
1.7 KiB
PHP
Raw Normal View History

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
{
/**
* ServerManagementController constructor.
2018-01-20 19:48:02 +00:00
*/
public function __construct(
private ReinstallServerService $reinstallServerService,
private SuspensionService $suspensionService
) {
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
*/
public function suspend(ServerWriteRequest $request, Server $server): Response
2018-01-20 19:48:02 +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
*/
public function unsuspend(ServerWriteRequest $request, Server $server): Response
2018-01-20 19:48:02 +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.
*
* @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 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();
}
}