mirror of
https://github.com/pelican-dev/panel.git
synced 2026-05-04 18:00:48 +03:00
Switch namespace back to App
This commit is contained in:
46
app/Repositories/Daemon/DaemonConfigurationRepository.php
Normal file
46
app/Repositories/Daemon/DaemonConfigurationRepository.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Daemon;
|
||||
|
||||
use App\Models\Node;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use GuzzleHttp\Exception\TransferException;
|
||||
use App\Exceptions\Http\Connection\DaemonConnectionException;
|
||||
|
||||
class DaemonConfigurationRepository extends DaemonRepository
|
||||
{
|
||||
/**
|
||||
* Returns system information from the daemon instance.
|
||||
*
|
||||
* @throws \App\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function getSystemInformation(?int $version = null): array
|
||||
{
|
||||
try {
|
||||
$response = $this->getHttpClient()->get('/api/system' . (!is_null($version) ? '?v=' . $version : ''));
|
||||
} 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.
|
||||
*
|
||||
* @throws \App\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function update(Node $node): ResponseInterface
|
||||
{
|
||||
try {
|
||||
return $this->getHttpClient()->post(
|
||||
'/api/update',
|
||||
['json' => $node->getConfiguration()]
|
||||
);
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user