2019-09-05 20:33:27 -07:00
|
|
|
<?php
|
|
|
|
|
|
2024-03-12 22:39:16 -04:00
|
|
|
namespace App\Repositories\Daemon;
|
2019-09-05 20:33:27 -07:00
|
|
|
|
2024-03-12 22:39:16 -04:00
|
|
|
use App\Models\Node;
|
2025-01-07 22:58:04 +01:00
|
|
|
use Illuminate\Http\Client\ConnectionException;
|
2024-10-19 21:00:11 -04:00
|
|
|
use Illuminate\Http\Client\Response;
|
2019-12-09 21:05:39 -08:00
|
|
|
|
2019-09-05 20:33:27 -07:00
|
|
|
class DaemonConfigurationRepository extends DaemonRepository
|
|
|
|
|
{
|
2019-12-09 21:05:39 -08:00
|
|
|
/**
|
2024-03-12 22:39:16 -04:00
|
|
|
* Returns system information from the daemon instance.
|
2019-12-09 21:05:39 -08:00
|
|
|
*
|
2025-01-07 22:58:04 +01:00
|
|
|
* @throws ConnectionException
|
2019-12-09 21:05:39 -08:00
|
|
|
*/
|
2025-01-07 22:58:04 +01:00
|
|
|
public function getSystemInformation(): array
|
2019-12-09 21:05:39 -08:00
|
|
|
{
|
2025-01-07 22:58:04 +01:00
|
|
|
return $this->getHttpClient()
|
|
|
|
|
->connectTimeout(3)
|
|
|
|
|
->get('/api/system')->throw()->json();
|
2019-12-09 21:05:39 -08:00
|
|
|
}
|
2020-04-10 15:15:38 -07:00
|
|
|
|
|
|
|
|
/**
|
2020-04-11 16:33:15 -07: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 15:15:38 -07:00
|
|
|
*
|
2025-01-07 22:58:04 +01:00
|
|
|
* @throws ConnectionException
|
2020-04-10 15:15:38 -07:00
|
|
|
*/
|
2024-10-19 21:00:11 -04:00
|
|
|
public function update(Node $node): Response
|
2020-04-10 15:15:38 -07:00
|
|
|
{
|
2025-01-07 22:58:04 +01:00
|
|
|
return $this->getHttpClient()->post('/api/update', $node->getConfiguration());
|
2020-04-10 15:15:38 -07:00
|
|
|
}
|
2019-09-05 20:33:27 -07:00
|
|
|
}
|