summaryrefslogtreecommitdiffstats
path: root/python/knot_resolver_manager/manager/datamodel/rpz_schema.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/knot_resolver_manager/manager/datamodel/rpz_schema.py')
-rw-r--r--python/knot_resolver_manager/manager/datamodel/rpz_schema.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/python/knot_resolver_manager/manager/datamodel/rpz_schema.py b/python/knot_resolver_manager/manager/datamodel/rpz_schema.py
new file mode 100644
index 00000000..e5dfe60e
--- /dev/null
+++ b/python/knot_resolver_manager/manager/datamodel/rpz_schema.py
@@ -0,0 +1,29 @@
+from typing import List, Optional
+
+from knot_resolver_manager.manager.datamodel.types import PolicyActionEnum, PolicyFlagEnum, ReadableFile
+from knot_resolver_manager.utils.modeling import ConfigSchema
+
+
+class RPZSchema(ConfigSchema):
+ """
+ Configuration or Response Policy Zone (RPZ).
+
+ ---
+ action: RPZ rule action, typically 'deny'.
+ file: Path to the RPZ zone file.
+ watch: Reload the file when it changes.
+ views: Use RPZ rule only for clients defined by views.
+ options: Configuration flags for RPZ rule.
+ message: Deny message for 'deny' action.
+ """
+
+ action: PolicyActionEnum
+ file: ReadableFile
+ watch: bool = True
+ views: Optional[List[str]] = None
+ options: Optional[List[PolicyFlagEnum]] = None
+ message: Optional[str] = None
+
+ def _validate(self) -> None:
+ if self.message and not self.action == "deny":
+ raise ValueError("'message' field can only be defined for 'deny' action")