machines: add endpoint machines/{name}/ verify

This commit is contained in:
DavHau
2023-10-24 16:30:58 +01:00
parent 3288185f66
commit f1e7495806
5 changed files with 71 additions and 12 deletions

View File

@@ -4,6 +4,8 @@ from typing import Annotated
from fastapi import APIRouter, Body
import clan_cli.config as config
from ...config.machine import (
config_for_machine,
schema_for_machine,
@@ -19,6 +21,7 @@ from ..schemas import (
MachinesResponse,
SchemaResponse,
Status,
VerifyMachineResponse,
)
log = logging.getLogger(__name__)
@@ -63,3 +66,9 @@ async def set_machine_config(
async def get_machine_schema(name: str) -> SchemaResponse:
schema = schema_for_machine(name)
return SchemaResponse(schema=schema)
@router.get("/api/machines/{name}/verify")
async def verify_machine_config(name: str) -> VerifyMachineResponse:
success, error = config.machine.verify_machine_config(name)
return VerifyMachineResponse(success=success, error=error)