2019-09-06 05:33:27 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Repositories\Wings;
|
|
|
|
|
2019-09-06 06:41:20 +02:00
|
|
|
use Webmozart\Assert\Assert;
|
|
|
|
use Pterodactyl\Models\Server;
|
|
|
|
use Psr\Http\Message\ResponseInterface;
|
|
|
|
|
2019-09-06 05:33:27 +02:00
|
|
|
class DaemonPowerRepository extends DaemonRepository
|
|
|
|
{
|
2019-09-06 06:41:20 +02:00
|
|
|
/**
|
|
|
|
* Sends a power action to the server instance.
|
|
|
|
*
|
|
|
|
* @param string $action
|
|
|
|
* @return \Psr\Http\Message\ResponseInterface
|
|
|
|
*/
|
|
|
|
public function send(string $action): ResponseInterface
|
|
|
|
{
|
|
|
|
Assert::isInstanceOf($this->server, Server::class);
|
|
|
|
|
|
|
|
return $this->getHttpClient()->post(
|
2019-09-09 02:48:37 +02:00
|
|
|
sprintf('/api/servers/%s/power', $this->server->uuid),
|
2019-09-06 06:41:20 +02:00
|
|
|
['json' => ['action' => $action]]
|
|
|
|
);
|
|
|
|
}
|
2019-09-06 05:33:27 +02:00
|
|
|
}
|