Path: blob/1.0-develop/app/Repositories/Wings/DaemonCommandRepository.php
7460 views
<?php12namespace Pterodactyl\Repositories\Wings;34use Webmozart\Assert\Assert;5use Pterodactyl\Models\Server;6use Psr\Http\Message\ResponseInterface;7use GuzzleHttp\Exception\TransferException;8use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;910/**11* @method \Pterodactyl\Repositories\Wings\DaemonCommandRepository setNode(\Pterodactyl\Models\Node $node)12* @method \Pterodactyl\Repositories\Wings\DaemonCommandRepository setServer(\Pterodactyl\Models\Server $server)13*/14class DaemonCommandRepository extends DaemonRepository15{16/**17* Sends a command or multiple commands to a running server instance.18*19* @throws DaemonConnectionException20*/21public function send(array|string $command): ResponseInterface22{23Assert::isInstanceOf($this->server, Server::class);2425try {26return $this->getHttpClient()->post(27sprintf('/api/servers/%s/commands', $this->server->uuid),28[29'json' => ['commands' => is_array($command) ? $command : [$command]],30]31);32} catch (TransferException $exception) {33throw new DaemonConnectionException($exception);34}35}36}373839