[sty] logic:conf

This commit is contained in:
Christian Fraß 2022-12-05 08:16:41 +01:00
parent e7be85f61a
commit 020846ebc8

View file

@ -1,7 +1,8 @@
def conf_schema_active(): def conf_schema_active():
return { return {
"description": "whether the check shall be executed",
"type": "boolean", "type": "boolean",
"default": True "default": True,
} }
@ -10,7 +11,7 @@ def conf_schema_threshold():
"description": "how often a condition has to occur in order to be reported", "description": "how often a condition has to occur in order to be reported",
"type": "integer", "type": "integer",
"minimum": 1, "minimum": 1,
"default": 3 "default": 3,
} }
@ -18,19 +19,20 @@ def conf_schema_annoy():
return { return {
"description": "whether notifications shall be kept sending after the threshold has been surpassed", "description": "whether notifications shall be kept sending after the threshold has been surpassed",
"type": "boolean", "type": "boolean",
"default": False "default": False,
} }
def conf_schema_interval(default): def conf_schema_interval(default):
return { return {
"description": "in seconds or as text",
"anyOf": [ "anyOf": [
{ {
"description": "in seconds",
"type": "integer", "type": "integer",
"exclusiveMinimum": 0 "exclusiveMinimum": 0,
}, },
{ {
"description": "as text",
"type": "string", "type": "string",
"enum": [ "enum": [
"minute", "minute",
@ -53,7 +55,7 @@ def conf_schema_schedule():
"attentive_interval": conf_schema_interval(60 * 2), "attentive_interval": conf_schema_interval(60 * 2),
}, },
"required": [ "required": [
] ],
} }
@ -77,7 +79,7 @@ def conf_schema_notifications(notification_channel_implementations):
"required": [ "required": [
"kind", "kind",
"parameters" "parameters"
] ],
}, },
notification_channel_implementations.items() notification_channel_implementations.items()
) )
@ -88,8 +90,8 @@ def conf_schema_notifications(notification_channel_implementations):
"kind": "console", "kind": "console",
"parameters": { "parameters": {
} }
} },
] ],
} }
@ -110,7 +112,7 @@ def conf_schema_root(check_kind_implementations, notification_channel_implementa
"notifications": conf_schema_notifications(notification_channel_implementations), "notifications": conf_schema_notifications(notification_channel_implementations),
}, },
"required": [ "required": [
] ],
}, },
"checks": { "checks": {
"type": "array", "type": "array",
@ -135,7 +137,7 @@ def conf_schema_root(check_kind_implementations, notification_channel_implementa
}, },
"required": [ "required": [
"name", "name",
] ],
}, },
{ {
"anyOf": list( "anyOf": list(
@ -153,7 +155,7 @@ def conf_schema_root(check_kind_implementations, notification_channel_implementa
}, },
"required": [ "required": [
"kind", "kind",
"parameters" "parameters",
] ]
}, },
check_kind_implementations.items() check_kind_implementations.items()