Tweak backup agent interface (#130613)

* Tweak backup agent interface

* Adjust kitchen_sink
This commit is contained in:
Erik Montnemery 2024-11-14 15:49:17 +01:00 committed by GitHub
parent e9247fb94b
commit e8179f7a73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 14 deletions

View file

@ -20,11 +20,9 @@ class UploadedBackup(BaseBackup):
class BackupAgent(abc.ABC):
"""Define the format that backup agents can have."""
"""Backup agent interface."""
def __init__(self, name: str) -> None:
"""Initialize the backup agent."""
self.name = name
name: str
@abc.abstractmethod
async def async_download_backup(
@ -36,9 +34,8 @@ class BackupAgent(abc.ABC):
) -> None:
"""Download a backup file.
The `id` parameter is the ID of the backup that was returned in async_list_backups.
The `path` parameter is the full file path to download the backup to.
:param id: The ID of the backup that was returned in async_list_backups.
:param path: The full file path to download the backup to.
"""
@abc.abstractmethod
@ -51,9 +48,8 @@ class BackupAgent(abc.ABC):
) -> None:
"""Upload a backup.
The `path` parameter is the full file path to the backup that should be uploaded.
The `metadata` parameter contains metadata about the backup that should be uploaded.
:param path: The full file path to the backup that should be uploaded.
:param metadata: Metadata about the backup that should be uploaded.
"""
@abc.abstractmethod
@ -62,12 +58,11 @@ class BackupAgent(abc.ABC):
class BackupAgentPlatformProtocol(Protocol):
"""Define the format that backup platforms can have."""
"""Define the format of backup platforms which implement backup agents."""
async def async_get_backup_agents(
self,
*,
hass: HomeAssistant,
**kwargs: Any,
) -> list[BackupAgent]:
"""Register the backup agent."""
"""Return a list of backup agents."""

View file

@ -29,7 +29,8 @@ class KitchenSinkBackupAgent(BackupAgent):
def __init__(self, name: str) -> None:
"""Initialize the kitchen sink backup sync agent."""
super().__init__(name)
super().__init__()
self.name = name
self._uploads = [
UploadedBackup(
id="def456",

View file

@ -30,6 +30,10 @@ TEST_BACKUP = Backup(
class BackupAgentTest(BackupAgent):
"""Test backup agent."""
def __init__(self, name: str) -> None:
"""Initialize the backup agent."""
self.name = name
async def async_download_backup(
self,
*,