1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! `Client` methods for the `ForwardsAPI` domain.
use super::Client;
use crate::envelope::Envelope;
use crate::error::Error;
use serde_json::Value;
impl Client {
/// Gets port forwards — returns the raw Eero API response.
///
/// Ported from `get_forwards()` (`eero-api src/eero/client.py:1538-1543`). `auto_discover =
/// false`. Passes the network's cached envelope (if fresh) as `parent`, matching
/// `_network_parent_kwargs`. The request always goes to API version 2.2, even when that
/// envelope publishes its `forwards` link on 2.3; see
/// [`crate::endpoints::forwards::ForwardsApi::get_forwards`].
///
/// # Errors
///
/// See [`Client::get_diagnostics`].
pub async fn get_forwards(&self, network_id: Option<&str>) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
let parent = self.network_parent(&network_id);
self.api
.forwards()
.get_forwards(&network_id, parent.as_ref())
.await
}
// ==================== Forwards ====================
/// Creates a port forward on the network — returns the raw Eero API response.
///
/// Ported from `create_forward` (`eero-api src/eero/client.py:1545-1552`). `auto_discover =
/// false`. Invalidates nothing: there is no `forwards` cache bucket.
///
/// # Errors
///
/// See [`Client::get_diagnostics`].
pub async fn create_forward(
&self,
forward_data: Value,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
let parent = self.network_parent(&network_id);
self.api
.forwards()
.create_forward(&network_id, forward_data, parent.as_ref())
.await
}
/// Updates a port forward on the network — returns the raw Eero API response.
///
/// Ported from `update_forward` (`eero-api src/eero/client.py:1554-1563`). `auto_discover =
/// false` — unlike every other row in this file, `network_id` is resolved and forwarded to
/// the domain call as `network=Some(..)` unconditionally (Python's `network=network_id`
/// after `_ensure_network_id`), not passed straight through as `Option`. No `parent=`
/// forwarded, matching Python exactly. Invalidates nothing — see
/// [`Client::create_forward`].
///
/// # Errors
///
/// See [`Client::get_diagnostics`].
pub async fn update_forward(
&self,
forward_id: &str,
forward_data: Value,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
self.api
.forwards()
.update_forward(forward_id, forward_data, Some(&network_id), None)
.await
}
/// Deletes a port forward from the network — returns the raw Eero API response.
///
/// Ported from `delete_forward` (`eero-api src/eero/client.py:1564-1569`). `auto_discover =
/// false`. Invalidates nothing — see [`Client::create_forward`].
///
/// # Errors
///
/// See [`Client::get_diagnostics`].
pub async fn delete_forward(
&self,
forward_id: &str,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
self.api
.forwards()
.delete_forward(&network_id, forward_id)
.await
}
}