Add zone validation
This commit is contained in:
@@ -70,15 +70,6 @@ def extract_domain_from_path(path: str) -> str|None:
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def validate_zone(zone_name, content) -> bool:
|
|
||||||
try:
|
|
||||||
dns.zone.from_text(content, zone_name, relativize=False)
|
|
||||||
logging.info(f"Zone {zone_name} parsed successfully")
|
|
||||||
return True
|
|
||||||
except Exception as e:
|
|
||||||
logging.error(f"Parse failed for zone {zone_name}")
|
|
||||||
return False
|
|
||||||
|
|
||||||
def export_single_zone(trigger_path: str) -> list[Path]:
|
def export_single_zone(trigger_path: str) -> list[Path]:
|
||||||
logging.info(f"Starting export of single zone for trigger path {trigger_path})")
|
logging.info(f"Starting export of single zone for trigger path {trigger_path})")
|
||||||
ensure_git_repo()
|
ensure_git_repo()
|
||||||
|
@@ -2,10 +2,18 @@ import logging
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
from config import *
|
from config import *
|
||||||
from helpers import validate_zone
|
|
||||||
|
|
||||||
session = requests.Session()
|
session = requests.Session()
|
||||||
|
|
||||||
|
def validate_zone(zone_name, content) -> bool:
|
||||||
|
try:
|
||||||
|
dns.zone.from_text(content, zone_name, relativize=False)
|
||||||
|
logging.info(f"Zone {zone_name} parsed successfully")
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"Parse failed for zone {zone_name}")
|
||||||
|
return False
|
||||||
|
|
||||||
def list_zones() -> list[dict]:
|
def list_zones() -> list[dict]:
|
||||||
url = f"{TECHNITIUM_API_BASE.rstrip('/')}{LIST_ZONES_ENDPOINT}?token={API_TOKEN}"
|
url = f"{TECHNITIUM_API_BASE.rstrip('/')}{LIST_ZONES_ENDPOINT}?token={API_TOKEN}"
|
||||||
logging.debug(f"Listing zones from {url}")
|
logging.debug(f"Listing zones from {url}")
|
||||||
|
Reference in New Issue
Block a user