mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Add require_admin decorator to otbr WS API (#89385)
* Add require_admin decorator to otbr WS API * Add require_admin decorator to forgotten otbr WS API
This commit is contained in:
parent
7d97653895
commit
7232a0a786
@ -3,12 +3,7 @@ from typing import TYPE_CHECKING
|
|||||||
|
|
||||||
import python_otbr_api
|
import python_otbr_api
|
||||||
|
|
||||||
from homeassistant.components.websocket_api import (
|
from homeassistant.components import websocket_api
|
||||||
ActiveConnection,
|
|
||||||
async_register_command,
|
|
||||||
async_response,
|
|
||||||
websocket_command,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
|
||||||
@ -21,18 +16,19 @@ if TYPE_CHECKING:
|
|||||||
@callback
|
@callback
|
||||||
def async_setup(hass: HomeAssistant) -> None:
|
def async_setup(hass: HomeAssistant) -> None:
|
||||||
"""Set up the OTBR Websocket API."""
|
"""Set up the OTBR Websocket API."""
|
||||||
async_register_command(hass, websocket_info)
|
websocket_api.async_register_command(hass, websocket_info)
|
||||||
async_register_command(hass, websocket_create_network)
|
websocket_api.async_register_command(hass, websocket_create_network)
|
||||||
|
|
||||||
|
|
||||||
@websocket_command(
|
@websocket_api.websocket_command(
|
||||||
{
|
{
|
||||||
"type": "otbr/info",
|
"type": "otbr/info",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@async_response
|
@websocket_api.require_admin
|
||||||
|
@websocket_api.async_response
|
||||||
async def websocket_info(
|
async def websocket_info(
|
||||||
hass: HomeAssistant, connection: ActiveConnection, msg: dict
|
hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Get OTBR info."""
|
"""Get OTBR info."""
|
||||||
if DOMAIN not in hass.data:
|
if DOMAIN not in hass.data:
|
||||||
@ -56,14 +52,15 @@ async def websocket_info(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@websocket_command(
|
@websocket_api.websocket_command(
|
||||||
{
|
{
|
||||||
"type": "otbr/create_network",
|
"type": "otbr/create_network",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@async_response
|
@websocket_api.require_admin
|
||||||
|
@websocket_api.async_response
|
||||||
async def websocket_create_network(
|
async def websocket_create_network(
|
||||||
hass: HomeAssistant, connection: ActiveConnection, msg: dict
|
hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Create a new Thread network."""
|
"""Create a new Thread network."""
|
||||||
if DOMAIN not in hass.data:
|
if DOMAIN not in hass.data:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user