unifi_rs/models/
device.rs

1use crate::models::common::{ConnectorType, FrequencyBand, PortState, WlanStandard};
2use chrono::{DateTime, Utc};
3use serde::{Deserialize, Serialize};
4use uuid::Uuid;
5
6#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
7#[serde(rename_all = "UPPERCASE")]
8pub enum DeviceState {
9    Online,
10    Offline,
11    PendingAdoption,
12    Updating,
13    GettingReady,
14    Adopting,
15    Deleting,
16    ConnectionInterrupted,
17    Isolated,
18}
19
20#[derive(Debug, Clone, Serialize, Deserialize)]
21#[serde(rename_all = "camelCase")]
22pub struct DeviceOverview {
23    pub id: Uuid,
24    pub name: String,
25    pub model: String,
26    pub mac_address: String,
27    pub ip_address: String,
28    pub state: DeviceState,
29    pub features: Vec<String>,
30    pub interfaces: Vec<String>,
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(rename_all = "camelCase")]
35pub struct DevicePhysicalInterfaces {
36    #[serde(default)]
37    pub ports: Vec<EthernetPortOverview>,
38    #[serde(default)]
39    pub radios: Vec<WirelessRadioOverview>,
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
43#[serde(rename_all = "camelCase")]
44pub struct EthernetPortOverview {
45    pub idx: i32,
46    pub state: PortState,
47    pub connector: ConnectorType,
48    pub max_speed_mbps: i32,
49    pub speed_mbps: i32,
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(rename_all = "camelCase")]
54pub struct WirelessRadioOverview {
55    pub wlan_standard: Option<WlanStandard>,
56    #[serde(default, rename = "frequencyGHz")]
57    pub frequency_ghz: Option<FrequencyBand>,
58    #[serde(default, rename = "channelWidthMHz")]
59    pub channel_width_mhz: Option<i32>,
60    pub channel: Option<i32>,
61}
62
63#[derive(Debug, Clone, Serialize, Deserialize)]
64#[serde(rename_all = "camelCase")]
65pub struct DeviceDetails {
66    pub id: Uuid,
67    pub name: String,
68    pub model: String,
69    pub supported: bool,
70    pub mac_address: String,
71    pub ip_address: String,
72    pub state: DeviceState,
73    pub firmware_version: String,
74    pub firmware_updatable: bool,
75    pub adopted_at: Option<DateTime<Utc>>,
76    pub provisioned_at: Option<DateTime<Utc>>,
77    pub configuration_id: String,
78    #[serde(default)]
79    pub uplink: Option<DeviceUplinkInterface>,
80    #[serde(default)]
81    pub features: Option<DeviceFeatures>,
82    #[serde(default)]
83    pub interfaces: Option<DevicePhysicalInterfaces>,
84}
85
86#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(rename_all = "camelCase")]
88pub struct DeviceUplinkInterface {
89    pub device_id: Uuid,
90}
91
92#[derive(Debug, Clone, Serialize, Deserialize)]
93#[serde(rename_all = "camelCase")]
94pub struct DeviceFeatures {
95    pub switching: Option<SwitchFeatureOverview>,
96    pub access_point: Option<AccessPointFeatureOverview>,
97}
98
99#[derive(Debug, Clone, Serialize, Deserialize)]
100pub struct SwitchFeatureOverview {}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
103pub struct AccessPointFeatureOverview {}