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
//! `Client` methods for the `DnsAPI` domain, v8.0.4.
//!
//! Ported from `eero-api src/eero/client.py:2080-2158` (the DNS group of `EeroClient`). Every
//! write below passes `**self._network_parent_kwargs(network_id)` in Python
//! (`client.py:2080-2158`) — this port's [`Client::network_parent`] equivalent — except
//! [`Client::get_dns_settings`], whose underlying [`crate::endpoints::dns::DnsApi::get_dns_settings`]
//! has no `parent` parameter at all (see that method's own docs).
use super::Client;
use crate::envelope::Envelope;
use crate::error::Error;
impl Client {
// ==================== DNS ====================
/// Gets DNS settings — returns the raw Eero API response.
///
/// Ported from `get_dns_settings()` (`client.py:2080-2083`). `auto_discover = false` — see
/// [`Client::get_diagnostics`].
///
/// # Errors
///
/// See [`Client::get_diagnostics`].
pub async fn get_dns_settings(&self, network_id: Option<&str>) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
self.api.dns().get_dns_settings(&network_id).await
}
// ==================== DNS (mutations) ====================
/// Enables or disables DNS caching — returns the raw Eero API response.
///
/// Ported from `set_dns_caching` (`client.py:2094-2102`). `auto_discover = false`. On
/// success, invalidates `network[nid]` — DNS settings live inside the network resource, so
/// any DNS write makes a cached snapshot stale (mirrors `client.py`'s own
/// `_invalidate_network_cache`, `client.py:2085-2092`).
///
/// # Errors
///
/// See [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn set_dns_caching(
&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
.dns()
.set_dns_caching(&network_id, enabled, parent.as_ref())
.await?;
self.invalidate_network_cache(&network_id);
Ok(response)
}
/// Sets custom DNS servers from a mixed IPv4/IPv6 list — returns the raw Eero API response.
///
/// Ported from `set_custom_dns` (`client.py:2105-2113`). `auto_discover = false`. On success,
/// invalidates `network[nid]` — see [`Client::set_dns_caching`].
///
/// # Errors
///
/// See [`crate::endpoints::dns::DnsApi::set_custom_dns`], otherwise
/// [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn set_custom_dns(
&self,
dns_servers: &[&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
.dns()
.set_custom_dns(&network_id, dns_servers, parent.as_ref())
.await?;
self.invalidate_network_cache(&network_id);
Ok(response)
}
/// Sets the IPv4 custom DNS servers, leaving IPv6 untouched — returns the raw Eero API
/// response.
///
/// Ported from `set_custom_dns_ipv4` (`client.py:2116-2124`). `auto_discover = false`. On
/// success, invalidates `network[nid]` — see [`Client::set_dns_caching`].
///
/// # Errors
///
/// See [`crate::endpoints::dns::DnsApi::set_custom_dns_ipv4`], otherwise
/// [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn set_custom_dns_ipv4(
&self,
dns_servers: &[&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
.dns()
.set_custom_dns_ipv4(&network_id, dns_servers, parent.as_ref())
.await?;
self.invalidate_network_cache(&network_id);
Ok(response)
}
/// Sets the IPv6 custom DNS servers, leaving IPv4 untouched — returns the raw Eero API
/// response.
///
/// Ported from `set_custom_dns_ipv6` (`client.py:2127-2135`). `auto_discover = false`. On
/// success, invalidates `network[nid]` — see [`Client::set_dns_caching`].
///
/// # Errors
///
/// See [`crate::endpoints::dns::DnsApi::set_custom_dns_ipv6`], otherwise
/// [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn set_custom_dns_ipv6(
&self,
dns_servers: &[&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
.dns()
.set_custom_dns_ipv6(&network_id, dns_servers, parent.as_ref())
.await?;
self.invalidate_network_cache(&network_id);
Ok(response)
}
/// Switches DNS back to automatic (non-destructive) — returns the raw Eero API response.
///
/// Ported from `clear_custom_dns` (`client.py:2138-2151`). `family = Some("ipv4")`/
/// `Some("ipv6")` clears one family only; `None` (the default) clears both.
/// `auto_discover = false`. On success, invalidates `network[nid]` — see
/// [`Client::set_dns_caching`].
///
/// # Errors
///
/// See [`crate::endpoints::dns::DnsApi::clear_custom_dns`], otherwise
/// [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn clear_custom_dns(
&self,
family: Option<&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
.dns()
.clear_custom_dns(&network_id, family, parent.as_ref())
.await?;
self.invalidate_network_cache(&network_id);
Ok(response)
}
/// Sets DNS mode — returns the raw Eero API response.
///
/// Ported from `set_dns_mode` (`client.py:2153-2163`). `auto_discover = false`. On success,
/// invalidates `network[nid]` — see [`Client::set_dns_caching`].
///
/// # Errors
///
/// See [`crate::endpoints::dns::DnsApi::set_dns_mode`], otherwise
/// [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn set_dns_mode(
&self,
mode: &str,
custom_servers: Option<&[&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
.dns()
.set_dns_mode(&network_id, mode, custom_servers, parent.as_ref())
.await?;
self.invalidate_network_cache(&network_id);
Ok(response)
}
}