2020-04-04 17:59:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Controllers\Api\Client\Servers;
|
|
|
|
|
|
|
|
use Pterodactyl\Models\Server;
|
2020-04-04 19:26:39 +00:00
|
|
|
use Pterodactyl\Services\Backups\InitiateBackupService;
|
2020-04-04 17:59:25 +00:00
|
|
|
use Pterodactyl\Transformers\Api\Client\BackupTransformer;
|
|
|
|
use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
|
|
|
|
use Pterodactyl\Http\Requests\Api\Client\Servers\Backups\GetBackupsRequest;
|
|
|
|
use Pterodactyl\Http\Requests\Api\Client\Servers\Backups\StoreBackupRequest;
|
|
|
|
|
|
|
|
class BackupController extends ClientApiController
|
|
|
|
{
|
2020-04-04 19:26:39 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Services\Backups\InitiateBackupService
|
|
|
|
*/
|
|
|
|
private $initiateBackupService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* BackupController constructor.
|
|
|
|
*
|
|
|
|
* @param \Pterodactyl\Services\Backups\InitiateBackupService $initiateBackupService
|
|
|
|
*/
|
|
|
|
public function __construct(InitiateBackupService $initiateBackupService)
|
2020-04-04 17:59:25 +00:00
|
|
|
{
|
|
|
|
parent::__construct();
|
2020-04-04 19:26:39 +00:00
|
|
|
|
|
|
|
$this->initiateBackupService = $initiateBackupService;
|
2020-04-04 17:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns all of the backups for a given server instance in a paginated
|
|
|
|
* result set.
|
|
|
|
*
|
|
|
|
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\GetBackupsRequest $request
|
|
|
|
* @param \Pterodactyl\Models\Server $server
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function index(GetBackupsRequest $request, Server $server)
|
|
|
|
{
|
|
|
|
return $this->fractal->collection($server->backups()->paginate(20))
|
|
|
|
->transformWith($this->getTransformer(BackupTransformer::class))
|
|
|
|
->toArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Starts the backup process for a server.
|
|
|
|
*
|
|
|
|
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\StoreBackupRequest $request
|
|
|
|
* @param \Pterodactyl\Models\Server $server
|
2020-04-04 19:26:39 +00:00
|
|
|
* @return array
|
|
|
|
*
|
|
|
|
* @throws \Exception
|
2020-04-04 17:59:25 +00:00
|
|
|
*/
|
|
|
|
public function store(StoreBackupRequest $request, Server $server)
|
|
|
|
{
|
2020-04-04 19:26:39 +00:00
|
|
|
$backup = $this->initiateBackupService
|
|
|
|
->setIgnoredFiles($request->input('ignored'))
|
|
|
|
->handle($server, $request->input('name'));
|
|
|
|
|
|
|
|
return $this->fractal->item($backup)
|
|
|
|
->transformWith($this->getTransformer(BackupTransformer::class))
|
|
|
|
->toArray();
|
2020-04-04 17:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function view()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function update()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function delete()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|