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}",