Skip to main content

unifly_api/session/
system_log.rs

1// Session API system log endpoints (v2)
2//
3// Covers client connection timeline queries from the raw JSON system-log
4// surface.
5
6use serde_json::Value;
7use tracing::debug;
8
9use crate::error::Error;
10use crate::session::client::SessionClient;
11
12impl SessionClient {
13    /// Get a client's connection timeline: connects, disconnects, and roams.
14    ///
15    /// `GET /v2/api/site/{site}/system-log/client-connection/{mac}`
16    ///
17    /// **Quirk:** the MAC must appear in both the URL path and the
18    /// `?mac=` query parameter.
19    pub async fn get_client_roams(
20        &self,
21        mac: &str,
22        limit: Option<u32>,
23    ) -> Result<Vec<Value>, Error> {
24        let limit = limit.unwrap_or(200);
25        let path = format!(
26            "system-log/client-connection/{mac}?mac={mac}&separateConnectionSignalParam=false&limit={limit}"
27        );
28        let url = self.site_url_v2(&path);
29        debug!(mac, limit, "fetching client roam timeline");
30        let value = self.get_raw(url).await?;
31        Ok(match value {
32            Value::Array(items) => items,
33            other => vec![other],
34        })
35    }
36}