Adds options_validate API (#1996)
This commit is contained in:
parent
f32d17d924
commit
1c7b1f1462
1
API.md
1
API.md
|
@ -619,6 +619,7 @@ Get all available add-ons.
|
|||
- GET `/addons/{addon}/changelog`
|
||||
- GET `/addons/{addon}/documentation`
|
||||
- POST `/addons/{addon}/options`
|
||||
- POST `/addons/{addon}/options/validate`
|
||||
|
||||
```json
|
||||
{
|
||||
|
|
|
@ -268,6 +268,9 @@ class RestAPI(CoreSysAttributes):
|
|||
web.post("/addons/{addon}/restart", api_addons.restart),
|
||||
web.post("/addons/{addon}/update", api_addons.update),
|
||||
web.post("/addons/{addon}/options", api_addons.options),
|
||||
web.post(
|
||||
"/addons/{addon}/options/validate", api_addons.options_validate
|
||||
),
|
||||
web.post("/addons/{addon}/rebuild", api_addons.rebuild),
|
||||
web.get("/addons/{addon}/logs", api_addons.logs),
|
||||
web.get("/addons/{addon}/icon", api_addons.icon),
|
||||
|
|
|
@ -5,6 +5,7 @@ from typing import Any, Awaitable, Dict, List
|
|||
|
||||
from aiohttp import web
|
||||
import voluptuous as vol
|
||||
from voluptuous.humanize import humanize_error
|
||||
|
||||
from ..addons import AnyAddon
|
||||
from ..addons.addon import Addon
|
||||
|
@ -315,6 +316,15 @@ class APIAddons(CoreSysAttributes):
|
|||
|
||||
addon.save_persist()
|
||||
|
||||
@api_process
|
||||
async def options_validate(self, request: web.Request) -> None:
|
||||
"""Validate user options for add-on."""
|
||||
addon = self._extract_addon_installed(request)
|
||||
try:
|
||||
addon.schema(addon.options)
|
||||
except vol.Invalid as ex:
|
||||
raise APIError(humanize_error(addon.options, ex)) from None
|
||||
|
||||
@api_process
|
||||
async def security(self, request: web.Request) -> None:
|
||||
"""Store security options for add-on."""
|
||||
|
|
Loading…
Reference in New Issue