misc_pterodactyl-panel/app/Repositories/Wings/DaemonConfigurationRepository.php

48 lines
1.5 KiB
PHP
Raw Permalink Normal View History

<?php
namespace Pterodactyl\Repositories\Wings;
use Pterodactyl\Models\Node;
use GuzzleHttp\Exception\TransferException;
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
class DaemonConfigurationRepository extends DaemonRepository
{
/**
* Returns system information from the wings instance.
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function getSystemInformation(): array
{
try {
$response = $this->getHttpClient()->get('/api/system');
} catch (TransferException $exception) {
throw new DaemonConnectionException($exception);
}
return json_decode($response->getBody()->__toString(), true);
}
/**
* Updates the configuration information for a daemon. Updates the information for
* this instance using a passed-in model. This allows us to change plenty of information
* in the model, and still use the old, pre-update model to actually make the HTTP request.
*
* @return \Psr\Http\Message\ResponseInterface
2021-01-23 20:33:34 +00:00
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
2020-06-25 04:54:56 +00:00
public function update(Node $node)
{
try {
return $this->getHttpClient()->post(
2021-01-23 20:33:34 +00:00
'/api/update',
['json' => $node->getConfiguration()]
);
} catch (TransferException $exception) {
throw new DaemonConnectionException($exception);
}
}
}