From dd4cc7b84b99d44c588852944d4bd14914f19570 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Fri, 12 Jan 2018 16:48:09 +0100 Subject: [PATCH] Add method get_soa() to class PdnsApiZone --- pp_lib/pdns_zone.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/pp_lib/pdns_zone.py b/pp_lib/pdns_zone.py index ce68151..a1236c1 100644 --- a/pp_lib/pdns_zone.py +++ b/pp_lib/pdns_zone.py @@ -21,9 +21,9 @@ from .common import pp, to_bytes, to_utf8, to_bool from .errors import PpError from .obj import PpBaseObjectError, PpBaseObject -from .pdns_record import PdnsApiRrset +from .pdns_record import PdnsApiRrset, PdnsSoaData -__version__ = '0.4.2' +__version__ = '0.4.3' LOG = logging.getLogger(__name__) @@ -371,6 +371,23 @@ class PdnsApiZone(PpBaseObject): return tpl.format(**params) + # ------------------------------------------------------------------------- + def get_soa(self): + + soa = None + + for rrset in self.rrsets: + if rrset.type == 'SOA': + for record in rrset.records: + soa = PdnsSoaData.init_from_data( + data=record.content, appname=self.appname, + verbose=self.verbose, base_dir=self.base_dir) + break + if soa: + break + + return soa + # ============================================================================= if __name__ == "__main__": -- 2.39.5