Skip to main content

zlayer_types/api/
overlay.rs

1//! Overlay network API DTOs.
2//!
3//! Wire types for the overlay network status endpoints. These are the
4//! response shapes consumed by both the daemon and SDK clients.
5
6use serde::{Deserialize, Serialize};
7use utoipa::ToSchema;
8
9/// Overlay network status response
10#[derive(Debug, Serialize, Deserialize, ToSchema)]
11pub struct OverlayStatusResponse {
12    /// Overlay interface name
13    pub interface: String,
14    /// Whether this node is the cluster leader
15    pub is_leader: bool,
16    /// Node's overlay IP address
17    pub node_ip: String,
18    /// Overlay network CIDR
19    pub cidr: String,
20    /// Overlay listen port (`WireGuard` protocol)
21    pub port: u16,
22    /// Total number of peers
23    pub total_peers: usize,
24    /// Number of healthy peers
25    pub healthy_peers: usize,
26    /// Number of unhealthy peers
27    pub unhealthy_peers: usize,
28    /// Last health check timestamp (unix epoch seconds)
29    pub last_check: u64,
30}
31
32/// Peer information
33#[derive(Debug, Serialize, Deserialize, ToSchema)]
34pub struct PeerInfo {
35    /// Peer's public key
36    pub public_key: String,
37    /// Peer's overlay IP address
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub overlay_ip: Option<String>,
40    /// Whether the peer is healthy
41    pub healthy: bool,
42    /// Seconds since last handshake
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub last_handshake_secs: Option<u64>,
45    /// Last ping latency in milliseconds
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub last_ping_ms: Option<u64>,
48    /// Number of consecutive health check failures
49    pub failure_count: u32,
50    /// Last health check timestamp (unix epoch seconds)
51    pub last_check: u64,
52}
53
54/// Peer list response
55#[derive(Debug, Serialize, Deserialize, ToSchema)]
56pub struct PeerListResponse {
57    /// Total number of peers
58    pub total: usize,
59    /// Number of healthy peers
60    pub healthy: usize,
61    /// List of peer information
62    pub peers: Vec<PeerInfo>,
63}
64
65/// IP allocation status response
66#[derive(Debug, Serialize, Deserialize, ToSchema)]
67pub struct IpAllocationResponse {
68    /// Overlay network CIDR
69    pub cidr: String,
70    /// Total available IPs in the range
71    pub total_ips: u32,
72    /// Number of allocated IPs
73    pub allocated_count: usize,
74    /// Number of available IPs
75    pub available_count: u32,
76    /// Utilization percentage (0.0 - 100.0)
77    pub utilization_percent: f64,
78    /// List of allocated IP addresses (only included if requested)
79    #[serde(skip_serializing_if = "Option::is_none")]
80    pub allocated_ips: Option<Vec<String>>,
81}
82
83/// DNS service status response
84#[derive(Debug, Serialize, Deserialize, ToSchema)]
85pub struct DnsStatusResponse {
86    /// Whether DNS service is enabled
87    pub enabled: bool,
88    /// DNS zone name
89    #[serde(skip_serializing_if = "Option::is_none")]
90    pub zone: Option<String>,
91    /// DNS server port
92    #[serde(skip_serializing_if = "Option::is_none")]
93    pub port: Option<u16>,
94    /// DNS server bind address
95    #[serde(skip_serializing_if = "Option::is_none")]
96    pub bind_addr: Option<String>,
97    /// Number of registered services
98    pub service_count: usize,
99    /// List of registered service names
100    pub services: Vec<String>,
101}