fix: add per-type fallback for fetch_backups(), move agent types first in per-type lists
This commit is contained in:
@@ -204,11 +204,7 @@ class VeeamClient:
|
||||
|
||||
async def fetch_jobs(self) -> list[dict]:
|
||||
if self._is_v12():
|
||||
for path in (
|
||||
"/api/v1/jobs/states",
|
||||
"/api/v1/jobs",
|
||||
"/api/v1/backups",
|
||||
):
|
||||
for path in ("/api/v1/jobs/states", "/api/v1/jobs"):
|
||||
try:
|
||||
data = await self._fetch_json_list(path)
|
||||
if data:
|
||||
@@ -216,14 +212,14 @@ class VeeamClient:
|
||||
except Exception:
|
||||
continue
|
||||
for t in (
|
||||
"LinuxAgentBackup", "WindowsAgentBackup",
|
||||
"LinuxAgentBackupServerPolicy", "WindowsAgentBackupServerPolicy",
|
||||
"LinuxAgentBackupWorkstationPolicy", "WindowsAgentBackupWorkstationPolicy",
|
||||
"VSphereBackup", "HyperVBackup", "VSphereReplica",
|
||||
"CloudDirectorBackup", "EntraIDTenantBackup", "EntraIDAuditLogBackup",
|
||||
"FileBackupCopy", "LegacyBackupCopy", "BackupCopy",
|
||||
"WindowsAgentBackup", "LinuxAgentBackup", "ObjectStorageBackup",
|
||||
"EntraIDTenantBackupCopy", "SureBackupContentScan",
|
||||
"ObjectStorageBackup", "EntraIDTenantBackupCopy", "SureBackupContentScan",
|
||||
"CloudBackupAzure", "CloudBackupAWS", "CloudBackupGoogle",
|
||||
"WindowsAgentBackupWorkstationPolicy", "LinuxAgentBackupWorkstationPolicy",
|
||||
"WindowsAgentBackupServerPolicy", "LinuxAgentBackupServerPolicy",
|
||||
):
|
||||
for base in ("/api/v1/jobs/states", "/api/v1/jobs"):
|
||||
try:
|
||||
@@ -320,9 +316,35 @@ class VeeamClient:
|
||||
return []
|
||||
|
||||
async def fetch_backups(self) -> list[dict]:
|
||||
if self._is_v12():
|
||||
if not self._is_v12():
|
||||
return []
|
||||
try:
|
||||
return await self._fetch_json_list("/api/v1/backups")
|
||||
return []
|
||||
except Exception:
|
||||
pass
|
||||
seen: set[str] = set()
|
||||
all_backups: list[dict] = []
|
||||
backup_types = [
|
||||
"LinuxAgentBackup", "WindowsAgentBackup",
|
||||
"LinuxAgentBackupServerPolicy", "WindowsAgentBackupServerPolicy",
|
||||
"LinuxAgentBackupWorkstationPolicy", "WindowsAgentBackupWorkstationPolicy",
|
||||
"VSphereBackup", "HyperVBackup", "VSphereReplica",
|
||||
"CloudDirectorBackup", "EntraIDTenantBackup", "EntraIDAuditLogBackup",
|
||||
"FileBackupCopy", "LegacyBackupCopy", "BackupCopy",
|
||||
"ObjectStorageBackup", "EntraIDTenantBackupCopy", "SureBackupContentScan",
|
||||
"CloudBackupAzure", "CloudBackupAWS", "CloudBackupGoogle",
|
||||
]
|
||||
for t in backup_types:
|
||||
try:
|
||||
items = await self._fetch_json_list(f"/api/v1/backups?typeFilter={t}")
|
||||
for b in items:
|
||||
bid = b.get("id") or b.get("Id") or ""
|
||||
if bid and bid not in seen:
|
||||
seen.add(bid)
|
||||
all_backups.append(b)
|
||||
except Exception:
|
||||
continue
|
||||
return all_backups
|
||||
|
||||
async def fetch_restore_points(self, limit: int = 100) -> list[dict]:
|
||||
if self._is_v12():
|
||||
|
||||
Reference in New Issue
Block a user