From 1f448744f3f15df5250b890833c064d139c64f21 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Sun, 18 Aug 2019 11:46:23 +0200 Subject: [PATCH] Add restart function / options change (#1242) --- API.md | 2 ++ hassio/api/__init__.py | 1 + hassio/api/dns.py | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/API.md b/API.md index a6fc1b6da..36ea2c474 100644 --- a/API.md +++ b/API.md @@ -771,6 +771,8 @@ return: } ``` +- POST `/dns/restart` + - GET `/dns/logs` - GET `/dns/stats` diff --git a/hassio/api/__init__.py b/hassio/api/__init__.py index dbc3decaf..2a02eaeb8 100644 --- a/hassio/api/__init__.py +++ b/hassio/api/__init__.py @@ -278,6 +278,7 @@ class RestAPI(CoreSysAttributes): web.get("/dns/logs", api_dns.logs), web.post("/dns/update", api_dns.update), web.post("/dns/options", api_dns.options), + web.post("/dns/restart", api_dns.restart), ] ) diff --git a/hassio/api/dns.py b/hassio/api/dns.py index b643a6539..b4666b9eb 100644 --- a/hassio/api/dns.py +++ b/hassio/api/dns.py @@ -54,6 +54,7 @@ class APICoreDNS(CoreSysAttributes): if ATTR_SERVERS in body: self.sys_dns.servers = body[ATTR_SERVERS] + self.sys_create_task(self.sys_dns.restart()) self.sys_dns.save_data() @@ -87,3 +88,8 @@ class APICoreDNS(CoreSysAttributes): def logs(self, request: web.Request) -> Awaitable[bytes]: """Return DNS Docker logs.""" return self.sys_dns.logs() + + @api_process + def restart(self, request: web.Request) -> Awaitable[None]: + """Restart CoreDNS plugin.""" + return asyncio.shield(self.sys_dns.restart())