Skip to main content

feagi_api/v1/
network_dtos.rs

1// Copyright 2025 Neuraville Inc.
2// Licensed under the Apache License, Version 2.0
3
4//! Network API DTOs
5//!
6//! Request/response types for network configuration
7
8use serde::{Deserialize, Serialize};
9use std::collections::HashMap;
10use utoipa::ToSchema;
11
12/// Network status response
13#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
14pub struct NetworkStatusResponse {
15    pub zmq_enabled: bool,
16    pub http_enabled: bool,
17    pub websocket_enabled: bool,
18}
19
20/// Network configuration request
21#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
22pub struct NetworkConfigRequest {
23    pub config: HashMap<String, serde_json::Value>,
24}
25
26/// Success response
27#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
28pub struct NetworkSuccessResponse {
29    pub message: String,
30    pub success: bool,
31}
32
33// ============================================================================
34// Connection Info (GET /v1/network/connection_info)
35// ============================================================================
36
37/// API transport section
38#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
39pub struct ConnectionInfoApi {
40    pub enabled: bool,
41    pub base_url: String,
42    pub host: String,
43    pub port: u16,
44    pub swagger_url: String,
45}
46
47/// ZMQ transport section
48#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
49pub struct ConnectionInfoZmq {
50    pub enabled: bool,
51    pub host: String,
52    pub ports: ConnectionInfoZmqPorts,
53    pub endpoints: ConnectionInfoZmqEndpoints,
54}
55
56#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
57pub struct ConnectionInfoZmqPorts {
58    pub registration: u16,
59    pub sensory: u16,
60    pub motor: u16,
61    pub visualization: u16,
62    pub api_control: u16,
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
66pub struct ConnectionInfoZmqEndpoints {
67    pub registration: String,
68    pub sensory: String,
69    pub motor: String,
70    pub visualization: String,
71}
72
73/// WebSocket transport section
74#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
75pub struct ConnectionInfoWebSocket {
76    pub enabled: bool,
77    pub host: String,
78    pub ports: ConnectionInfoWebSocketPorts,
79    pub endpoints: ConnectionInfoWebSocketEndpoints,
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
83pub struct ConnectionInfoWebSocketPorts {
84    pub registration: u16,
85    pub sensory: u16,
86    pub motor: u16,
87    pub visualization: u16,
88    pub rest_api: u16,
89}
90
91#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
92pub struct ConnectionInfoWebSocketEndpoints {
93    pub registration: String,
94    pub sensory: String,
95    pub motor: String,
96    pub visualization: String,
97}
98
99/// SHM transport section
100#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
101pub struct ConnectionInfoShm {
102    pub enabled: bool,
103    pub base_path: String,
104    pub policy: String,
105    pub note: String,
106}
107
108/// UDP transport section (placeholder)
109#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
110pub struct ConnectionInfoUdp {
111    pub enabled: bool,
112    pub visualization: Option<serde_json::Value>,
113    pub sensory: Option<serde_json::Value>,
114    pub note: String,
115}
116
117/// Bluetooth transport section (placeholder)
118#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
119pub struct ConnectionInfoBluetooth {
120    pub enabled: bool,
121    pub relay_port: Option<u16>,
122    pub note: String,
123}
124
125/// Stream runtime status
126#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
127pub struct ConnectionInfoStreamStatus {
128    pub zmq_control_started: bool,
129    pub zmq_data_streams_started: bool,
130    pub websocket_started: bool,
131    pub note: String,
132}
133
134/// Full network connection info response
135#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
136pub struct NetworkConnectionInfo {
137    pub api: ConnectionInfoApi,
138    pub zmq: ConnectionInfoZmq,
139    pub websocket: ConnectionInfoWebSocket,
140    pub shm: ConnectionInfoShm,
141    pub udp: ConnectionInfoUdp,
142    pub bluetooth: ConnectionInfoBluetooth,
143    pub stream_status: ConnectionInfoStreamStatus,
144}