api/machines: allow importing extra modules

- add top-level option `clanImports` to clanCore
- clanImports can be set and checked as any other option
- buildClan resolves the clanImports from the settings.json before calling evalModules to prevent infinite recursions
- new endpoint PUT machines/{name}/schema to allow getting the schema for a specific list of imports
- to retrieve the currently imported modules, cimply do a GET or PU on machines/{name}/config which will return `clanImports` as part of the config

Still missing: get list of available modules
This commit is contained in:
DavHau
2023-10-25 16:36:01 +01:00
parent 3d0b9428a7
commit cf0953146d
11 changed files with 234 additions and 81 deletions

View File

@@ -69,6 +69,14 @@ async def get_machine_schema(name: str) -> SchemaResponse:
return SchemaResponse(schema=schema)
@router.put("/api/machines/{name}/schema")
async def set_machine_schema(
name: str, config: Annotated[dict, Body()]
) -> SchemaResponse:
schema = schema_for_machine(name, config)
return SchemaResponse(schema=schema)
@router.get("/api/machines/{name}/verify")
async def put_verify_machine_config(name: str) -> VerifyMachineResponse:
error = verify_machine_config(name)