Update command sending from server API to use new daemon code

This commit is contained in:
Dane Everitt 2019-09-05 21:11:19 -07:00
parent 161e0f6165
commit ee0da206c1
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 26 additions and 8 deletions

View file

@ -2,6 +2,27 @@
namespace Pterodactyl\Repositories\Wings;
use Webmozart\Assert\Assert;
use Pterodactyl\Models\Server;
use Psr\Http\Message\ResponseInterface;
class DaemonCommandRepository extends DaemonRepository
{
/**
* Sends a command or multiple commands to a running server instance.
*
* @param string|string[] $command
* @return \Psr\Http\Message\ResponseInterface
*/
public function send($command): ResponseInterface
{
Assert::isInstanceOf(Server::class, $this->server);
return $this->getHttpClient()->post(
sprintf('/api/servers/%s/commands', $this->server->uuid),
[
'json' => ['commands' => is_array($command) ? $command : [$command]],
]
);
}
}