File size: 1,032 Bytes
3a006a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from fastapi import APIRouter, Depends, Request, HTTPException
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import select

from app.database import get_db
from app.models.system import WorkflowConfig

router = APIRouter(prefix="/v1/debug", tags=["Debug"])


@router.get("/workflows")
async def debug_list_workflows(request: Request, db: AsyncSession = Depends(get_db)):
    """Debug endpoint: admin-only workflow listing."""
    role = getattr(request.state, "user_role", None)
    if role not in ("admin", "ADMIN"):
        raise HTTPException(status_code=403, detail="Admin role required")
    
    result = await db.execute(select(WorkflowConfig))
    rows = result.scalars().all()
    return {"success": True, "workflows": [
        {
            "workflow_name": r.workflow_name,
            "is_active": r.is_active,
            "schedule_cron": r.schedule_cron,
            "last_run": r.last_run,
            "updated_at": r.updated_at,
        }
        for r in rows
    ]}