37 lines
891 B
Python
37 lines
891 B
Python
import uuid
|
|
|
|
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.core.deps import get_db_session, require_study_member
|
|
from app.crud import audit as audit_crud
|
|
from app.schemas.audit import AuditLogRead
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get(
|
|
"/",
|
|
response_model=list[AuditLogRead],
|
|
dependencies=[Depends(require_study_member())],
|
|
)
|
|
async def list_audit_logs(
|
|
study_id: uuid.UUID,
|
|
entity_type: str | None = None,
|
|
entity_id: uuid.UUID | None = None,
|
|
action: str | None = None,
|
|
skip: int = 0,
|
|
limit: int = 100,
|
|
db: AsyncSession = Depends(get_db_session),
|
|
) -> list[AuditLogRead]:
|
|
logs = await audit_crud.list_logs(
|
|
db,
|
|
study_id=study_id,
|
|
entity_type=entity_type,
|
|
entity_id=entity_id,
|
|
action=action,
|
|
skip=skip,
|
|
limit=limit,
|
|
)
|
|
return list(logs)
|