use axum::{
Json,
extract::{Path, State},
response::Response,
};
use serde::{Deserialize, Serialize};
use crate::routes::{graphql::app_state::AppState, studio::not_implemented};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FunctionEntry {
pub name: String,
pub version: u32,
pub runtime: String,
pub status: String,
pub deployed_at: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FunctionListResponse {
pub functions: Vec<FunctionEntry>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InvokeResponse {
pub value: serde_json::Value,
pub logs: Vec<String>,
pub duration_ms: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InvocationLogEntry {
pub status: String,
pub duration_ms: u64,
pub error: Option<String>,
pub timestamp: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SecretsKeysResponse {
pub keys: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InvokeRequest {
pub event: serde_json::Value,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SecretSetRequest {
pub value: String,
}
pub async fn list_functions_handler(State(_state): State<AppState>) -> Response {
not_implemented(
"studio.functions.list",
"The deployed-function registry is not exposed through the admin API; an \
empty list here would not mean no functions are deployed.",
)
}
pub async fn invoke_function_handler(
Path(_name): Path<String>,
State(_state): State<AppState>,
Json(_req): Json<InvokeRequest>,
) -> Response {
not_implemented(
"studio.functions.invoke",
"Ad-hoc function invocation is not exposed through the admin API. Use \
`fraiseql functions invoke`.",
)
}
pub async fn function_logs_handler(
Path(_name): Path<String>,
State(_state): State<AppState>,
) -> Response {
not_implemented(
"studio.functions.logs",
"No invocation-log ring buffer is exposed through the admin API; an empty \
list here would not mean the function has never run.",
)
}
pub async fn list_secrets_handler(
Path(_name): Path<String>,
State(_state): State<AppState>,
) -> Response {
not_implemented(
"studio.functions.secrets.list",
"Function secrets are not managed through the admin API; an empty key list \
here would not mean the function holds no secrets.",
)
}
pub async fn set_secret_handler(
Path((_name, _key)): Path<(String, String)>,
State(_state): State<AppState>,
Json(_req): Json<SecretSetRequest>,
) -> Response {
not_implemented(
"studio.functions.secrets.set",
"Function secrets are not writable through the admin API; nothing was \
stored. Manage them through the configured secrets backend.",
)
}
pub async fn delete_secret_handler(
Path((_name, _key)): Path<(String, String)>,
State(_state): State<AppState>,
) -> Response {
not_implemented(
"studio.functions.secrets.delete",
"Function secrets are not deletable through the admin API; nothing was \
removed. Manage them through the configured secrets backend.",
)
}