Deprecate old way of using repositories for daemon things
This commit is contained in:
parent
a9976c723e
commit
161e0f6165
17 changed files with 178 additions and 65 deletions
32
app/Repositories/Wings/DaemonServerRepository.php
Normal file
32
app/Repositories/Wings/DaemonServerRepository.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Repositories\Wings;
|
||||
|
||||
use Webmozart\Assert\Assert;
|
||||
use Pterodactyl\Models\Server;
|
||||
use GuzzleHttp\Exception\TransferException;
|
||||
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
||||
|
||||
class DaemonServerRepository extends DaemonRepository
|
||||
{
|
||||
/**
|
||||
* Returns details about a server from the Daemon instance.
|
||||
*
|
||||
* @return array
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function getDetails(): array
|
||||
{
|
||||
Assert::isInstanceOf(Server::class, $this->server);
|
||||
|
||||
try {
|
||||
$response = $this->getHttpClient()->get(
|
||||
sprintf('/api/servers/%s', $this->server->uuid)
|
||||
);
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
}
|
||||
|
||||
return json_decode($response->getBody()->__toString(), true);
|
||||
}
|
||||
}
|
Reference in a new issue