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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
//! `Client` methods for the `SecurityAPI` domain, v8.0.4.
//!
//! Ported from `eero-api src/eero/client.py:2205-2801` (the Security/MLO/fast-transition/
//! Passpoint/proxied-nodes group of `EeroClient`). Every method below passes
//! `**self._network_parent_kwargs(network_id)` in Python — this port's [`Client::network_parent`]
//! equivalent.
//!
//! **`Client::set_thread_enabled` is not defined here.** The old `SecurityAPI.set_thread` write
//! this method used to wrap is fully removed upstream (replaced by the `ThreadAPI` family) — see
//! [`crate::client::Client::set_thread_enabled`] in `src/client/thread.rs`, the v8.0.4
//! replacement wrapping the new `ThreadAPI.set_thread_enabled`.
use super::Client;
use crate::envelope::Envelope;
use crate::error::Error;
impl Client {
// ==================== Security ====================
/// Gets security settings — returns the raw Eero API response.
///
/// Ported from `get_security_settings()` (`client.py:2205-2208`). `auto_discover = false` —
/// see [`Client::get_diagnostics`].
///
/// # Errors
///
/// See [`Client::get_diagnostics`].
pub async fn get_security_settings(&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
.security()
.get_security_settings(&network_id, parent.as_ref())
.await
}
// ==================== Security (mutations) ====================
/// Enables or disables WPA3 encryption — returns the raw Eero API response.
///
/// Ported from `set_wpa3` (`client.py:2212-2219`). `auto_discover = false`. On success,
/// invalidates `network[nid]`.
///
/// # Errors
///
/// See [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn set_wpa3(
&self,
enabled: bool,
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);
let response = self
.api
.security()
.set_wpa3(&network_id, enabled, parent.as_ref())
.await?;
self.invalidate_network_cache(&network_id);
Ok(response)
}
/// Enables or disables band steering — returns the raw Eero API response.
///
/// Ported from `set_band_steering` (`client.py:2221-2229`). `auto_discover = false`. On
/// success, invalidates `network[nid]`.
///
/// # Errors
///
/// See [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn set_band_steering(
&self,
enabled: bool,
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);
let response = self
.api
.security()
.set_band_steering(&network_id, enabled, parent.as_ref())
.await?;
self.invalidate_network_cache(&network_id);
Ok(response)
}
/// Enables or disables `UPnP` — returns the raw Eero API response.
///
/// Ported from `set_upnp` (`client.py:2232-2239`). `auto_discover = false`. On success,
/// invalidates `network[nid]`.
///
/// # Errors
///
/// See [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn set_upnp(
&self,
enabled: bool,
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);
let response = self
.api
.security()
.set_upnp(&network_id, enabled, parent.as_ref())
.await?;
self.invalidate_network_cache(&network_id);
Ok(response)
}
/// Enables or disables IPv6 (both upstream and downstream) — returns the raw Eero API
/// response.
///
/// Ported from `set_ipv6` (`client.py:2241-2248`). `auto_discover = false`. On success,
/// invalidates `network[nid]`.
///
/// # Errors
///
/// See [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn set_ipv6(
&self,
enabled: bool,
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);
let response = self
.api
.security()
.set_ipv6(&network_id, enabled, parent.as_ref())
.await?;
self.invalidate_network_cache(&network_id);
Ok(response)
}
/// Configures multiple security settings in one call — returns the raw Eero API response.
///
/// Ported from `configure_security` (`client.py:2250-2269`). **`thread` is not a parameter**
/// — see [`crate::endpoints::security::SecurityApi::configure_security`]'s own docs for why.
/// `auto_discover = false`. On success, invalidates `network[nid]`.
///
/// # Errors
///
/// Returns `Error::Validation` if every argument is `None` — see
/// [`crate::endpoints::security::SecurityApi::configure_security`]'s own docs. Otherwise see
/// [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn configure_security(
&self,
wpa3: Option<bool>,
band_steering: Option<bool>,
upnp: Option<bool>,
ipv6: Option<bool>,
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);
let response = self
.api
.security()
.configure_security(
&network_id,
wpa3,
band_steering,
upnp,
ipv6,
parent.as_ref(),
)
.await?;
self.invalidate_network_cache(&network_id);
Ok(response)
}
// ==================== MLO, fast transition, Passpoint, proxied nodes (new in v8.0.0) ====================
/// Sets the network's MLO (Multi-Link Operation) mode — returns the raw Eero API response
/// (unverified; may reboot the mesh).
///
/// Ported from `set_mlo_mode` (`client.py:2763-2769`). `auto_discover = false`. On success,
/// invalidates `network[nid]`.
///
/// # Errors
///
/// Returns `Error::Validation { field: "mode", .. }` for an unrecognised mode — see
/// [`crate::endpoints::security::SecurityApi::set_mlo_mode`]. Otherwise see
/// [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn set_mlo_mode(
&self,
mode: &str,
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);
let response = self
.api
.security()
.set_mlo_mode(&network_id, mode, parent.as_ref())
.await?;
self.invalidate_network_cache(&network_id);
Ok(response)
}
/// Gets the network's 802.11r fast-transition setting — returns the raw Eero API response
/// (verified read).
///
/// Ported from `get_fast_transition` (`client.py:2772-2777`). `auto_discover = false`.
///
/// # Errors
///
/// See [`Client::get_diagnostics`].
pub async fn get_fast_transition(&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
.security()
.get_fast_transition(&network_id, parent.as_ref())
.await
}
/// Sets fast transition — returns the raw Eero API response (unverified; may reboot the
/// mesh).
///
/// Ported from `set_fast_transition` (`client.py:2779-2788`). `auto_discover = false`. On
/// success, invalidates `network[nid]`.
///
/// # Errors
///
/// See [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn set_fast_transition(
&self,
enabled: bool,
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);
let response = self
.api
.security()
.set_fast_transition(&network_id, enabled, parent.as_ref())
.await?;
self.invalidate_network_cache(&network_id);
Ok(response)
}
/// Enables or disables Passpoint — returns the raw Eero API response (unverified write).
///
/// Ported from `set_passpoint_enabled` (`client.py:2790-2799`). `auto_discover = false`. On
/// success, invalidates `network[nid]`.
///
/// # Errors
///
/// See [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn set_passpoint_enabled(
&self,
enabled: bool,
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);
let response = self
.api
.security()
.set_passpoint_enabled(&network_id, enabled, parent.as_ref())
.await?;
self.invalidate_network_cache(&network_id);
Ok(response)
}
/// Enables or disables proxied nodes — returns the raw Eero API response (unverified write).
///
/// Ported from `set_proxied_nodes` (`client.py:2801-2810`). `auto_discover = false`. On
/// success, invalidates `network[nid]`.
///
/// # Errors
///
/// See [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn set_proxied_nodes(
&self,
enabled: bool,
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);
let response = self
.api
.security()
.set_proxied_nodes(&network_id, enabled, parent.as_ref())
.await?;
self.invalidate_network_cache(&network_id);
Ok(response)
}
}