asterust_junos/interfaces/auto_configure/
ranges.rs1use crate::{arg_of, args_of, child_block, named_children};
11use asterust::config::ConfigLine;
12
13#[derive(Clone, Debug, PartialEq, Eq)]
15#[non_exhaustive]
16pub struct AutoConfigureProfile {
17 pub name: String,
18 pub accept: Vec<String>,
20 pub access_profile: Option<String>,
21 pub ranges: Option<String>,
23}
24
25#[derive(Clone, Debug, PartialEq, Eq)]
28#[non_exhaustive]
29pub struct AutoConfigureRanges {
30 pub access_profile: Option<String>,
31 pub dynamic_profiles: Vec<AutoConfigureProfile>,
32 pub has_authentication: bool,
34 pub authentication_password: Option<crate::Secret>,
36}
37
38pub(super) fn parse_ranges(ranges: &ConfigLine) -> AutoConfigureRanges {
39 AutoConfigureRanges {
40 access_profile: arg_of(ranges, "access-profile").map(str::to_string),
41 dynamic_profiles: named_children(ranges, "dynamic-profile")
42 .map(|(name, profile)| AutoConfigureProfile {
43 name: name.to_string(),
44 accept: args_of(profile, "accept").into_iter().map(str::to_string).collect(),
45 access_profile: arg_of(profile, "access-profile").map(str::to_string),
46 ranges: arg_of(profile, "ranges").map(str::to_string),
47 })
48 .collect(),
49 has_authentication: child_block(ranges, "authentication").is_some(),
50 authentication_password: crate::secret_value(
51 child_block(ranges, "authentication").and_then(|auth| arg_of(auth, "password")),
52 ),
53 }
54}