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(
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) {

View File

@ -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);

View File

@ -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) {

View File

@ -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);