mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Remove snapshot from hassio integration (#57652)
This commit is contained in:
parent
5cd2167924
commit
24509503bb
@ -43,7 +43,6 @@ from .const import (
|
||||
ATTR_PASSWORD,
|
||||
ATTR_REPOSITORY,
|
||||
ATTR_SLUG,
|
||||
ATTR_SNAPSHOT,
|
||||
ATTR_URL,
|
||||
ATTR_VERSION,
|
||||
DOMAIN,
|
||||
@ -87,8 +86,6 @@ SERVICE_ADDON_UPDATE = "addon_update"
|
||||
SERVICE_ADDON_STDIN = "addon_stdin"
|
||||
SERVICE_HOST_SHUTDOWN = "host_shutdown"
|
||||
SERVICE_HOST_REBOOT = "host_reboot"
|
||||
SERVICE_SNAPSHOT_FULL = "snapshot_full"
|
||||
SERVICE_SNAPSHOT_PARTIAL = "snapshot_partial"
|
||||
SERVICE_BACKUP_FULL = "backup_full"
|
||||
SERVICE_BACKUP_PARTIAL = "backup_partial"
|
||||
SERVICE_RESTORE_FULL = "restore_full"
|
||||
@ -116,11 +113,9 @@ SCHEMA_BACKUP_PARTIAL = SCHEMA_BACKUP_FULL.extend(
|
||||
|
||||
SCHEMA_RESTORE_FULL = vol.Schema(
|
||||
{
|
||||
vol.Exclusive(ATTR_SLUG, ATTR_SLUG): cv.slug,
|
||||
vol.Exclusive(ATTR_SNAPSHOT, ATTR_SLUG): cv.slug,
|
||||
vol.Required(ATTR_SLUG): cv.slug,
|
||||
vol.Optional(ATTR_PASSWORD): cv.string,
|
||||
},
|
||||
cv.has_at_least_one_key(ATTR_SLUG, ATTR_SNAPSHOT),
|
||||
}
|
||||
)
|
||||
|
||||
SCHEMA_RESTORE_PARTIAL = SCHEMA_RESTORE_FULL.extend(
|
||||
@ -175,18 +170,6 @@ MAP_SERVICE_API = {
|
||||
None,
|
||||
True,
|
||||
),
|
||||
SERVICE_SNAPSHOT_FULL: APIEndpointSettings(
|
||||
"/backups/new/full",
|
||||
SCHEMA_BACKUP_FULL,
|
||||
None,
|
||||
True,
|
||||
),
|
||||
SERVICE_SNAPSHOT_PARTIAL: APIEndpointSettings(
|
||||
"/backups/new/partial",
|
||||
SCHEMA_BACKUP_PARTIAL,
|
||||
None,
|
||||
True,
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@ -489,22 +472,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa:
|
||||
"""Handle service calls for Hass.io."""
|
||||
api_endpoint = MAP_SERVICE_API[service.service]
|
||||
|
||||
if "snapshot" in service.service:
|
||||
_LOGGER.warning(
|
||||
"The service '%s' is deprecated and will be removed in Home Assistant 2021.11, use '%s' instead",
|
||||
service.service,
|
||||
service.service.replace("snapshot", "backup"),
|
||||
)
|
||||
data = service.data.copy()
|
||||
addon = data.pop(ATTR_ADDON, None)
|
||||
slug = data.pop(ATTR_SLUG, None)
|
||||
snapshot = data.pop(ATTR_SNAPSHOT, None)
|
||||
if snapshot is not None:
|
||||
_LOGGER.warning(
|
||||
"Using 'snapshot' is deprecated and will be removed in Home Assistant 2021.11, use 'slug' instead"
|
||||
)
|
||||
slug = snapshot
|
||||
|
||||
payload = None
|
||||
|
||||
# Pass data to Hass.io API
|
||||
|
@ -15,7 +15,6 @@ ATTR_HOMEASSISTANT = "homeassistant"
|
||||
ATTR_INPUT = "input"
|
||||
ATTR_PANELS = "panels"
|
||||
ATTR_PASSWORD = "password"
|
||||
ATTR_SNAPSHOT = "snapshot"
|
||||
ATTR_TITLE = "title"
|
||||
ATTR_USERNAME = "username"
|
||||
ATTR_UUID = "uuid"
|
||||
|
@ -38,15 +38,10 @@ NO_TIMEOUT = re.compile(
|
||||
r"|backups/.+/full"
|
||||
r"|backups/.+/partial"
|
||||
r"|backups/[^/]+/(?:upload|download)"
|
||||
r"|snapshots/.+/full"
|
||||
r"|snapshots/.+/partial"
|
||||
r"|snapshots/[^/]+/(?:upload|download)"
|
||||
r")$"
|
||||
)
|
||||
|
||||
NO_AUTH_ONBOARDING = re.compile(
|
||||
r"^(?:" r"|supervisor/logs" r"|backups/[^/]+/.+" r"|snapshots/[^/]+/.+" r")$"
|
||||
)
|
||||
NO_AUTH_ONBOARDING = re.compile(r"^(?:" r"|supervisor/logs" r"|backups/[^/]+/.+" r")$")
|
||||
|
||||
NO_AUTH = re.compile(
|
||||
r"^(?:" r"|app/.*" r"|addons/[^/]+/logo" r"|addons/[^/]+/icon" r")$"
|
||||
@ -89,7 +84,7 @@ class HassIOView(HomeAssistantView):
|
||||
This method is a coroutine.
|
||||
"""
|
||||
headers = _init_header(request)
|
||||
if path in ("snapshots/new/upload", "backups/new/upload"):
|
||||
if path == "backups/new/upload":
|
||||
# We need to reuse the full content type that includes the boundary
|
||||
headers[
|
||||
"Content-Type"
|
||||
|
@ -66,52 +66,6 @@ host_shutdown:
|
||||
name: Poweroff the host system.
|
||||
description: Poweroff the host system.
|
||||
|
||||
snapshot_full:
|
||||
name: Create a full backup.
|
||||
description: Create a full backup (deprecated, use backup_full instead).
|
||||
fields:
|
||||
name:
|
||||
name: Name
|
||||
description: Optional (default = current date and time).
|
||||
example: "Backup 1"
|
||||
selector:
|
||||
text:
|
||||
password:
|
||||
name: Password
|
||||
description: Optional password.
|
||||
example: "password"
|
||||
selector:
|
||||
text:
|
||||
|
||||
snapshot_partial:
|
||||
name: Create a partial backup.
|
||||
description: Create a partial backup (deprecated, use backup_partial instead).
|
||||
fields:
|
||||
addons:
|
||||
name: Add-ons
|
||||
description: Optional list of add-on slugs.
|
||||
example: ["core_ssh", "core_samba", "core_mosquitto"]
|
||||
selector:
|
||||
object:
|
||||
folders:
|
||||
name: Folders
|
||||
description: Optional list of directories.
|
||||
example: ["homeassistant", "share"]
|
||||
selector:
|
||||
object:
|
||||
name:
|
||||
name: Name
|
||||
description: Optional (default = current date and time).
|
||||
example: "Partial backup 1"
|
||||
selector:
|
||||
text:
|
||||
password:
|
||||
name: Password
|
||||
description: Optional password.
|
||||
example: "password"
|
||||
selector:
|
||||
text:
|
||||
|
||||
backup_full:
|
||||
name: Create a full backup.
|
||||
description: Create a full backup.
|
||||
|
@ -301,8 +301,6 @@ async def test_service_register(hassio_env, hass):
|
||||
assert hass.services.has_service("hassio", "host_shutdown")
|
||||
assert hass.services.has_service("hassio", "host_reboot")
|
||||
assert hass.services.has_service("hassio", "host_reboot")
|
||||
assert hass.services.has_service("hassio", "snapshot_full")
|
||||
assert hass.services.has_service("hassio", "snapshot_partial")
|
||||
assert hass.services.has_service("hassio", "backup_full")
|
||||
assert hass.services.has_service("hassio", "backup_partial")
|
||||
assert hass.services.has_service("hassio", "restore_full")
|
||||
@ -353,36 +351,17 @@ async def test_service_calls(hassio_env, hass, aioclient_mock, caplog):
|
||||
"backup_partial",
|
||||
{"addons": ["test"], "folders": ["ssl"], "password": "123456"},
|
||||
)
|
||||
await hass.services.async_call("hassio", "snapshot_full", {})
|
||||
await hass.services.async_call(
|
||||
"hassio",
|
||||
"snapshot_partial",
|
||||
{"addons": ["test"], "folders": ["ssl"]},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert (
|
||||
"The service 'snapshot_full' is deprecated and will be removed in Home Assistant 2021.11, use 'backup_full' instead"
|
||||
in caplog.text
|
||||
)
|
||||
assert (
|
||||
"The service 'snapshot_partial' is deprecated and will be removed in Home Assistant 2021.11, use 'backup_partial' instead"
|
||||
in caplog.text
|
||||
)
|
||||
|
||||
assert aioclient_mock.call_count == 14
|
||||
assert aioclient_mock.mock_calls[-3][2] == {
|
||||
assert aioclient_mock.call_count == 12
|
||||
assert aioclient_mock.mock_calls[-1][2] == {
|
||||
"addons": ["test"],
|
||||
"folders": ["ssl"],
|
||||
"password": "123456",
|
||||
}
|
||||
|
||||
await hass.services.async_call("hassio", "restore_full", {"slug": "test"})
|
||||
await hass.services.async_call("hassio", "restore_full", {"snapshot": "test"})
|
||||
await hass.async_block_till_done()
|
||||
assert (
|
||||
"Using 'snapshot' is deprecated and will be removed in Home Assistant 2021.11, use 'slug' instead"
|
||||
in caplog.text
|
||||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
"hassio",
|
||||
@ -397,7 +376,7 @@ async def test_service_calls(hassio_env, hass, aioclient_mock, caplog):
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert aioclient_mock.call_count == 17
|
||||
assert aioclient_mock.call_count == 14
|
||||
assert aioclient_mock.mock_calls[-1][2] == {
|
||||
"addons": ["test"],
|
||||
"folders": ["ssl"],
|
||||
|
Loading…
x
Reference in New Issue
Block a user