2020-04-04 10:59:25 -07:00
|
|
|
<?php
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2020-04-04 10:59:25 -07:00
|
|
|
namespace Pterodactyl\Http\Requests\Api\Client\Servers\Backups;
|
|
|
|
|
|
2026-10-11 09:31:53 -04:00
|
|
|
use Pterodactyl\Actions\Backups\InitiateBackup;
|
2026-10-05 18:10:18 -04:00
|
|
|
use Pterodactyl\Contracts\Http\ClientPermissionsRequest;
|
|
|
|
|
use Pterodactyl\Enum\Permissions;
|
2020-04-04 10:59:25 -07:00
|
|
|
use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
class StoreBackupRequest extends ClientApiRequest implements ClientPermissionsRequest
|
2020-04-04 10:59:25 -07:00
|
|
|
{
|
2022-10-14 10:59:20 -06:00
|
|
|
public function permission(): string
|
2020-04-04 10:59:25 -07:00
|
|
|
{
|
2026-10-05 18:10:18 -04:00
|
|
|
return Permissions::BackupCreate->value;
|
2020-04-04 10:59:25 -07:00
|
|
|
}
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
/**
|
2026-10-11 09:31:53 -04:00
|
|
|
* The backup's name and lock take the action's rules. The files to ignore are sent as
|
|
|
|
|
* one string, a file or folder per line, which ignoredFiles() splits into the list the
|
|
|
|
|
* action takes.
|
|
|
|
|
*
|
2026-10-05 18:10:18 -04:00
|
|
|
* @return ValidationRules
|
|
|
|
|
*/
|
2020-04-04 10:59:25 -07:00
|
|
|
public function rules(): array
|
|
|
|
|
{
|
2026-10-11 09:31:53 -04:00
|
|
|
$rules = InitiateBackup::rules();
|
|
|
|
|
|
2020-04-04 10:59:25 -07:00
|
|
|
return [
|
2026-10-11 09:31:53 -04:00
|
|
|
'name' => $rules['name'],
|
|
|
|
|
'is_locked' => $rules['is_locked'],
|
2026-10-05 18:10:18 -04:00
|
|
|
'ignored' => ['nullable', 'string'],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-10-11 09:31:53 -04:00
|
|
|
* The files and folders to leave out of the backup, one per line of the ignored field.
|
|
|
|
|
*
|
|
|
|
|
* @return list<string>
|
2026-10-05 18:10:18 -04:00
|
|
|
*/
|
2026-10-11 09:31:53 -04:00
|
|
|
public function ignoredFiles(): array
|
2026-10-05 18:10:18 -04:00
|
|
|
{
|
2026-10-11 09:31:53 -04:00
|
|
|
return explode(PHP_EOL, $this->safe()->string('ignored')->toString());
|
2020-04-04 10:59:25 -07:00
|
|
|
}
|
|
|
|
|
}
|