From b70ab0e6ccd876b42529c81bcdab41284f89344c Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Mon, 15 Apr 2024 01:39:59 -0400 Subject: [PATCH] Adjust these --- .../Daemon/DaemonBackupRepository.php | 16 ++--- .../Daemon/DaemonConfigurationRepository.php | 2 +- .../Daemon/DaemonFileRepository.php | 62 ++++++++----------- .../Daemon/DaemonPowerRepository.php | 2 +- 4 files changed, 34 insertions(+), 48 deletions(-) diff --git a/app/Repositories/Daemon/DaemonBackupRepository.php b/app/Repositories/Daemon/DaemonBackupRepository.php index 355ebc1f0..bbe852e80 100644 --- a/app/Repositories/Daemon/DaemonBackupRepository.php +++ b/app/Repositories/Daemon/DaemonBackupRepository.php @@ -35,11 +35,9 @@ class DaemonBackupRepository extends DaemonRepository return $this->getHttpClient()->post( sprintf('/api/servers/%s/backup', $this->server->uuid), [ - 'json' => [ - 'adapter' => $this->adapter ?? config('backups.default'), - 'uuid' => $backup->uuid, - 'ignore' => implode("\n", $backup->ignored_files), - ], + 'adapter' => $this->adapter ?? config('backups.default'), + 'uuid' => $backup->uuid, + 'ignore' => implode("\n", $backup->ignored_files), ] ); } catch (TransferException $exception) { @@ -60,11 +58,9 @@ class DaemonBackupRepository extends DaemonRepository return $this->getHttpClient()->post( sprintf('/api/servers/%s/backup/%s/restore', $this->server->uuid, $backup->uuid), [ - 'json' => [ - 'adapter' => $backup->disk, - 'truncate_directory' => $truncate, - 'download_url' => $url ?? '', - ], + 'adapter' => $backup->disk, + 'truncate_directory' => $truncate, + 'download_url' => $url ?? '', ] ); } catch (TransferException $exception) { diff --git a/app/Repositories/Daemon/DaemonConfigurationRepository.php b/app/Repositories/Daemon/DaemonConfigurationRepository.php index 2b8de3b71..194119629 100644 --- a/app/Repositories/Daemon/DaemonConfigurationRepository.php +++ b/app/Repositories/Daemon/DaemonConfigurationRepository.php @@ -39,7 +39,7 @@ class DaemonConfigurationRepository extends DaemonRepository try { return $this->getHttpClient()->post( '/api/update', - ['json' => $node->getConfiguration()] + $node->getConfiguration(), ); } catch (TransferException $exception) { throw new DaemonConnectionException($exception); diff --git a/app/Repositories/Daemon/DaemonFileRepository.php b/app/Repositories/Daemon/DaemonFileRepository.php index a7d4f6e9a..ad1903a68 100644 --- a/app/Repositories/Daemon/DaemonFileRepository.php +++ b/app/Repositories/Daemon/DaemonFileRepository.php @@ -103,10 +103,8 @@ class DaemonFileRepository extends DaemonRepository return $this->getHttpClient()->post( sprintf('/api/servers/%s/files/create-directory', $this->server->uuid), [ - 'json' => [ - 'name' => $name, - 'path' => $path, - ], + 'name' => $name, + 'path' => $path, ] ); } catch (TransferException $exception) { @@ -151,9 +149,7 @@ class DaemonFileRepository extends DaemonRepository return $this->getHttpClient()->post( sprintf('/api/servers/%s/files/copy', $this->server->uuid), [ - 'json' => [ - 'location' => $location, - ], + 'location' => $location, ] ); } catch (TransferException $exception) { @@ -174,10 +170,8 @@ class DaemonFileRepository extends DaemonRepository return $this->getHttpClient()->post( sprintf('/api/servers/%s/files/delete', $this->server->uuid), [ - 'json' => [ - 'root' => $root ?? '/', - 'files' => $files, - ], + 'root' => $root ?? '/', + 'files' => $files, ] ); } catch (TransferException $exception) { @@ -195,18 +189,17 @@ class DaemonFileRepository extends DaemonRepository Assert::isInstanceOf($this->server, Server::class); try { - $response = $this->getHttpClient()->post( - sprintf('/api/servers/%s/files/compress', $this->server->uuid), - [ - 'json' => [ + $response = $this->getHttpClient() + // Wait for up to 15 minutes for the archive to be completed when calling this endpoint + // since it will likely take quite awhile for large directories. + ->timeout(60 * 15) + ->post( + sprintf('/api/servers/%s/files/compress', $this->server->uuid), + [ 'root' => $root ?? '/', 'files' => $files, - ], - // Wait for up to 15 minutes for the archive to be completed when calling this endpoint - // since it will likely take quite awhile for large directories. - 'timeout' => 60 * 15, - ] - ); + ] + ); } catch (TransferException $exception) { throw new DaemonConnectionException($exception); } @@ -224,18 +217,17 @@ class DaemonFileRepository extends DaemonRepository Assert::isInstanceOf($this->server, Server::class); try { - return $this->getHttpClient()->post( - sprintf('/api/servers/%s/files/decompress', $this->server->uuid), - [ - 'json' => [ + return $this->getHttpClient() + // Wait for up to 15 minutes for the decompress to be completed when calling this endpoint + // since it will likely take quite awhile for large directories. + ->timeout((int) CarbonInterval::minutes(15)->totalSeconds) + ->post( + sprintf('/api/servers/%s/files/decompress', $this->server->uuid), + [ 'root' => $root ?? '/', 'file' => $file, - ], - // Wait for up to 15 minutes for the decompress to be completed when calling this endpoint - // since it will likely take quite awhile for large directories. - 'timeout' => (int) CarbonInterval::minutes(15)->totalSeconds, - ] - ); + ] + ); } catch (TransferException $exception) { throw new DaemonConnectionException($exception); } @@ -254,10 +246,8 @@ class DaemonFileRepository extends DaemonRepository return $this->getHttpClient()->post( sprintf('/api/servers/%s/files/chmod', $this->server->uuid), [ - 'json' => [ - 'root' => $root ?? '/', - 'files' => $files, - ], + 'root' => $root ?? '/', + 'files' => $files, ] ); } catch (TransferException $exception) { @@ -286,7 +276,7 @@ class DaemonFileRepository extends DaemonRepository return $this->getHttpClient()->post( sprintf('/api/servers/%s/files/pull', $this->server->uuid), [ - 'json' => array_filter($attributes, fn ($value) => !is_null($value)), + array_filter($attributes, fn ($value) => !is_null($value)), ] ); } catch (TransferException $exception) { diff --git a/app/Repositories/Daemon/DaemonPowerRepository.php b/app/Repositories/Daemon/DaemonPowerRepository.php index c2a87a57d..ca3e03c44 100644 --- a/app/Repositories/Daemon/DaemonPowerRepository.php +++ b/app/Repositories/Daemon/DaemonPowerRepository.php @@ -21,7 +21,7 @@ class DaemonPowerRepository extends DaemonRepository try { return $this->getHttpClient()->post( sprintf('/api/servers/%s/power', $this->server->uuid), - ['json' => ['action' => $action]] + ['action' => $action], ); } catch (TransferException $exception) { throw new DaemonConnectionException($exception);