diff --git a/aiohasupervisor/backups.py b/aiohasupervisor/backups.py index 2737368..2f6e50e 100644 --- a/aiohasupervisor/backups.py +++ b/aiohasupervisor/backups.py @@ -15,6 +15,7 @@ NewBackup, PartialBackupOptions, PartialRestoreOptions, + ReloadOptions, ) @@ -35,9 +36,11 @@ async def set_options(self, options: BackupsOptions) -> None: """Set options for backups.""" await self._client.post("backups/options", json=options.to_dict()) - async def reload(self) -> None: + async def reload(self, options: ReloadOptions | None = None) -> None: """Reload backups cache.""" - await self._client.post("backups/reload") + await self._client.post( + "backups/reload", json=options.to_dict() if options else None + ) async def freeze(self, options: FreezeOptions | None = None) -> None: """Start a freeze for external snapshot process.""" diff --git a/aiohasupervisor/models/__init__.py b/aiohasupervisor/models/__init__.py index 1a3614b..c7dfb65 100644 --- a/aiohasupervisor/models/__init__.py +++ b/aiohasupervisor/models/__init__.py @@ -40,6 +40,7 @@ NewBackup, PartialBackupOptions, PartialRestoreOptions, + ReloadOptions, ) from aiohasupervisor.models.discovery import ( Discovery, @@ -203,6 +204,7 @@ "NewBackup", "PartialBackupOptions", "PartialRestoreOptions", + "ReloadOptions", "Discovery", "DiscoveryConfig", "AccessPoint", diff --git a/aiohasupervisor/models/backups.py b/aiohasupervisor/models/backups.py index 4a81f53..b0fc058 100644 --- a/aiohasupervisor/models/backups.py +++ b/aiohasupervisor/models/backups.py @@ -48,6 +48,7 @@ class BackupBaseFields(ABC): type: BackupType size: float location: str | None + locations: list[str | None] protected: bool compressed: bool @@ -167,3 +168,11 @@ class FullRestoreOptions(Request): @dataclass(frozen=True, slots=True) class PartialRestoreOptions(FullRestoreOptions, PartialBackupRestoreOptions): """PartialRestoreOptions model.""" + + +@dataclass(frozen=True, slots=True) +class ReloadOptions(Request): + """ReloadOptions model.""" + + location: str | None + filename: str diff --git a/tests/test_backups.py b/tests/test_backups.py index 2eb8a91..6b00047 100644 --- a/tests/test_backups.py +++ b/tests/test_backups.py @@ -15,6 +15,7 @@ FullBackupOptions, PartialBackupOptions, PartialRestoreOptions, + ReloadOptions, ) from . import load_fixture @@ -79,6 +80,22 @@ async def test_backups_reload( } +async def test_backups_partial_reload( + responses: aioresponses, supervisor_client: SupervisorClient +) -> None: + """Test backups partial reload API.""" + responses.post(f"{SUPERVISOR_URL}/backups/reload", status=200) + assert ( + await supervisor_client.backups.reload( + ReloadOptions(location=None, filename="test.tar") + ) + is None + ) + assert responses.requests.keys() == { + ("POST", URL(f"{SUPERVISOR_URL}/backups/reload")) + } + + @pytest.mark.parametrize("options", [None, FreezeOptions(timeout=1000)]) async def test_backups_freeze( responses: aioresponses,