1"""Per-user named config library. `/api/configs` CRUD.
3The stored payload is an engine design: `{"input": <PintleEngineConfig>,
4"output": <last results>}`. The store itself is payload-agnostic -- the frontend
5decides what goes in; load hands the blob back and the UI rehydrates it.
7Identity is X-Auth-Email (from Caddy) with a `local` dev fallback -- there is no
8gating here, only whose folder to use. See backend/userdata.py.
11from fastapi
import APIRouter, HTTPException, Request
12from pydantic
import BaseModel
14from backend
import userdata
16router = APIRouter(prefix=
"/api/configs", tags=[
"configs"])
26 """Saved configs for the caller, newest first (metadata only)."""
27 return {
"configs": userdata.list_configs(userdata.current_user(request))}
32 blob = userdata.read_config(userdata.current_user(request), slug)
34 raise HTTPException(status_code=404, detail=
"No saved config by that name.")
40 """Create or overwrite a named config for the caller."""
42 return userdata.write_config(
43 userdata.current_user(request), body.name, body.config
45 except ValueError
as exc:
46 raise HTTPException(status_code=422, detail=str(exc))
49@router.delete("/{slug}")
51 if not userdata.delete_config(userdata.current_user(request), slug):
52 raise HTTPException(status_code=404, detail=
"No saved config by that name.")
53 return {
"status":
"deleted",
"slug": slug}
get_config(str slug, Request request)
delete_config(str slug, Request request)
save_config(SaveRequest body, Request request)
list_configs(Request request)