Skip to main content

unifly_api/session/
networkconf.rs

1// Legacy networkconf operations.
2//
3// Site-to-site VPN, VPN server, and VPN client records are stored in the
4// classic `rest/networkconf` collection behind the legacy API.
5
6use serde_json::Value;
7use tracing::debug;
8
9use super::SessionClient;
10use crate::error::Error;
11
12impl SessionClient {
13    /// List raw networkconf records for the current site.
14    pub async fn list_network_conf(&self) -> Result<Vec<Value>, Error> {
15        let url = self.site_url("rest/networkconf");
16        debug!("listing networkconf records");
17        self.get(url).await
18    }
19
20    /// Create a networkconf record for the current site.
21    pub async fn create_network_conf(&self, body: &Value) -> Result<Vec<Value>, Error> {
22        let url = self.site_url("rest/networkconf");
23        debug!("creating networkconf record");
24        self.post(url, body).await
25    }
26
27    /// Update a networkconf record for the current site.
28    pub async fn update_network_conf(
29        &self,
30        record_id: &str,
31        body: &Value,
32    ) -> Result<Vec<Value>, Error> {
33        let url = self.site_url(&format!("rest/networkconf/{record_id}"));
34        debug!(record_id, "updating networkconf record");
35        self.put(url, body).await
36    }
37
38    /// Delete a networkconf record for the current site.
39    pub async fn delete_network_conf(&self, record_id: &str) -> Result<Vec<Value>, Error> {
40        let url = self.site_url(&format!("rest/networkconf/{record_id}"));
41        debug!(record_id, "deleting networkconf record");
42        self.delete(url).await
43    }
44}