feat: add agent policies and session typeFilter fallbacks
- fetch_jobs: try /api/v1/agents/policies/states and /api/v1/agents/policies as additional fallback URLs (agent-based backup policies) - fetch_sessions: fallback with typeFilter=Backup and typeFilter=Agent to find actual backup/agent sessions beyond system config sync - New fetch_agent_policies() method for dedicated agent policy queries - Helps surface real backup policies when classic /api/v1/jobs fails due to FileBackup enum bug
This commit is contained in:
@@ -211,6 +211,8 @@ class VeeamClient:
|
||||
"/api/v1/jobs?source=Backup",
|
||||
"/api/v1/jobs/states?typeFilter=Backup",
|
||||
"/api/v1/jobs?typeFilter=Backup",
|
||||
"/api/v1/agents/policies/states",
|
||||
"/api/v1/agents/policies",
|
||||
):
|
||||
try:
|
||||
return await self._fetch_json_list(path)
|
||||
@@ -232,12 +234,21 @@ class VeeamClient:
|
||||
return [self._normalize_legacy_job(j) for j in jobs]
|
||||
except Exception:
|
||||
pass
|
||||
raise ConnectionError("all job endpoints failed (v12 REST + legacy XML)")
|
||||
raise ConnectionError("all job/policy endpoints failed (v12 REST + legacy XML)")
|
||||
return await self._fetch_legacy_jobs()
|
||||
|
||||
async def fetch_sessions(self, limit: int = 50) -> list[dict]:
|
||||
if self._is_v12():
|
||||
return await self._fetch_json_list(f"/api/v1/sessions?limit={limit}")
|
||||
for path in (
|
||||
f"/api/v1/sessions?limit={limit}",
|
||||
f"/api/v1/sessions?limit={limit}&typeFilter=Backup",
|
||||
f"/api/v1/sessions?limit={limit}&typeFilter=Agent",
|
||||
):
|
||||
try:
|
||||
return await self._fetch_json_list(path)
|
||||
except Exception:
|
||||
continue
|
||||
return []
|
||||
return await self._fetch_legacy_sessions(limit)
|
||||
|
||||
async def fetch_repositories(self) -> list[dict]:
|
||||
@@ -265,6 +276,18 @@ class VeeamClient:
|
||||
return await self._fetch_json_list("/api/v1/agents/protectedComputers")
|
||||
return []
|
||||
|
||||
async def fetch_agent_policies(self) -> list[dict]:
|
||||
if self._is_v12():
|
||||
for path in (
|
||||
"/api/v1/agents/policies/states",
|
||||
"/api/v1/agents/policies",
|
||||
):
|
||||
try:
|
||||
return await self._fetch_json_list(path)
|
||||
except Exception:
|
||||
continue
|
||||
return []
|
||||
|
||||
async def _fetch_json_list(self, path: str) -> list[dict]:
|
||||
resp = await self._http.get(
|
||||
f"{self.base_url}{path}",
|
||||
|
||||
Reference in New Issue
Block a user