asterust-junos 0.3.7

Typed Juniper JunOS config views (interfaces, OSPF, BGP, IS-IS, routing instances, policy options, firewall filters, system) extracted from an asterust config tree.
Documentation
//! `dynamic-profile-options`
//! `system { dynamic-profile-options { ... } }`.
//!
//! # See also
//!
//! - [dynamic-profile-options](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/dynamic-profile-options-edit-system.html)

use crate::has_leaf;
use asterust::config::ConfigLine;

/// The `system dynamic-profile-options` settings.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct DynamicProfileOptions {
    pub versioning: bool,
}

pub(super) fn parse_dynamic_profile_options(options: &ConfigLine) -> DynamicProfileOptions {
    DynamicProfileOptions {
        versioning: has_leaf(options, "versioning"),
    }
}

#[cfg(test)]
mod tests {
    use crate::system::system;
    use asterust::config::juniper;

    // Not from documentation: written from the CLI Reference syntax pages. See the README "Sources".
    #[test]
    fn extracts_dynamic_profile_options() {
        let system = system(&juniper::parse_braces(
            "system {\n    dynamic-profile-options {\n        versioning;\n    }\n}\n",
        ))
        .unwrap();
        assert!(system.dynamic_profile_options.unwrap().versioning);
    }
}