asterust_junos/system/services/
static_subscribers.rs1use crate::{arg_of, args_of, named_children};
9use asterust::config::ConfigLine;
10
11#[derive(Clone, Debug, PartialEq, Eq)]
13#[non_exhaustive]
14pub struct StaticSubscriberProfile {
15 pub name: String,
16 pub aggregate_clients: Option<String>,
18}
19
20#[derive(Clone, Debug, PartialEq, Eq)]
22#[non_exhaustive]
23pub struct StaticSubscriberGroup {
24 pub name: String,
25 pub access_profile: Option<String>,
26 pub dynamic_profiles: Vec<StaticSubscriberProfile>,
27 pub interfaces: Vec<String>,
30}
31
32#[derive(Clone, Debug, PartialEq, Eq)]
35#[non_exhaustive]
36pub struct StaticSubscribers {
37 pub access_profile: Option<String>,
38 pub service_profile: Option<String>,
39 pub groups: Vec<StaticSubscriberGroup>,
40}
41
42pub(super) fn parse_static_subscribers(subscribers: &ConfigLine) -> StaticSubscribers {
43 StaticSubscribers {
44 access_profile: arg_of(subscribers, "access-profile").map(str::to_string),
45 service_profile: arg_of(subscribers, "service-profile").map(str::to_string),
46 groups: named_children(subscribers, "group")
47 .map(|(name, group)| StaticSubscriberGroup {
48 name: name.to_string(),
49 access_profile: arg_of(group, "access-profile").map(str::to_string),
50 dynamic_profiles: named_children(group, "dynamic-profile")
51 .map(|(name, profile)| StaticSubscriberProfile {
52 name: name.to_string(),
53 aggregate_clients: arg_of(profile, "aggregate-clients").map(str::to_string),
54 })
55 .collect(),
56 interfaces: args_of(group, "interface").into_iter().map(str::to_string).collect(),
57 })
58 .collect(),
59 }
60}