Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Http/Controllers/Api/Application/Servers/ServerManagementController.php
10277 views
1
<?php
2
3
namespace Pterodactyl\Http\Controllers\Api\Application\Servers;
4
5
use Illuminate\Http\Response;
6
use Pterodactyl\Models\Server;
7
use Pterodactyl\Services\Servers\SuspensionService;
8
use Pterodactyl\Services\Servers\ReinstallServerService;
9
use Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest;
10
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
11
12
class ServerManagementController extends ApplicationApiController
13
{
14
/**
15
* ServerManagementController constructor.
16
*/
17
public function __construct(
18
private ReinstallServerService $reinstallServerService,
19
private SuspensionService $suspensionService,
20
) {
21
parent::__construct();
22
}
23
24
/**
25
* Suspend a server on the Panel.
26
*
27
* @throws \Throwable
28
*/
29
public function suspend(ServerWriteRequest $request, Server $server): Response
30
{
31
$this->suspensionService->toggle($server);
32
33
return $this->returnNoContent();
34
}
35
36
/**
37
* Unsuspend a server on the Panel.
38
*
39
* @throws \Throwable
40
*/
41
public function unsuspend(ServerWriteRequest $request, Server $server): Response
42
{
43
$this->suspensionService->toggle($server, SuspensionService::ACTION_UNSUSPEND);
44
45
return $this->returnNoContent();
46
}
47
48
/**
49
* Mark a server as needing to be reinstalled.
50
*
51
* @throws \Pterodactyl\Exceptions\DisplayException
52
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
53
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
54
*/
55
public function reinstall(ServerWriteRequest $request, Server $server): Response
56
{
57
$this->reinstallServerService->handle($server);
58
59
return $this->returnNoContent();
60
}
61
}
62
63