Expand lab seed tiers, OpenAPI PARAMS, and console DATA/Params UX.

This commit is contained in:
2026-07-18 08:46:39 +03:00
parent f8d3cbdd59
commit 63cc409424
71 changed files with 38380 additions and 796 deletions
+44 -6
View File
@@ -4,7 +4,7 @@ from __future__ import annotations
from typing import Any
from fastapi import APIRouter, Depends
from fastapi import APIRouter, Depends, Query
from app.db.pool import Database
from app.dependencies import get_database
@@ -16,11 +16,7 @@ from app.vsphere.security.session import SessionInfo
router = APIRouter(tags=["vSphere Tasks"])
@router.get("/api/cis/tasks")
async def list_tasks(
database: Database = Depends(get_database),
_: SessionInfo = Depends(require_read),
) -> list[dict[str, Any]]:
async def _ensure_seed_task(database: Database) -> list[dict[str, Any]]:
tasks = await task_store.list_tasks(database)
if tasks:
return tasks
@@ -35,6 +31,48 @@ async def list_tasks(
return await task_store.list_tasks(database)
@router.get("/api/cis/tasks")
async def list_tasks(
database: Database = Depends(get_database),
_: SessionInfo = Depends(require_read),
) -> list[dict[str, Any]]:
# Lab convenience: return recent Cis Task Info objects (non-empty after seed).
return await _ensure_seed_task(database)
@router.post("/api/cis/tasks")
async def list_tasks_action(
body: dict[str, Any] | None = None,
action: str = Query("list"),
database: Database = Depends(get_database),
_: SessionInfo = Depends(require_read),
) -> dict[str, Any] | None:
"""Official Automation list: POST /api/cis/tasks?action=list → map id→info."""
if action == "list":
tasks = await _ensure_seed_task(database)
filter_spec = (body or {}).get("filter_spec") or (body or {})
wanted_tasks = set(filter_spec.get("tasks") or [])
wanted_services = set(filter_spec.get("services") or [])
wanted_status = set(filter_spec.get("status") or [])
out: dict[str, Any] = {}
for task in tasks:
tid = str(task.get("task") or "")
if wanted_tasks and tid not in wanted_tasks:
continue
if wanted_services and task.get("service") not in wanted_services:
continue
if wanted_status and task.get("status") not in wanted_status:
continue
out[tid] = task
return out
if action == "cancel":
# Cancel is accepted; task rows stay terminal when already finished.
return None
from app.vsphere.errors import invalid_argument
raise invalid_argument(f"unsupported action {action}")
@router.get("/api/cis/tasks/{task}")
async def get_task(
task: str,