Add base logic to support sending a request to restore a backup for a server
This commit is contained in:
parent
805952ac38
commit
87371901c0
9 changed files with 229 additions and 237 deletions
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Repositories\Wings;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Webmozart\Assert\Assert;
|
||||
use Pterodactyl\Models\Backup;
|
||||
use Pterodactyl\Models\Server;
|
||||
|
@ -58,6 +57,36 @@ class DaemonBackupRepository extends DaemonRepository
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a request to Wings to begin restoring a backup for a server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Backup $backup
|
||||
* @param string|null $url
|
||||
* @param bool $truncate
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function restore(Backup $backup, string $url = null, bool $truncate = false): ResponseInterface
|
||||
{
|
||||
Assert::isInstanceOf($this->server, Server::class);
|
||||
|
||||
try {
|
||||
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 ?? '',
|
||||
],
|
||||
]
|
||||
);
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a backup from the daemon.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue