2019-09-06 03:33:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Repositories\Wings;
|
|
|
|
|
2019-09-06 04:41:20 +00:00
|
|
|
use Webmozart\Assert\Assert;
|
|
|
|
use Pterodactyl\Models\Server;
|
|
|
|
use Psr\Http\Message\ResponseInterface;
|
|
|
|
|
2019-09-06 03:33:27 +00:00
|
|
|
class DaemonPowerRepository extends DaemonRepository
|
|
|
|
{
|
2019-09-06 04:41:20 +00: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(
|
|
|
|
sprintf('/api/servers/%s/power', $this->server->id),
|
|
|
|
['json' => ['action' => $action]]
|
|
|
|
);
|
|
|
|
}
|
2019-09-06 03:33:27 +00:00
|
|
|
}
|