mirror of
https://github.com/home-assistant/core.git
synced 2025-08-16 02:51:40 +02:00
Tweak backup agent interface (#130613)
* Tweak backup agent interface * Adjust kitchen_sink
This commit is contained in:
@@ -20,11 +20,9 @@ class UploadedBackup(BaseBackup):
|
|||||||
|
|
||||||
|
|
||||||
class BackupAgent(abc.ABC):
|
class BackupAgent(abc.ABC):
|
||||||
"""Define the format that backup agents can have."""
|
"""Backup agent interface."""
|
||||||
|
|
||||||
def __init__(self, name: str) -> None:
|
name: str
|
||||||
"""Initialize the backup agent."""
|
|
||||||
self.name = name
|
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
async def async_download_backup(
|
async def async_download_backup(
|
||||||
@@ -36,9 +34,8 @@ class BackupAgent(abc.ABC):
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Download a backup file.
|
"""Download a backup file.
|
||||||
|
|
||||||
The `id` parameter is the ID of the backup that was returned in async_list_backups.
|
: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.
|
||||||
The `path` parameter is the full file path to download the backup to.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
@@ -51,9 +48,8 @@ class BackupAgent(abc.ABC):
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Upload a backup.
|
"""Upload a backup.
|
||||||
|
|
||||||
The `path` parameter is the full file path to 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.
|
||||||
The `metadata` parameter contains metadata about the backup that should be uploaded.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
@@ -62,12 +58,11 @@ class BackupAgent(abc.ABC):
|
|||||||
|
|
||||||
|
|
||||||
class BackupAgentPlatformProtocol(Protocol):
|
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(
|
async def async_get_backup_agents(
|
||||||
self,
|
self,
|
||||||
*,
|
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> list[BackupAgent]:
|
) -> 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:
|
def __init__(self, name: str) -> None:
|
||||||
"""Initialize the kitchen sink backup sync agent."""
|
"""Initialize the kitchen sink backup sync agent."""
|
||||||
super().__init__(name)
|
super().__init__()
|
||||||
|
self.name = name
|
||||||
self._uploads = [
|
self._uploads = [
|
||||||
UploadedBackup(
|
UploadedBackup(
|
||||||
id="def456",
|
id="def456",
|
||||||
|
@@ -30,6 +30,10 @@ TEST_BACKUP = Backup(
|
|||||||
class BackupAgentTest(BackupAgent):
|
class BackupAgentTest(BackupAgent):
|
||||||
"""Test backup agent."""
|
"""Test backup agent."""
|
||||||
|
|
||||||
|
def __init__(self, name: str) -> None:
|
||||||
|
"""Initialize the backup agent."""
|
||||||
|
self.name = name
|
||||||
|
|
||||||
async def async_download_backup(
|
async def async_download_backup(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
|
Reference in New Issue
Block a user