minifly-api 0.1.2

API server for Minifly - Local Fly.io development simulator
Documentation
use axum::{
    extract::{Path, State},
    Json,
};
use minifly_core::models::{Volume, VolumeState, CreateVolumeRequest};
use minifly_core::{SuccessResponse, Error as CoreError};
use chrono::Utc;
use crate::state::AppState;
use crate::error::Result;

pub async fn list_volumes(
    State(_state): State<AppState>,
    Path(_app_name): Path<String>,
) -> Result<Json<Vec<Volume>>> {
    // TODO: Implement volume storage and filtering by app
    Ok(Json(Vec::<Volume>::new()))
}

pub async fn create_volume(
    State(_state): State<AppState>,
    Path(_app_name): Path<String>,
    Json(req): Json<CreateVolumeRequest>,
) -> Result<Json<Volume>> {
    let volume = Volume {
        id: format!("vol_{}", uuid::Uuid::new_v4().simple()),
        name: req.name,
        state: VolumeState::Created,
        size_gb: req.size_gb.unwrap_or(1),
        region: req.region,
        zone: "a".to_string(),
        encrypted: req.encrypted.unwrap_or(true),
        attached_machine_id: None,
        attached_alloc_id: None,
        created_at: Utc::now(),
    };
    
    // TODO: Implement actual volume creation with Docker volumes
    
    Ok(Json(volume))
}

pub async fn get_volume(
    State(_state): State<AppState>,
    Path((_app_name, _volume_id)): Path<(String, String)>,
) -> Result<Json<Volume>> {
    // TODO: Implement volume storage
    Err(CoreError::NotFound.into())
}

pub async fn delete_volume(
    State(_state): State<AppState>,
    Path((_app_name, _volume_id)): Path<(String, String)>,
) -> Result<Json<SuccessResponse>> {
    // TODO: Implement volume deletion
    Ok(Json(SuccessResponse { ok: true }))
}