From 0db2c114082ba157bc43013d14a84bb6e33e0f02 Mon Sep 17 00:00:00 2001 From: smolkik-code Date: Tue, 9 Jun 2026 17:24:58 +0700 Subject: [PATCH] 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 --- veeam_client.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/veeam_client.py b/veeam_client.py index 96850a5..2badb5a 100644 --- a/veeam_client.py +++ b/veeam_client.py @@ -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}",