Skip to main content

unifly_api/integration/client/
networks.rs

1use uuid::Uuid;
2
3use super::{Error, IntegrationClient, types};
4
5impl IntegrationClient {
6    // ── Networks ─────────────────────────────────────────────────────
7
8    pub async fn list_networks(
9        &self,
10        site_id: &Uuid,
11        offset: i64,
12        limit: i32,
13    ) -> Result<types::Page<types::NetworkResponse>, Error> {
14        self.get_with_params(
15            &format!("v1/sites/{site_id}/networks"),
16            &[("offset", offset.to_string()), ("limit", limit.to_string())],
17        )
18        .await
19    }
20
21    pub async fn get_network(
22        &self,
23        site_id: &Uuid,
24        network_id: &Uuid,
25    ) -> Result<types::NetworkDetailsResponse, Error> {
26        self.get(&format!("v1/sites/{site_id}/networks/{network_id}"))
27            .await
28    }
29
30    pub async fn create_network(
31        &self,
32        site_id: &Uuid,
33        body: &types::NetworkCreateUpdate,
34    ) -> Result<types::NetworkDetailsResponse, Error> {
35        self.post(&format!("v1/sites/{site_id}/networks"), body)
36            .await
37    }
38
39    pub async fn update_network(
40        &self,
41        site_id: &Uuid,
42        network_id: &Uuid,
43        body: &types::NetworkCreateUpdate,
44    ) -> Result<types::NetworkDetailsResponse, Error> {
45        self.put(&format!("v1/sites/{site_id}/networks/{network_id}"), body)
46            .await
47    }
48
49    pub async fn delete_network(&self, site_id: &Uuid, network_id: &Uuid) -> Result<(), Error> {
50        self.delete(&format!("v1/sites/{site_id}/networks/{network_id}"))
51            .await
52    }
53
54    pub async fn get_network_references(
55        &self,
56        site_id: &Uuid,
57        network_id: &Uuid,
58    ) -> Result<types::NetworkReferencesResponse, Error> {
59        self.get(&format!(
60            "v1/sites/{site_id}/networks/{network_id}/references"
61        ))
62        .await
63    }
64}