Skip to content

Commit 24c5809

Browse files
Add Scaleway Object Storage backup integration
1 parent b75af6d commit 24c5809

21 files changed

+1672
-0
lines changed

.strict-typing

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ homeassistant.components.ruuvi_gateway.*
482482
homeassistant.components.ruuvitag_ble.*
483483
homeassistant.components.samsungtv.*
484484
homeassistant.components.saunum.*
485+
homeassistant.components.scaleway_object_storage.*
485486
homeassistant.components.scene.*
486487
homeassistant.components.schedule.*
487488
homeassistant.components.schlage.*

CODEOWNERS

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""The Scaleway Object Storage integration."""
2+
3+
from typing import TYPE_CHECKING
4+
5+
from homeassistant.config_entries import ConfigEntry
6+
from homeassistant.exceptions import (
7+
ConfigEntryAuthFailed,
8+
ConfigEntryError,
9+
ConfigEntryNotReady,
10+
)
11+
from homeassistant.helpers.aiohttp_client import async_get_clientsession
12+
13+
if TYPE_CHECKING:
14+
from aiohttp_s3_client import S3Client
15+
16+
from homeassistant.core import HomeAssistant
17+
18+
from . import exceptions, helpers
19+
from .const import DATA_BACKUP_AGENT_LISTENERS, DOMAIN
20+
21+
type ScalewayConfigEntry = ConfigEntry[S3Client]
22+
23+
24+
async def async_setup_entry(hass: HomeAssistant, entry: ScalewayConfigEntry) -> bool:
25+
"""Set up an integration config entry."""
26+
session = async_get_clientsession(hass)
27+
try:
28+
await helpers.check_connection(session, entry.data)
29+
except ConfigEntryNotReady, ConfigEntryError, ConfigEntryAuthFailed:
30+
# Re-raise as they are
31+
raise
32+
except exceptions.ScalewayException as e:
33+
# All other exceptions are translated
34+
raise ConfigEntryError(
35+
translation_domain=DOMAIN,
36+
translation_key=e.translation_key,
37+
) from e
38+
39+
entry.runtime_data = helpers.create_client(session, entry.data)
40+
41+
# Notify backup listeners
42+
def notify_backup_listeners() -> None:
43+
for listener in hass.data.get(DATA_BACKUP_AGENT_LISTENERS, []):
44+
listener()
45+
46+
entry.async_on_unload(entry.async_on_state_change(notify_backup_listeners))
47+
48+
return True
49+
50+
51+
async def async_unload_entry(hass: HomeAssistant, entry: ScalewayConfigEntry) -> bool:
52+
"""Unload a config entry."""
53+
return True

0 commit comments

Comments
 (0)