From c5294ec75455d4435383a778da73ba1cdb8f5d0c Mon Sep 17 00:00:00 2001 From: smolkik-code Date: Wed, 10 Jun 2026 13:51:09 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20align=20with=20v13=20OpenAPI=20spec=20?= =?UTF-8?q?=E2=80=94=20jobTypeFilter,=20protection=20groups,=20alarms=20re?= =?UTF-8?q?siliency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fetch_backups(): typeFilter → jobTypeFilter (spec parameter name fix) - fetch_protection_groups(): new method via /api/v1/agents/protectionGroups (spec-recommended replacement for deprecated protectedComputers) - fetch_alarms(): wrap in try/except — endpoint not in v13 spec, may 404 - _collect_instance(): fetch and expose protection_groups in response --- main.py | 8 ++++++++ veeam_client.py | 12 ++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index b2a781a..89e5dc8 100644 --- a/main.py +++ b/main.py @@ -189,6 +189,12 @@ async def _collect_instance(inst) -> dict | None: except Exception as e: errors.append(f"agents: {e}") + protection_groups = [] + try: + protection_groups = await client.fetch_protection_groups() + except Exception as e: + errors.append(f"protection groups: {e}") + try: agent_policies = await client.fetch_agent_policies() except Exception as e: @@ -297,6 +303,7 @@ async def _collect_instance(inst) -> dict | None: "alarms": alarms_data, "agents": agents_data, "agent_policies": agent_policies, + "protection_groups": protection_groups, "restore_points": restore_points[:50] if restore_points else [], } @@ -321,6 +328,7 @@ async def _collect_instance(inst) -> dict | None: "alarms": [], "agents": [], "agent_policies": [], + "protection_groups": [], "restore_points": [], } return error_result diff --git a/veeam_client.py b/veeam_client.py index a72385f..592f161 100644 --- a/veeam_client.py +++ b/veeam_client.py @@ -278,7 +278,10 @@ class VeeamClient: async def fetch_alarms(self) -> list[dict]: if self._is_v12(): - return await self._fetch_json_list("/api/v1/alarms") + try: + return await self._fetch_json_list("/api/v1/alarms") + except Exception: + return [] return [] async def fetch_backup_servers(self) -> list[dict]: @@ -291,6 +294,11 @@ class VeeamClient: return await self._fetch_json_list("/api/v1/agents/protectedComputers") return [] + async def fetch_protection_groups(self) -> list[dict]: + if self._is_v12(): + return await self._fetch_json_list("/api/v1/agents/protectionGroups") + return [] + async def fetch_agent_policies(self) -> list[dict]: if self._is_v12(): seen: set[str] = set() @@ -336,7 +344,7 @@ class VeeamClient: ] for t in backup_types: try: - items = await self._fetch_json_list(f"/api/v1/backups?typeFilter={t}") + items = await self._fetch_json_list(f"/api/v1/backups?jobTypeFilter={t}") for b in items: bid = b.get("id") or b.get("Id") or "" if bid and bid not in seen: