Tweak backup agent interface (#130613)
* Tweak backup agent interface * Adjust kitchen_sink
This commit is contained in:
parent
e9247fb94b
commit
e8179f7a73
3 changed files with 14 additions and 14 deletions
|
@ -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."""
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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,
|
||||
*,
|
||||
|
|
Loading…
Add table
Reference in a new issue