fix: align with v13 OpenAPI spec — jobTypeFilter, protection groups, alarms resiliency

- 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
This commit is contained in:
2026-06-10 13:51:09 +07:00
parent 699ac3646a
commit c5294ec754
2 changed files with 18 additions and 2 deletions

View File

@@ -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

View File

@@ -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: