You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.9 KiB
PHP
59 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Services\Cloud\CloudPortableRestoreCompatibility;
|
|
|
|
/** Portable system-disk backup stored outside its source host. */
|
|
final class CloudInstanceBackup extends Model
|
|
{
|
|
protected $connection = 'default';
|
|
protected $table = 'cloud_instance_backups';
|
|
protected $hidden = [
|
|
'sealed_credential', 'object_etag', 'object_version_id',
|
|
'delete_operation_id',
|
|
'create_request_actor_id', 'create_request_idempotency_key',
|
|
'create_request_fingerprint',
|
|
];
|
|
protected $casts = [
|
|
'id' => 'int',
|
|
'create_request_actor_id' => 'int',
|
|
'storage_artifact_id' => 'int',
|
|
'source_instance_id' => 'int',
|
|
'source_host_id' => 'int',
|
|
'user_id' => 'int',
|
|
'subscription_id' => 'int',
|
|
'scheduled_for' => 'int',
|
|
'object_size_bytes' => 'int',
|
|
'virtual_size_bytes' => 'int',
|
|
'storage_revision' => 'int',
|
|
'active_job_id' => 'int',
|
|
'delete_generation' => 'int',
|
|
'delete_cycle_attempts' => 'int',
|
|
'delete_presence_confirmations' => 'int',
|
|
'delete_requested_at' => 'int',
|
|
'delete_last_checked_at' => 'int',
|
|
'delete_next_check_at' => 'int',
|
|
'delete_attention_at' => 'int',
|
|
'ready_at' => 'int',
|
|
'created_at' => 'int',
|
|
'updated_at' => 'int',
|
|
];
|
|
|
|
/** A ready legacy row without exact Agent evidence is intentionally incompatible. */
|
|
public function sourcePortableRestoreCompatibility(): ?CloudPortableRestoreCompatibility
|
|
{
|
|
if ((string) $this->state !== 'ready') {
|
|
return null;
|
|
}
|
|
try {
|
|
return CloudPortableRestoreCompatibility::fromStored(
|
|
(string) $this->source_portable_restore_contract_json,
|
|
(string) $this->source_portable_restore_contract_sha256
|
|
);
|
|
} catch (\InvalidArgumentException) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|