mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 15:16:33 +00:00
Add backup location to info/list API calls (#4346)
* Add backup location to info/list API calls * Requested adjustments
This commit is contained in:
parent
5d1ef34f17
commit
8b4e8e9804
@ -100,6 +100,7 @@ class APIBackups(CoreSysAttributes):
|
|||||||
ATTR_DATE: backup.date,
|
ATTR_DATE: backup.date,
|
||||||
ATTR_TYPE: backup.sys_type,
|
ATTR_TYPE: backup.sys_type,
|
||||||
ATTR_SIZE: backup.size,
|
ATTR_SIZE: backup.size,
|
||||||
|
ATTR_LOCATON: backup.location,
|
||||||
ATTR_PROTECTED: backup.protected,
|
ATTR_PROTECTED: backup.protected,
|
||||||
ATTR_COMPRESSED: backup.compressed,
|
ATTR_COMPRESSED: backup.compressed,
|
||||||
ATTR_CONTENT: {
|
ATTR_CONTENT: {
|
||||||
@ -172,6 +173,7 @@ class APIBackups(CoreSysAttributes):
|
|||||||
ATTR_PROTECTED: backup.protected,
|
ATTR_PROTECTED: backup.protected,
|
||||||
ATTR_SUPERVISOR_VERSION: backup.supervisor_version,
|
ATTR_SUPERVISOR_VERSION: backup.supervisor_version,
|
||||||
ATTR_HOMEASSISTANT: backup.homeassistant_version,
|
ATTR_HOMEASSISTANT: backup.homeassistant_version,
|
||||||
|
ATTR_LOCATON: backup.location,
|
||||||
ATTR_ADDONS: data_addons,
|
ATTR_ADDONS: data_addons,
|
||||||
ATTR_REPOSITORIES: backup.repositories,
|
ATTR_REPOSITORIES: backup.repositories,
|
||||||
ATTR_FOLDERS: backup.folders,
|
ATTR_FOLDERS: backup.folders,
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
from base64 import b64decode, b64encode
|
from base64 import b64decode, b64encode
|
||||||
from collections.abc import Awaitable
|
from collections.abc import Awaitable
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from functools import cached_property
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -150,6 +151,14 @@ class Backup(CoreSysAttributes):
|
|||||||
"""Set the Docker config data."""
|
"""Set the Docker config data."""
|
||||||
self._data[ATTR_DOCKER] = value
|
self._data[ATTR_DOCKER] = value
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def location(self) -> str | None:
|
||||||
|
"""Return the location of the backup."""
|
||||||
|
for backup_mount in self.sys_mounts.backup_mounts:
|
||||||
|
if self.tarfile.is_relative_to(backup_mount.local_where):
|
||||||
|
return backup_mount.name
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def size(self):
|
def size(self):
|
||||||
"""Return backup size."""
|
"""Return backup size."""
|
||||||
|
@ -95,6 +95,11 @@ async def test_backup_to_location(
|
|||||||
|
|
||||||
assert (tmp_supervisor_data / backup_dir / f"{slug}.tar").exists()
|
assert (tmp_supervisor_data / backup_dir / f"{slug}.tar").exists()
|
||||||
|
|
||||||
|
resp = await api_client.get(f"/backups/{slug}/info")
|
||||||
|
result = await resp.json()
|
||||||
|
assert result["result"] == "ok"
|
||||||
|
assert result["data"]["location"] == location
|
||||||
|
|
||||||
|
|
||||||
async def test_backup_to_default(
|
async def test_backup_to_default(
|
||||||
api_client: TestClient,
|
api_client: TestClient,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user