Skip to main content

feagi_api/v1/
genome_dtos.rs

1// Copyright 2025 Neuraville Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4// Genome DTOs for V1 API
5//
6// These DTOs must match Python FastAPI response structures exactly.
7
8use serde::{Deserialize, Serialize};
9use utoipa::ToSchema;
10
11/// Genome information
12#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
13#[schema(example = json!({
14    "genome_id": "human_cortex_v1",
15    "title": "Human Cortex Model v1",
16    "version": "1.0.0",
17    "cortical_area_count": 52,
18    "brain_region_count": 12,
19    "created_at": "2025-01-15T10:30:00Z",
20    "modified_at": "2025-01-20T14:45:00Z"
21}))]
22pub struct GenomeInfoResponse {
23    /// Genome ID
24    pub genome_id: Option<String>,
25
26    /// Human-readable title
27    pub title: Option<String>,
28
29    /// Genome version
30    pub version: Option<String>,
31
32    /// Number of cortical areas
33    pub cortical_area_count: usize,
34
35    /// Number of brain regions
36    pub brain_region_count: usize,
37
38    /// Creation timestamp (ISO 8601)
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub created_at: Option<String>,
41
42    /// Last modification timestamp (ISO 8601)
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub modified_at: Option<String>,
45}
46
47/// Load genome request
48#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
49pub struct LoadGenomeRequest {
50    /// Genome JSON string
51    pub genome_json: String,
52
53    /// Whether to reset connectome before loading
54    #[serde(default)]
55    pub reset_before_load: bool,
56}
57
58/// Save genome request
59#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
60pub struct SaveGenomeRequest {
61    /// Optional: Genome ID to assign
62    #[serde(default)]
63    pub genome_id: Option<String>,
64
65    /// Optional: Human-readable title
66    #[serde(default)]
67    pub title: Option<String>,
68}
69
70/// Save genome response
71#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
72pub struct SaveGenomeResponse {
73    /// Genome JSON string
74    pub genome_json: String,
75
76    /// Genome metadata
77    pub genome_info: GenomeInfoResponse,
78}
79
80/// Validate genome request
81#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
82pub struct ValidateGenomeRequest {
83    /// Genome JSON string to validate
84    pub genome_json: String,
85}
86
87/// Validate genome response
88#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
89pub struct ValidateGenomeResponse {
90    /// Whether the genome is valid
91    pub is_valid: bool,
92
93    /// Validation errors (if any)
94    #[serde(skip_serializing_if = "Option::is_none")]
95    pub errors: Option<Vec<String>>,
96}