use axum::{
Json,
extract::{Query, State},
response::Response,
};
use serde::{Deserialize, Serialize};
use crate::routes::{graphql::app_state::AppState, studio::not_implemented};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ObjectEntry {
pub key: String,
pub size: u64,
pub content_type: String,
pub updated_at: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BucketEntry {
pub name: String,
pub object_count: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ObjectListResponse {
pub objects: Vec<ObjectEntry>,
pub total: u64,
pub page: u32,
pub page_size: u32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BucketListResponse {
pub buckets: Vec<BucketEntry>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ObjectListQuery {
pub bucket: String,
pub prefix: Option<String>,
#[serde(default = "default_page")]
pub page: u32,
#[serde(default = "default_page_size")]
pub page_size: u32,
}
const fn default_page() -> u32 {
1
}
const fn default_page_size() -> u32 {
50
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PresignRequest {
pub bucket: String,
pub key: String,
pub expires_in_secs: u32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DeleteObjectRequest {
pub bucket: String,
pub key: String,
}
pub async fn list_buckets_handler(State(_state): State<AppState>) -> Response {
not_implemented(
"studio.storage.buckets",
"The storage browser is not wired to a StorageBackend; an empty bucket list \
here would not mean the deployment has no buckets.",
)
}
pub async fn list_objects_handler(
State(_state): State<AppState>,
Query(_params): Query<ObjectListQuery>,
) -> Response {
not_implemented(
"studio.storage.objects",
"The storage browser is not wired to a StorageBackend; an empty object list \
here would not mean the bucket is empty.",
)
}
pub async fn presign_handler(
State(_state): State<AppState>,
Json(_req): Json<PresignRequest>,
) -> Response {
not_implemented(
"studio.storage.presign",
"The storage browser is not wired to a StorageBackend; no presigned URL was \
generated.",
)
}
pub async fn delete_object_handler(
State(_state): State<AppState>,
Json(_req): Json<DeleteObjectRequest>,
) -> Response {
not_implemented(
"studio.storage.delete",
"The storage browser is not wired to a StorageBackend; no object was deleted.",
)
}