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
//! `tca`
//! `interfaces <name> { optics-options { tca ... } }` and `interfaces <name> { otn-options { tca ... } }`.
//!
//! # See also
//!
//! - [tca](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/tca-edit-interfaces-otn-options.html)
use crate::split_keyword;
/// A threshold crossing alert, `tca <identifier> (enable-tca | no-enable-tca) (threshold <n> | threshold-24hrs <n>)`.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct Tca {
/// The alert, e.g. `"odu-bbe"`.
pub identifier: String,
/// `Some(true)` for `enable-tca`, `Some(false)` for `no-enable-tca`.
pub enabled: Option<bool>,
pub threshold: Option<String>,
pub threshold_24hrs: Option<String>,
}
/// Parses the argument of a `tca` statement.
pub(super) fn parse_tca(arg: &str) -> Tca {
let (identifier, rest) = split_keyword(arg);
let words: Vec<&str> = rest.split_whitespace().collect();
let enabled = if words.contains(&"enable-tca") {
Some(true)
} else if words.contains(&"no-enable-tca") {
Some(false)
} else {
None
};
Tca {
identifier: identifier.to_string(),
enabled,
threshold: crate::value_after(&words, "threshold"),
threshold_24hrs: crate::value_after(&words, "threshold-24hrs"),
}
}