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
//! `Client` methods for the `DhcpAPI` domain (new in v8.0.0).
use super::Client;
use crate::envelope::Envelope;
use crate::error::Error;
use serde_json::{Map, Value};
impl Client {
// ==================== DHCP, Connection Mode & NAT ====================
/// Sets the network's DHCP configuration — returns the raw Eero API response.
///
/// Ported from `set_dhcp` (`eero-api src/eero/client.py:3488-3512`). `auto_discover =
/// false`. Passes the network's cached envelope (if fresh) as `parent`. Invalidates
/// `network[{nid}]` unconditionally after the write.
///
/// `mode` is `"automatic"`, `"manual"` or `"custom"`; `"manual"` is sent as `"custom"`, the
/// wire value the API accepts (see [`crate::endpoints::dhcp::DhcpApi::set_dhcp`]).
///
/// # Warning
///
/// A settings-class write confirmed (`eero-api` issue #136) to restart every eero on the
/// mesh — roughly an eight-minute outage each time, the same as the confirmed DNS write on
/// this endpoint. Read the network first and skip the write when it is unchanged; never
/// retry.
///
/// # Errors
///
/// See [`Client::get_diagnostics`], plus whatever [`crate::endpoints::dhcp::DhcpApi::set_dhcp`]
/// itself validates.
pub async fn set_dhcp(
&self,
mode: Option<&str>,
custom: Option<&Map<String, Value>>,
custom_v2: Option<&Map<String, 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);
let response = self
.api
.dhcp()
.set_dhcp(&network_id, mode, custom, custom_v2, parent.as_ref())
.await?;
self.invalidate_network_cache(&network_id);
Ok(response)
}
/// Sets the network's WAN connection mode — returns the raw Eero API response.
///
/// Ported from `set_connection_mode` (`eero-api src/eero/client.py:3514-3523`).
/// `auto_discover = false`. Passes the network's cached envelope (if fresh) as `parent`.
/// Invalidates `network[{nid}]` unconditionally after the write.
///
/// # Errors
///
/// See [`Client::get_diagnostics`], plus whatever
/// [`crate::endpoints::dhcp::DhcpApi::set_connection_mode`] itself validates.
pub async fn set_connection_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
.dhcp()
.set_connection_mode(&network_id, mode, parent.as_ref())
.await?;
self.invalidate_network_cache(&network_id);
Ok(response)
}
/// Sets NAT port randomization — returns the raw Eero API response.
///
/// Ported from `set_nat_port_randomization` (`eero-api src/eero/client.py:3525-3534`).
/// `auto_discover = false`. Passes the network's cached envelope (if fresh) as `parent`.
/// Invalidates `network[{nid}]` unconditionally after the write.
///
/// # Errors
///
/// See [`Client::get_diagnostics`].
pub async fn set_nat_port_randomization(
&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
.dhcp()
.set_nat_port_randomization(&network_id, enabled, parent.as_ref())
.await?;
self.invalidate_network_cache(&network_id);
Ok(response)
}
/// Sets `PPPoE` credentials on an eero — returns the raw Eero API response.
///
/// Ported from `set_pppoe` (`eero-api src/eero/client.py:3536-3541`). Not network-scoped —
/// no `_ensure_network_id` call, no cache interaction — `eero_serial_or_id` addresses the
/// eero directly.
///
/// # Errors
///
/// See [`Client::get_diagnostics`].
pub async fn set_pppoe(
&self,
eero_serial_or_id: &str,
username: &str,
password: &str,
) -> Result<Envelope, Error> {
self.api
.dhcp()
.set_pppoe(eero_serial_or_id, username, password)
.await
}
}