Files
stackpilot/backend/routers/audit.py
T
menzeljandClaude Opus 4.8 f732cb080b Initial commit: StackPilot Phase 1 (Core)
Self-hosted Docker Compose manager.
- Backend: FastAPI + docker-py + SQLite (JWT auth, file-first stacks,
  lifecycle, live status, WebSocket logs, docker-run converter, audit log)
- Frontend: React + Vite + Tailwind (login/setup, dashboard, stacks,
  stack detail, Monaco editor, dark/light theme)
- Deployment: docker-compose.yml, Dockerfiles, nginx reverse proxy

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-07 16:04:58 +00:00

30 lines
823 B
Python

"""Audit log query endpoint."""
from __future__ import annotations
from typing import Optional
from fastapi import APIRouter, Depends, Query
from sqlmodel import Session, select
from auth import get_current_user
from database import get_session
from models.audit import AuditLog
from models.user import User
router = APIRouter(prefix="/api/audit", tags=["audit"])
@router.get("")
def list_audit(
limit: int = Query(100, le=500),
offset: int = 0,
stack_id: Optional[str] = None,
session: Session = Depends(get_session),
_user: User = Depends(get_current_user),
) -> list[AuditLog]:
stmt = select(AuditLog).order_by(AuditLog.timestamp.desc())
if stack_id:
stmt = stmt.where(AuditLog.target == stack_id)
stmt = stmt.offset(offset).limit(limit)
return session.exec(stmt).all()