2019-09-06 03:33:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Repositories\Wings;
|
|
|
|
|
2020-04-11 23:33:15 +00:00
|
|
|
use Pterodactyl\Models\Node;
|
2022-10-14 16:59:20 +00:00
|
|
|
use Psr\Http\Message\ResponseInterface;
|
2019-12-10 05:05:39 +00:00
|
|
|
use GuzzleHttp\Exception\TransferException;
|
|
|
|
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
|
|
|
|
2019-09-06 03:33:27 +00:00
|
|
|
class DaemonConfigurationRepository extends DaemonRepository
|
|
|
|
{
|
2019-12-10 05:05:39 +00:00
|
|
|
/**
|
|
|
|
* Returns system information from the wings instance.
|
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
|
|
|
*/
|
2022-11-22 20:39:43 +00:00
|
|
|
public function getSystemInformation(?int $version = null): array
|
2019-12-10 05:05:39 +00:00
|
|
|
{
|
|
|
|
try {
|
2022-11-22 20:39:43 +00:00
|
|
|
$response = $this->getHttpClient()->get('/api/system' . (!is_null($version) ? '?v=' . $version : ''));
|
2019-12-10 05:05:39 +00:00
|
|
|
} catch (TransferException $exception) {
|
|
|
|
throw new DaemonConnectionException($exception);
|
|
|
|
}
|
|
|
|
|
|
|
|
return json_decode($response->getBody()->__toString(), true);
|
|
|
|
}
|
2020-04-10 22:15:38 +00:00
|
|
|
|
|
|
|
/**
|
2020-04-11 23:33:15 +00:00
|
|
|
* 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.
|
2020-04-10 22:15:38 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function update(Node $node): ResponseInterface
|
2020-04-10 22:15:38 +00:00
|
|
|
{
|
|
|
|
try {
|
|
|
|
return $this->getHttpClient()->post(
|
2021-01-23 20:33:34 +00:00
|
|
|
'/api/update',
|
|
|
|
['json' => $node->getConfiguration()]
|
2020-04-10 22:15:38 +00:00
|
|
|
);
|
|
|
|
} catch (TransferException $exception) {
|
|
|
|
throw new DaemonConnectionException($exception);
|
|
|
|
}
|
|
|
|
}
|
2019-09-06 03:33:27 +00:00
|
|
|
}
|