All checks were successful
Deploy Development / deploy (push) Successful in 47s
Test Suite / pytest-backend (push) Successful in 42s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 18s
Test Suite / playwright-smoke (push) Successful in 12s
Co-authored-by: Cursor <cursoragent@cursor.com>
64 lines
2.0 KiB
Python
64 lines
2.0 KiB
Python
"""Workspace read API — delegates to Data Layer (AP0.7)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Optional
|
|
|
|
from capabilities import require_capability
|
|
from data_layer import actions as dl_actions
|
|
from data_layer import actors as dl_actors
|
|
from data_layer import initiatives as dl_initiatives
|
|
from data_layer import workspace as dl_workspace
|
|
from fastapi import APIRouter, Depends, HTTPException, Query
|
|
from tenant_context import TenantContext
|
|
|
|
router = APIRouter(prefix="/api/workspace", tags=["workspace"])
|
|
|
|
|
|
def _require_actor_ctx(ctx: TenantContext) -> TenantContext:
|
|
if not ctx.actor_id:
|
|
raise HTTPException(status_code=400, detail="Kein Actor im TenantContext")
|
|
return ctx
|
|
|
|
|
|
@router.get("/summary")
|
|
def workspace_summary(
|
|
ctx: TenantContext = Depends(require_capability("kairo.workspace.read")),
|
|
):
|
|
return dl_workspace.get_workspace_summary(ctx)
|
|
|
|
|
|
@router.get("/actions/open")
|
|
def workspace_open_actions(
|
|
ctx: TenantContext = Depends(require_capability("kairo.workspace.read")),
|
|
):
|
|
try:
|
|
return dl_actions.get_my_open_actions(_require_actor_ctx(ctx))
|
|
except ValueError as exc:
|
|
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
|
|
|
|
|
@router.get("/actions/blocked")
|
|
def workspace_blocked_actions(
|
|
ctx: TenantContext = Depends(require_capability("kairo.workspace.read")),
|
|
):
|
|
try:
|
|
return dl_actions.get_my_blocked_actions(_require_actor_ctx(ctx))
|
|
except ValueError as exc:
|
|
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
|
|
|
|
|
@router.get("/initiatives/active")
|
|
def workspace_active_initiatives(
|
|
limit: Optional[int] = Query(default=None, ge=1, le=100),
|
|
ctx: TenantContext = Depends(require_capability("kairo.workspace.read")),
|
|
):
|
|
return dl_initiatives.get_active_initiatives(ctx, limit=limit)
|
|
|
|
|
|
@router.get("/actors/workload")
|
|
def workspace_actor_workload(
|
|
ctx: TenantContext = Depends(require_capability("kairo.workspace.read")),
|
|
):
|
|
return dl_actors.get_actor_workload(ctx)
|