Adjust these

This commit is contained in:
Lance Pioch 2024-04-15 01:39:59 -04:00
parent 8ec4dc1b6e
commit b70ab0e6cc
4 changed files with 34 additions and 48 deletions

View File

@ -35,11 +35,9 @@ class DaemonBackupRepository extends DaemonRepository
return $this->getHttpClient()->post( return $this->getHttpClient()->post(
sprintf('/api/servers/%s/backup', $this->server->uuid), sprintf('/api/servers/%s/backup', $this->server->uuid),
[ [
'json' => [ 'adapter' => $this->adapter ?? config('backups.default'),
'adapter' => $this->adapter ?? config('backups.default'), 'uuid' => $backup->uuid,
'uuid' => $backup->uuid, 'ignore' => implode("\n", $backup->ignored_files),
'ignore' => implode("\n", $backup->ignored_files),
],
] ]
); );
} catch (TransferException $exception) { } catch (TransferException $exception) {
@ -60,11 +58,9 @@ class DaemonBackupRepository extends DaemonRepository
return $this->getHttpClient()->post( return $this->getHttpClient()->post(
sprintf('/api/servers/%s/backup/%s/restore', $this->server->uuid, $backup->uuid), sprintf('/api/servers/%s/backup/%s/restore', $this->server->uuid, $backup->uuid),
[ [
'json' => [ 'adapter' => $backup->disk,
'adapter' => $backup->disk, 'truncate_directory' => $truncate,
'truncate_directory' => $truncate, 'download_url' => $url ?? '',
'download_url' => $url ?? '',
],
] ]
); );
} catch (TransferException $exception) { } catch (TransferException $exception) {

View File

@ -39,7 +39,7 @@ class DaemonConfigurationRepository extends DaemonRepository
try { try {
return $this->getHttpClient()->post( return $this->getHttpClient()->post(
'/api/update', '/api/update',
['json' => $node->getConfiguration()] $node->getConfiguration(),
); );
} catch (TransferException $exception) { } catch (TransferException $exception) {
throw new DaemonConnectionException($exception); throw new DaemonConnectionException($exception);

View File

@ -103,10 +103,8 @@ class DaemonFileRepository extends DaemonRepository
return $this->getHttpClient()->post( return $this->getHttpClient()->post(
sprintf('/api/servers/%s/files/create-directory', $this->server->uuid), sprintf('/api/servers/%s/files/create-directory', $this->server->uuid),
[ [
'json' => [ 'name' => $name,
'name' => $name, 'path' => $path,
'path' => $path,
],
] ]
); );
} catch (TransferException $exception) { } catch (TransferException $exception) {
@ -151,9 +149,7 @@ class DaemonFileRepository extends DaemonRepository
return $this->getHttpClient()->post( return $this->getHttpClient()->post(
sprintf('/api/servers/%s/files/copy', $this->server->uuid), sprintf('/api/servers/%s/files/copy', $this->server->uuid),
[ [
'json' => [ 'location' => $location,
'location' => $location,
],
] ]
); );
} catch (TransferException $exception) { } catch (TransferException $exception) {
@ -174,10 +170,8 @@ class DaemonFileRepository extends DaemonRepository
return $this->getHttpClient()->post( return $this->getHttpClient()->post(
sprintf('/api/servers/%s/files/delete', $this->server->uuid), sprintf('/api/servers/%s/files/delete', $this->server->uuid),
[ [
'json' => [ 'root' => $root ?? '/',
'root' => $root ?? '/', 'files' => $files,
'files' => $files,
],
] ]
); );
} catch (TransferException $exception) { } catch (TransferException $exception) {
@ -195,18 +189,17 @@ class DaemonFileRepository extends DaemonRepository
Assert::isInstanceOf($this->server, Server::class); Assert::isInstanceOf($this->server, Server::class);
try { try {
$response = $this->getHttpClient()->post( $response = $this->getHttpClient()
sprintf('/api/servers/%s/files/compress', $this->server->uuid), // 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.
'json' => [ ->timeout(60 * 15)
->post(
sprintf('/api/servers/%s/files/compress', $this->server->uuid),
[
'root' => $root ?? '/', 'root' => $root ?? '/',
'files' => $files, '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) { } catch (TransferException $exception) {
throw new DaemonConnectionException($exception); throw new DaemonConnectionException($exception);
} }
@ -224,18 +217,17 @@ class DaemonFileRepository extends DaemonRepository
Assert::isInstanceOf($this->server, Server::class); Assert::isInstanceOf($this->server, Server::class);
try { try {
return $this->getHttpClient()->post( return $this->getHttpClient()
sprintf('/api/servers/%s/files/decompress', $this->server->uuid), // 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.
'json' => [ ->timeout((int) CarbonInterval::minutes(15)->totalSeconds)
->post(
sprintf('/api/servers/%s/files/decompress', $this->server->uuid),
[
'root' => $root ?? '/', 'root' => $root ?? '/',
'file' => $file, '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) { } catch (TransferException $exception) {
throw new DaemonConnectionException($exception); throw new DaemonConnectionException($exception);
} }
@ -254,10 +246,8 @@ class DaemonFileRepository extends DaemonRepository
return $this->getHttpClient()->post( return $this->getHttpClient()->post(
sprintf('/api/servers/%s/files/chmod', $this->server->uuid), sprintf('/api/servers/%s/files/chmod', $this->server->uuid),
[ [
'json' => [ 'root' => $root ?? '/',
'root' => $root ?? '/', 'files' => $files,
'files' => $files,
],
] ]
); );
} catch (TransferException $exception) { } catch (TransferException $exception) {
@ -286,7 +276,7 @@ class DaemonFileRepository extends DaemonRepository
return $this->getHttpClient()->post( return $this->getHttpClient()->post(
sprintf('/api/servers/%s/files/pull', $this->server->uuid), 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) { } catch (TransferException $exception) {

View File

@ -21,7 +21,7 @@ class DaemonPowerRepository extends DaemonRepository
try { try {
return $this->getHttpClient()->post( return $this->getHttpClient()->post(
sprintf('/api/servers/%s/power', $this->server->uuid), sprintf('/api/servers/%s/power', $this->server->uuid),
['json' => ['action' => $action]] ['action' => $action],
); );
} catch (TransferException $exception) { } catch (TransferException $exception) {
throw new DaemonConnectionException($exception); throw new DaemonConnectionException($exception);