Skip to main content

unifly_api/model/
supporting.rs

1// ── Supporting / auxiliary domain types ──
2//
3// VPN, WAN, traffic matching, RADIUS, device tags, and other
4// resources that don't warrant their own module.
5
6use serde::{Deserialize, Serialize};
7use serde_json::Value;
8use std::net::IpAddr;
9
10use super::common::EntityOrigin;
11use super::entity_id::EntityId;
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
14pub struct VpnServer {
15    pub id: EntityId,
16    pub name: Option<String>,
17    pub server_type: String,
18    pub enabled: Option<bool>,
19    pub subnet: Option<String>,
20    pub port: Option<u16>,
21    pub wan_ip: Option<String>,
22    pub connected_clients: Option<u32>,
23    pub protocol: Option<String>,
24    #[serde(flatten)]
25    pub extra: serde_json::Map<String, serde_json::Value>,
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
29pub struct VpnTunnel {
30    pub id: EntityId,
31    pub name: Option<String>,
32    pub tunnel_type: String,
33    pub enabled: Option<bool>,
34    pub peer_address: Option<String>,
35    pub local_subnets: Vec<String>,
36    pub remote_subnets: Vec<String>,
37    pub has_psk: bool,
38    pub ike_version: Option<String>,
39    #[serde(flatten)]
40    pub extra: serde_json::Map<String, serde_json::Value>,
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct IpsecSa {
45    pub name: Option<String>,
46    pub remote_ip: Option<String>,
47    pub local_ip: Option<String>,
48    pub state: Option<String>,
49    pub tx_bytes: Option<i64>,
50    pub rx_bytes: Option<i64>,
51    pub uptime: Option<i64>,
52    pub ike_version: Option<String>,
53    #[serde(flatten)]
54    pub extra: serde_json::Map<String, serde_json::Value>,
55}
56
57#[derive(Debug, Clone, Serialize, Deserialize)]
58pub struct VpnSetting {
59    pub key: String,
60    pub enabled: Option<bool>,
61    #[serde(default)]
62    pub fields: serde_json::Map<String, Value>,
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize)]
66pub struct SiteToSiteVpn {
67    pub id: EntityId,
68    pub name: String,
69    pub enabled: bool,
70    pub vpn_type: String,
71    pub remote_site_id: Option<String>,
72    pub local_ip: Option<String>,
73    pub interface: Option<String>,
74    pub remote_host: Option<String>,
75    #[serde(default)]
76    pub remote_vpn_subnets: Vec<String>,
77    #[serde(default)]
78    pub fields: serde_json::Map<String, Value>,
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
82pub struct RemoteAccessVpnServer {
83    pub id: EntityId,
84    pub name: String,
85    pub enabled: bool,
86    pub vpn_type: String,
87    pub local_port: Option<u16>,
88    pub local_wan_ip: Option<String>,
89    pub interface: Option<String>,
90    pub gateway_subnet: Option<String>,
91    pub radius_profile_id: Option<String>,
92    pub exposed_to_site_vpn: Option<bool>,
93    #[serde(default)]
94    pub fields: serde_json::Map<String, Value>,
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize)]
98pub struct WireGuardPeer {
99    pub id: EntityId,
100    pub server_id: Option<EntityId>,
101    pub name: String,
102    pub interface_ip: Option<String>,
103    pub interface_ipv6: Option<String>,
104    pub public_key: Option<String>,
105    #[serde(default)]
106    pub allowed_ips: Vec<String>,
107    pub has_private_key: bool,
108    pub has_preshared_key: bool,
109    #[serde(default)]
110    pub fields: serde_json::Map<String, Value>,
111}
112
113#[derive(Debug, Clone, Serialize, Deserialize)]
114pub struct VpnClientConnection {
115    pub id: EntityId,
116    pub name: Option<String>,
117    pub connection_type: Option<String>,
118    pub status: Option<String>,
119    pub local_address: Option<String>,
120    pub remote_address: Option<String>,
121    pub username: Option<String>,
122    #[serde(default)]
123    pub fields: serde_json::Map<String, Value>,
124}
125
126#[derive(Debug, Clone, Serialize, Deserialize)]
127pub struct VpnClientProfile {
128    pub id: EntityId,
129    pub name: String,
130    pub enabled: bool,
131    pub vpn_type: String,
132    pub server_address: Option<String>,
133    pub server_port: Option<u16>,
134    pub local_address: Option<String>,
135    pub username: Option<String>,
136    pub interface: Option<String>,
137    pub route_distance: Option<u32>,
138    #[serde(default)]
139    pub fields: serde_json::Map<String, Value>,
140}
141
142#[derive(Debug, Clone, Serialize, Deserialize)]
143pub struct MagicSiteToSiteVpnConfig {
144    pub id: EntityId,
145    pub name: Option<String>,
146    pub status: Option<String>,
147    pub enabled: Option<bool>,
148    pub local_site_name: Option<String>,
149    pub remote_site_name: Option<String>,
150    #[serde(default)]
151    pub fields: serde_json::Map<String, Value>,
152}
153
154#[derive(Debug, Clone, Serialize, Deserialize)]
155pub struct WanInterface {
156    pub id: EntityId,
157    pub name: Option<String>,
158    pub ip: Option<IpAddr>,
159    pub gateway: Option<IpAddr>,
160    pub dns: Vec<IpAddr>,
161}
162
163#[derive(Debug, Clone, Serialize, Deserialize)]
164pub struct TrafficMatchingList {
165    pub id: EntityId,
166    pub name: String,
167    /// List type: PORTS, IPV4_ADDRESSES, IPV6_ADDRESSES
168    pub list_type: String,
169    pub items: Vec<String>,
170    pub origin: Option<EntityOrigin>,
171}
172
173#[derive(Debug, Clone, Serialize, Deserialize)]
174pub struct RadiusProfile {
175    pub id: EntityId,
176    pub name: String,
177}
178
179#[derive(Debug, Clone, Serialize, Deserialize)]
180pub struct DeviceTag {
181    pub id: EntityId,
182    pub name: String,
183}