Remove deprecated function calls
This commit is contained in:
parent
38feac9f0b
commit
336234843d
3 changed files with 9 additions and 87 deletions
|
@ -32,14 +32,10 @@ use Pterodactyl\Exceptions\DisplayException;
|
|||
class CommandRepository
|
||||
{
|
||||
protected $server;
|
||||
protected $node;
|
||||
protected $client;
|
||||
|
||||
public function __construct($server)
|
||||
{
|
||||
$this->server = ($server instanceof Models\Server) ? $server : Models\Server::findOrFail($server);
|
||||
$this->node = Models\Node::getByID($this->server->node);
|
||||
$this->client = Models\Node::guzzleRequest($this->server->node);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,15 +52,10 @@ class CommandRepository
|
|||
// Additionally not all calls to this will be from a logged in user.
|
||||
// (e.g. task queue or API)
|
||||
try {
|
||||
$response = $this->client->request('POST', '/server/command', [
|
||||
'headers' => [
|
||||
'X-Access-Token' => $this->server->daemonSecret,
|
||||
'X-Access-Server' => $this->server->uuid,
|
||||
],
|
||||
'json' => [
|
||||
'command' => $command,
|
||||
],
|
||||
]);
|
||||
$response = $this->server->node->guzzleClient([
|
||||
'X-Access-Token' => $this->server->daemonSecret,
|
||||
'X-Access-Server' => $this->server->uuid,
|
||||
])->request('POST', '/server/command', ['json' => ['command' => $command]]);
|
||||
|
||||
if ($response->getStatusCode() < 200 || $response->getStatusCode() >= 300) {
|
||||
throw new DisplayException('Command sending responded with a non-200 error code.');
|
||||
|
|
|
@ -31,14 +31,10 @@ use Pterodactyl\Exceptions\DisplayException;
|
|||
class PowerRepository
|
||||
{
|
||||
protected $server;
|
||||
protected $node;
|
||||
protected $client;
|
||||
|
||||
public function __construct($server)
|
||||
{
|
||||
$this->server = ($server instanceof Models\Server) ? $server : Models\Server::findOrFail($server);
|
||||
$this->node = Models\Node::getByID($this->server->node);
|
||||
$this->client = Models\Node::guzzleRequest($this->server->node);
|
||||
}
|
||||
|
||||
public function do($action)
|
||||
|
@ -48,15 +44,10 @@ class PowerRepository
|
|||
// Additionally not all calls to this will be from a logged in user.
|
||||
// (e.g. task queue or API)
|
||||
try {
|
||||
$response = $this->client->request('PUT', '/server/power', [
|
||||
'headers' => [
|
||||
'X-Access-Token' => $this->server->daemonSecret,
|
||||
'X-Access-Server' => $this->server->uuid,
|
||||
],
|
||||
'json' => [
|
||||
'action' => $action,
|
||||
],
|
||||
]);
|
||||
$response = $this->server->node->guzzleClient([
|
||||
'X-Access-Token' => $this->server->daemonSecret,
|
||||
'X-Access-Server' => $this->server->uuid,
|
||||
])->request('PUT', '/server/power', ['json' => ['action' => $action]]);
|
||||
|
||||
if ($response->getStatusCode() < 200 || $response->getStatusCode() >= 300) {
|
||||
throw new DisplayException('Power status responded with a non-200 error code.');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue