36 lines
990 B
Python
36 lines
990 B
Python
|
|
"""Feature registry API."""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from capabilities import require_capability_ctx
|
||
|
|
from db import get_connection
|
||
|
|
from fastapi import APIRouter, Depends
|
||
|
|
|
||
|
|
router = APIRouter(prefix="/api/features", tags=["features"])
|
||
|
|
|
||
|
|
|
||
|
|
@router.get("")
|
||
|
|
def list_features(_ctx=Depends(require_capability_ctx("kairo.feature.registry.read"))):
|
||
|
|
conn = get_connection()
|
||
|
|
try:
|
||
|
|
with conn.cursor() as cur:
|
||
|
|
cur.execute(
|
||
|
|
"""
|
||
|
|
SELECT feature_key, module, name, description, is_active
|
||
|
|
FROM features
|
||
|
|
ORDER BY feature_key
|
||
|
|
"""
|
||
|
|
)
|
||
|
|
return [
|
||
|
|
{
|
||
|
|
"feature_key": row[0],
|
||
|
|
"module": row[1],
|
||
|
|
"name": row[2],
|
||
|
|
"description": row[3],
|
||
|
|
"is_active": row[4],
|
||
|
|
}
|
||
|
|
for row in cur.fetchall()
|
||
|
|
]
|
||
|
|
finally:
|
||
|
|
conn.close()
|