/api/clan_modules: init
- add GET /api/clan_modules entry point returning a list of modules available for import
This commit is contained in:
@@ -8,7 +8,7 @@ from fastapi.staticfiles import StaticFiles
|
||||
from ..errors import ClanError
|
||||
from .assets import asset_path
|
||||
from .error_handlers import clan_error_handler
|
||||
from .routers import flake, health, machines, root, vms
|
||||
from .routers import clan_modules, flake, health, machines, root, vms
|
||||
|
||||
origins = [
|
||||
"http://localhost:3000",
|
||||
@@ -26,6 +26,7 @@ def setup_app() -> FastAPI:
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
app.include_router(clan_modules.router)
|
||||
app.include_router(flake.router)
|
||||
app.include_router(health.router)
|
||||
app.include_router(machines.router)
|
||||
|
||||
21
pkgs/clan-cli/clan_cli/webui/routers/clan_modules.py
Normal file
21
pkgs/clan-cli/clan_cli/webui/routers/clan_modules.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# Logging setup
|
||||
import logging
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from clan_cli.clan_modules import get_clan_module_names
|
||||
|
||||
from ..schemas import (
|
||||
ClanModulesResponse,
|
||||
)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/api/clan_modules")
|
||||
async def list_clan_modules() -> ClanModulesResponse:
|
||||
module_names, error = get_clan_module_names()
|
||||
if error is not None:
|
||||
raise HTTPException(status_code=400, detail=error)
|
||||
return ClanModulesResponse(clan_modules=module_names)
|
||||
@@ -13,6 +13,10 @@ class Status(Enum):
|
||||
UNKNOWN = "unknown"
|
||||
|
||||
|
||||
class ClanModulesResponse(BaseModel):
|
||||
clan_modules: list[str]
|
||||
|
||||
|
||||
class Machine(BaseModel):
|
||||
name: str
|
||||
status: Status
|
||||
|
||||
Reference in New Issue
Block a user