Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I28cf5b7b7cff8e90e123d624d97cf9656a6a6964
36 lines
1,012 B
Rust
36 lines
1,012 B
Rust
use axum::{
|
|
Json,
|
|
extract::{Query, State},
|
|
};
|
|
|
|
use crate::{
|
|
dto::{AuditEntryResponse, PaginationParams},
|
|
error::ApiError,
|
|
state::AppState,
|
|
};
|
|
|
|
#[utoipa::path(
|
|
get,
|
|
path = "/api/v1/audit",
|
|
tag = "audit",
|
|
params(
|
|
("offset" = Option<u64>, Query, description = "Pagination offset"),
|
|
("limit" = Option<u64>, Query, description = "Page size"),
|
|
),
|
|
responses(
|
|
(status = 200, description = "Audit log entries", body = Vec<AuditEntryResponse>),
|
|
(status = 401, description = "Unauthorized"),
|
|
(status = 500, description = "Internal server error"),
|
|
),
|
|
security(("bearer_auth" = []))
|
|
)]
|
|
pub async fn list_audit(
|
|
State(state): State<AppState>,
|
|
Query(params): Query<PaginationParams>,
|
|
) -> Result<Json<Vec<AuditEntryResponse>>, ApiError> {
|
|
let pagination = params.to_pagination();
|
|
let entries = state.storage.list_audit_entries(None, &pagination).await?;
|
|
Ok(Json(
|
|
entries.into_iter().map(AuditEntryResponse::from).collect(),
|
|
))
|
|
}
|