2018-03-01 04:51:04 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Controllers\Api\Client\Servers;
|
|
|
|
|
|
|
|
use Illuminate\Http\Response;
|
|
|
|
use Pterodactyl\Models\Server;
|
2019-09-06 04:41:20 +00:00
|
|
|
use Pterodactyl\Repositories\Wings\DaemonPowerRepository;
|
2018-03-01 04:51:04 +00:00
|
|
|
use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
|
|
|
|
use Pterodactyl\Http\Requests\Api\Client\Servers\SendPowerRequest;
|
|
|
|
|
|
|
|
class PowerController extends ClientApiController
|
|
|
|
{
|
|
|
|
/**
|
2019-09-06 04:41:20 +00:00
|
|
|
* @var \Pterodactyl\Repositories\Wings\DaemonPowerRepository
|
2018-03-01 04:51:04 +00:00
|
|
|
*/
|
|
|
|
private $repository;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PowerController constructor.
|
|
|
|
*/
|
2019-09-06 04:41:20 +00:00
|
|
|
public function __construct(DaemonPowerRepository $repository)
|
2018-03-01 04:51:04 +00:00
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->repository = $repository;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a power action to a server.
|
|
|
|
*
|
2020-07-15 04:16:38 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
2018-03-01 04:51:04 +00:00
|
|
|
*/
|
2019-09-06 04:41:20 +00:00
|
|
|
public function index(SendPowerRequest $request, Server $server): Response
|
2018-03-01 04:51:04 +00:00
|
|
|
{
|
2019-09-06 04:41:20 +00:00
|
|
|
$this->repository->setServer($server)->send(
|
|
|
|
$request->input('signal')
|
|
|
|
);
|
2018-03-01 04:51:04 +00:00
|
|
|
|
|
|
|
return $this->returnNoContent();
|
|
|
|
}
|
|
|
|
}
|