Path: blob/1.0-develop/app/Repositories/Wings/DaemonConfigurationRepository.php
7460 views
<?php12namespace Pterodactyl\Repositories\Wings;34use Pterodactyl\Models\Node;5use Psr\Http\Message\ResponseInterface;6use GuzzleHttp\Exception\TransferException;7use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;89/**10* @method \Pterodactyl\Repositories\Wings\DaemonConfigurationRepository setNode(\Pterodactyl\Models\Node $node)11* @method \Pterodactyl\Repositories\Wings\DaemonConfigurationRepository setServer(\Pterodactyl\Models\Server $server)12*/13class DaemonConfigurationRepository extends DaemonRepository14{15/**16* Returns system information from the wings instance.17*18* @throws DaemonConnectionException19*/20public function getSystemInformation(?int $version = null): array21{22try {23$response = $this->getHttpClient()->get('/api/system' . (!is_null($version) ? '?v=' . $version : ''));24} catch (TransferException $exception) {25throw new DaemonConnectionException($exception);26}2728return json_decode($response->getBody()->__toString(), true);29}3031/**32* Updates the configuration information for a daemon. Updates the information for33* this instance using a passed-in model. This allows us to change plenty of information34* in the model, and still use the old, pre-update model to actually make the HTTP request.35*36* @throws DaemonConnectionException37*/38public function update(Node $node): ResponseInterface39{40try {41return $this->getHttpClient()->post(42'/api/update',43['json' => $node->getConfiguration()]44);45} catch (TransferException $exception) {46throw new DaemonConnectionException($exception);47}48}49}505152