From 246fab7e1e65d0f1285cc437d81558e49a6125b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Bachmann?= Date: Thu, 15 Jan 2026 19:53:07 +0000 Subject: [PATCH] . --- custom_components/bahmcloud_store/views.py | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/custom_components/bahmcloud_store/views.py b/custom_components/bahmcloud_store/views.py index 7e5effc..228c811 100644 --- a/custom_components/bahmcloud_store/views.py +++ b/custom_components/bahmcloud_store/views.py @@ -290,3 +290,62 @@ class BCSReadmeView(HomeAssistantView): md_str = str(md) html = _render_markdown_server_side(md_str) return web.json_response({"ok": True, "readme": md_str, "html": html}) + + +class BCSInstallView(HomeAssistantView): + url = "/api/bcs/install" + name = "api:bcs_install" + requires_auth = True + + def __init__(self, core: Any) -> None: + self.core: BCSCore = core + + async def post(self, request: web.Request) -> web.Response: + repo_id = request.query.get("repo_id") + if not repo_id: + return web.json_response({"ok": False, "message": "Missing repo_id"}, status=400) + + try: + result = await self.core.install_repo(repo_id) + return web.json_response(result, status=200) + except Exception as e: + _LOGGER.exception("BCS install failed: %s", e) + return web.json_response({"ok": False, "message": str(e) or "Install failed"}, status=500) + + +class BCSUpdateView(HomeAssistantView): + url = "/api/bcs/update" + name = "api:bcs_update" + requires_auth = True + + def __init__(self, core: Any) -> None: + self.core: BCSCore = core + + async def post(self, request: web.Request) -> web.Response: + repo_id = request.query.get("repo_id") + if not repo_id: + return web.json_response({"ok": False, "message": "Missing repo_id"}, status=400) + + try: + result = await self.core.update_repo(repo_id) + return web.json_response(result, status=200) + except Exception as e: + _LOGGER.exception("BCS update failed: %s", e) + return web.json_response({"ok": False, "message": str(e) or "Update failed"}, status=500) + + +class BCSRestartView(HomeAssistantView): + url = "/api/bcs/restart" + name = "api:bcs_restart" + requires_auth = True + + def __init__(self, core: Any) -> None: + self.core: BCSCore = core + + async def post(self, request: web.Request) -> web.Response: + try: + await self.core.request_restart() + return web.json_response({"ok": True}) + except Exception as e: + _LOGGER.exception("BCS restart failed: %s", e) + return web.json_response({"ok": False, "message": str(e) or "Restart failed"}, status=500) \ No newline at end of file