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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
//! `Client` methods for the `SecurityAPI` domain, v8.4.1.
//!
//! Ported from `eero-api src/eero/client.py:2852-2960` and `:3571-3620` (the Security and
//! MLO/fast-transition/Passpoint/proxied-nodes groups of `EeroClient`). Every method below passes
//! `**self._network_parent_kwargs(network_id)` in Python — this port's [`Client::network_parent`]
//! equivalent — except [`Client::set_ipv6_upstream`], which takes a caller `parent` and passes
//! `**self._network_parent_kwargs_or(network_id, parent)`.
//!
//! **`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 replacement
//! wrapping `ThreadAPI.set_thread_enabled`.
use super::Client;
use crate::envelope::Envelope;
use crate::error::Error;
use serde_json::Value;
impl Client {
// ==================== Security ====================
/// Gets security settings — returns the raw Eero API response.
///
/// Ported from `get_security_settings()` (`client.py:2852-2857`). `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:2859-2866`). `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:2868-2877`). `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:2879-2886`). `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:2888-2895`). `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)
}
/// Enables or disables IPv6 on the upstream (WAN) side only — returns the raw Eero API
/// response.
///
/// Ported from `set_ipv6_upstream` (`client.py:2897-2937`), new at `v8.4.0`. `auto_discover =
/// false`. Forwards the caller's `parent` when supplied, otherwise the fresh cached network
/// envelope (`_network_parent_kwargs_or`), and sends only `{"ipv6_upstream": enabled}` to the
/// `settings` link — it never calls [`Client::set_ipv6`], which writes both flags. This is the
/// upstream connectivity toggle, **not** IPv6 DNS. On success, invalidates `network[nid]` only;
/// the eeros and devices caches are untouched.
///
/// **Settings-class write**: unverified against a live account, and the DNS write on the same
/// `settings` endpoint is confirmed to reboot every eero on the mesh, so treat this one as
/// capable of the same. Read the current configuration first, skip the write when it already
/// matches, and never retry a failed write in a loop.
///
/// # Errors
///
/// See [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn set_ipv6_upstream(
&self,
enabled: bool,
network_id: Option<&str>,
parent: Option<&Value>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
let parent = self.network_parent_or(&network_id, parent);
let response = self
.api
.security()
.set_ipv6_upstream(&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:2939-2960`). **`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:3571-3578`). `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:3580-3585`). `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:3587-3596`). `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:3598-3607`). `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:3609-3620`). `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)
}
}