Standardize Verizon plugin client boundary

This commit is contained in:
Lyncoln
2026-09-20 23:30:15 -04:00
parent c9a3898055
commit 0719671820
4 changed files with 64 additions and 104 deletions
+10 -13
View File
@@ -16,8 +16,7 @@ from dns_sync.adapter_support import (
require_endpoint_plugin,
)
from dns_sync.config import parse_endpoint_list
from dns_sync.models import DesiredRecord
from .provider import Plugin as VerizonProvider
from .client import VerizonClient, VerizonRecord
def configured_endpoints(config):
@@ -53,12 +52,11 @@ class Plugin:
def __init__(self, config, endpoint):
require_endpoint_plugin(endpoint, self.name)
self.config = config
self.endpoint = endpoint
self.provider = VerizonProvider(config, endpoint)
self.client = VerizonClient(endpoint)
def connect(self) -> None:
self.provider.connect()
self.client.connect()
def discover(
self,
@@ -72,7 +70,7 @@ class Plugin:
discovered: list[DiscoveredObject] = []
records = sorted(
self.provider.list_records().values(),
self.client.list_records().values(),
key=lambda record: record.hostname.lower(),
)
@@ -101,7 +99,7 @@ class Plugin:
def _desired_record(
self,
object: NormalizedObject,
) -> DesiredRecord:
) -> VerizonRecord:
if object.object_type != DNS_RECORDS:
raise RuntimeError(
f"{self.endpoint.identity} cannot handle "
@@ -129,11 +127,10 @@ class Plugin:
"Verizon DNS does not support wildcard records"
)
return DesiredRecord(
return VerizonRecord(
hostname=hostname,
ip=str(payload.get("ip") or ""),
record_type=record_type,
wildcard=False,
)
def apply(self, action: PlanAction) -> ApplyResult | None:
@@ -156,16 +153,16 @@ class Plugin:
record = self._desired_record(desired)
if action.operation == PlanOperation.CREATE:
detail = self.provider.add_record(record)
detail = self.client.add_record(record)
elif action.operation == PlanOperation.UPDATE:
detail = self.provider.update_record(record)
detail = self.client.update_record(record)
else:
raise RuntimeError(
f"Verizon adapter does not support "
f"{action.operation.value} actions"
)
records = self.provider.list_records()
records = self.client.list_records()
applied_record = records.get(record.hostname.lower())
if applied_record is None:
applied_record = records.get(record.hostname)
@@ -197,6 +194,6 @@ class Plugin:
)
def verify(self, object: NormalizedObject) -> bool:
return self.provider.verify_record(
return self.client.verify_record(
self._desired_record(object)
)