mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-20 07:36:29 +00:00
Add network reload to api (#2319)
This commit is contained in:
parent
06e10fdd3c
commit
e2a473baa3
@ -112,6 +112,7 @@ class RestAPI(CoreSysAttributes):
|
||||
self.webapp.add_routes(
|
||||
[
|
||||
web.get("/network/info", api_network.info),
|
||||
web.post("/network/reload", api_network.reload),
|
||||
web.get(
|
||||
"/network/interface/{interface}/info", api_network.interface_info
|
||||
),
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""REST API for network."""
|
||||
import asyncio
|
||||
from ipaddress import ip_address, ip_interface
|
||||
from typing import Any, Dict
|
||||
from typing import Any, Awaitable, Dict
|
||||
|
||||
from aiohttp import web
|
||||
import attr
|
||||
@ -207,6 +207,11 @@ class APINetwork(CoreSysAttributes):
|
||||
|
||||
await asyncio.shield(self.sys_host.network.apply_changes(interface))
|
||||
|
||||
@api_process
|
||||
def reload(self, request: web.Request) -> Awaitable[None]:
|
||||
"""Reload network data."""
|
||||
return asyncio.shield(self.sys_host.network.update())
|
||||
|
||||
@api_process
|
||||
async def scan_accesspoints(self, request: web.Request) -> Dict[str, Any]:
|
||||
"""Scan and return a list of available networks."""
|
||||
|
@ -185,3 +185,12 @@ async def test_api_network_wireless_scan(api_client):
|
||||
ap["ssid"] for ap in result["data"]["accesspoints"]
|
||||
]
|
||||
assert [47, 63] == [ap["signal"] for ap in result["data"]["accesspoints"]]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_api_network_reload(api_client, coresys):
|
||||
"""Test network manager reload api."""
|
||||
resp = await api_client.post("/network/reload")
|
||||
result = await resp.json()
|
||||
|
||||
assert result["result"] == "ok"
|
||||
|
Loading…
x
Reference in New Issue
Block a user