|
3 | 3 | # This file is part of Checkmk (https://checkmk.com). It is subject to the terms and |
4 | 4 | # conditions defined in the file COPYING, which is part of this source code package. |
5 | 5 |
|
| 6 | +from typing import NamedTuple |
| 7 | + |
6 | 8 | from cmk.rulesets.v1 import Title |
7 | 9 | from cmk.rulesets.v1.form_specs import ( |
8 | 10 | DefaultValue, |
|
17 | 19 | from cmk.rulesets.v1.rule_specs import CheckParameters, HostCondition, Topic |
18 | 20 |
|
19 | 21 |
|
| 22 | +class AssertType(NamedTuple): |
| 23 | + id: str |
| 24 | + title: Title |
| 25 | + |
| 26 | + |
| 27 | +ASSERT_TYPES = [ |
| 28 | + AssertType("msg", Title("Message rate")), |
| 29 | + AssertType("rollovers", Title("Rollovers rate")), |
| 30 | + AssertType("regular", Title("Regular rate")), |
| 31 | + AssertType("warning", Title("Warning rate")), |
| 32 | + AssertType("user", Title("User rate")), |
| 33 | +] |
| 34 | + |
| 35 | + |
20 | 36 | def _parameter_valuespec_mongodb_asserts() -> Dictionary: |
21 | 37 | return Dictionary( |
22 | 38 | elements={ |
23 | | - "%s_assert_rate" % what: DictElement[SimpleLevelsConfigModel[float]]( |
| 39 | + "%s_assert_rate" % assert_type.id: DictElement[SimpleLevelsConfigModel[float]]( |
24 | 40 | parameter_form=SimpleLevels[float]( |
25 | | - # astrein: disable=localization-named-placeholder |
26 | | - title=Title("%s rate") % what.title(), |
| 41 | + title=assert_type.title, |
27 | 42 | level_direction=LevelDirection.UPPER, |
28 | 43 | prefill_fixed_levels=DefaultValue((1.0, 2.0)), |
29 | 44 | form_spec_template=Float(unit_symbol="Asserts per second"), |
30 | 45 | migrate=migrate_to_float_simple_levels, |
31 | 46 | ) |
32 | 47 | ) |
33 | | - for what in ["msg", "rollovers", "regular", "warning", "user"] |
| 48 | + for assert_type in ASSERT_TYPES |
34 | 49 | } |
35 | 50 | ) |
36 | 51 |
|
|
0 commit comments