asterust_junos/interfaces/auto_configure/
ranges.rs1use crate::{arg_of, args_of, child_block, named_children};
4use asterust::config::ConfigLine;
5
6#[derive(Clone, Debug, PartialEq, Eq)]
8#[non_exhaustive]
9pub struct AutoConfigureProfile {
10 pub name: String,
11 pub accept: Vec<String>,
13 pub access_profile: Option<String>,
14 pub ranges: Option<String>,
16}
17
18#[derive(Clone, Debug, PartialEq, Eq)]
20#[non_exhaustive]
21pub struct AutoConfigureRanges {
22 pub access_profile: Option<String>,
23 pub dynamic_profiles: Vec<AutoConfigureProfile>,
24 pub has_authentication: bool,
26}
27
28pub(super) fn parse_ranges(ranges: &ConfigLine) -> AutoConfigureRanges {
29 AutoConfigureRanges {
30 access_profile: arg_of(ranges, "access-profile").map(str::to_string),
31 dynamic_profiles: named_children(ranges, "dynamic-profile")
32 .map(|(name, profile)| AutoConfigureProfile {
33 name: name.to_string(),
34 accept: args_of(profile, "accept").into_iter().map(str::to_string).collect(),
35 access_profile: arg_of(profile, "access-profile").map(str::to_string),
36 ranges: arg_of(profile, "ranges").map(str::to_string),
37 })
38 .collect(),
39 has_authentication: child_block(ranges, "authentication").is_some(),
40 }
41}