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
//! `Client` methods for the `DnsPoliciesAPI` domain (new in v8.0.0).
//!
//! Ported from `eero-api`'s `EeroClient` dns_policies-scoped wrappers
//! (`.claude/tasks/briefs/v8/client.md` §4 "`dns_policies` (entirely new — no v6.2.0 equivalent)").
//! Every method here passes `auto_discover = false` (`client.md`'s `net_id` column is `—` for the
//! whole table) and, except [`Client::get_dns_policy_applications`]/
//! [`Client::set_profile_blocked_applications`] (no published link for that sub-tree — see
//! [`crate::endpoints::dns_policies::DnsPoliciesApi::get_profile_applications`]'s docs), passes
//! the cached network envelope as `parent=` (`+net`).
use super::Client;
use crate::envelope::Envelope;
use crate::error::Error;
impl Client {
/// Gets the network's advanced content filter allow/block lists — returns the raw Eero API
/// response.
///
/// Ported from `get_advanced_content_filter` (`eero-api src/eero/client.py:2430-2437`).
///
/// # Errors
///
/// See [`Client::get_diagnostics`].
pub async fn get_advanced_content_filter(
&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.as_str());
self.api
.dns_policies()
.get_advanced_content_filter(&network_id, parent.as_ref())
.await
}
/// Adds (or removes) a domain from the network-wide allow list — returns the raw Eero API
/// response.
///
/// Ported from `allow_domain` (`eero-api src/eero/client.py:2437-2464`). On success,
/// invalidates `network[{nid}]`.
///
/// # Errors
///
/// See [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn allow_domain(
&self,
domain: &str,
add_cname: Option<bool>,
reason_to_allow: Option<i64>,
is_delete: Option<bool>,
keep_profiles: 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.as_str());
let response = self
.api
.dns_policies()
.allow_domain(
&network_id,
domain,
add_cname,
reason_to_allow,
is_delete,
keep_profiles,
parent.as_ref(),
)
.await?;
self.invalidate_network_cache(network_id.as_str());
Ok(response)
}
/// Allows a list of CNAME domains network-wide — returns the raw Eero API response.
///
/// Ported from `allow_cnames` (`eero-api src/eero/client.py:2464-2475`). On success,
/// invalidates `network[{nid}]`.
///
/// # Errors
///
/// See [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn allow_cnames(
&self,
domains: &[&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.as_str());
let response = self
.api
.dns_policies()
.allow_cnames(&network_id, domains, parent.as_ref())
.await?;
self.invalidate_network_cache(network_id.as_str());
Ok(response)
}
/// Adds (or removes) a domain from the network-wide block list — returns the raw Eero API
/// response.
///
/// Ported from `block_domain` (`eero-api src/eero/client.py:2475-2495`). On success,
/// invalidates `network[{nid}]`.
///
/// # Errors
///
/// See [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn block_domain(
&self,
domain: &str,
is_delete: Option<bool>,
keep_profiles: 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.as_str());
let response = self
.api
.dns_policies()
.block_domain(
&network_id,
domain,
is_delete,
keep_profiles,
parent.as_ref(),
)
.await?;
self.invalidate_network_cache(network_id.as_str());
Ok(response)
}
/// Adds (or removes) a domain from one or more profiles' allow lists — returns the raw Eero
/// API response.
///
/// Ported from `allow_domain_for_profiles` (`eero-api src/eero/client.py:2495-2521`). On
/// success, invalidates `profiles[{nid}_profiles]` — **not** `network[{nid}]`, despite `+net`
/// parent passing (`client.md` §4 flags this invalidation-target/parent-source mismatch
/// explicitly).
///
/// # Errors
///
/// See [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
#[allow(clippy::too_many_arguments)] // mirrors client.py:2495-2505's own signature
pub async fn allow_domain_for_profiles(
&self,
domain: &str,
profiles: &[&str],
override_: Option<bool>,
add_cname: Option<bool>,
reason_to_allow: Option<i64>,
is_delete: 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.as_str());
let response = self
.api
.dns_policies()
.allow_domain_for_profiles(
&network_id,
domain,
profiles,
override_,
add_cname,
reason_to_allow,
is_delete,
parent.as_ref(),
)
.await?;
self.invalidate_profiles_list_cache(network_id.as_str());
Ok(response)
}
/// Allows a list of CNAME domains for one or more profiles — returns the raw Eero API
/// response.
///
/// Ported from `allow_cnames_for_profiles` (`eero-api src/eero/client.py:2521-2532`). On
/// success, invalidates `profiles[{nid}_profiles]`.
///
/// # Errors
///
/// See [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn allow_cnames_for_profiles(
&self,
domains: &[&str],
profiles: &[&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.as_str());
let response = self
.api
.dns_policies()
.allow_cnames_for_profiles(&network_id, domains, profiles, parent.as_ref())
.await?;
self.invalidate_profiles_list_cache(network_id.as_str());
Ok(response)
}
/// Adds (or removes) a domain from one or more profiles' block lists — returns the raw Eero
/// API response.
///
/// Ported from `block_domain_for_profiles` (`eero-api src/eero/client.py:2532-2554`). On
/// success, invalidates `profiles[{nid}_profiles]`.
///
/// # Errors
///
/// See [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn block_domain_for_profiles(
&self,
domain: &str,
profiles: &[&str],
is_delete: Option<bool>,
override_: 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.as_str());
let response = self
.api
.dns_policies()
.block_domain_for_profiles(
&network_id,
domain,
profiles,
is_delete,
override_,
parent.as_ref(),
)
.await?;
self.invalidate_profiles_list_cache(network_id.as_str());
Ok(response)
}
/// Gets the applications a profile can block, and which are blocked — returns the raw Eero
/// API response.
///
/// Ported from `get_dns_policy_applications` (`eero-api src/eero/client.py:2554-2561`) — the
/// `EeroClient` wrapper name for the domain method
/// `DnsPoliciesAPI.get_profile_applications` (wiki `API-Reference.md:300`). No `parent=`: the
/// domain method itself accepts none.
///
/// # Errors
///
/// See [`Client::get_diagnostics`].
pub async fn get_dns_policy_applications(
&self,
profile_id: &str,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
self.api
.dns_policies()
.get_profile_applications(&network_id, profile_id)
.await
}
/// Sets the applications blocked for a profile — returns the raw Eero API response.
///
/// Ported from `set_profile_blocked_applications` (`eero-api src/eero/client.py:2561-2574`).
/// No `parent=`. On success, invalidates `profiles[{nid}_{pid}]` and
/// `profiles[{nid}_profiles]`.
///
/// # Errors
///
/// See [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn set_profile_blocked_applications(
&self,
profile_id: &str,
applications: &[&str],
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
let response = self
.api
.dns_policies()
.set_profile_blocked_applications(&network_id, profile_id, applications)
.await?;
self.invalidate_profile_cache(network_id.as_str(), profile_id);
Ok(response)
}
}