from .errors import PpError
from .obj import PpBaseObjectError, PpBaseObject
+from .pdns_record import PdnsApiRrset
-__version__ = '0.3.1'
+__version__ = '0.4.1'
LOG = logging.getLogger(__name__)
self._serial = serial
self._url = url
- self.records = []
+ self.rrsets = []
self._soa_edit = soa_edit
self._soa_edit_api = soa_edit_api
if initialized is not None:
params['initialized'] = initialized
+ rrsets = None
+ if 'rrsets' in data:
+ if data['rrsets']:
+ rrsets = data['rrsets']
+ data['rrsets'] = None
+
params.update(data)
zone = cls(**params)
+
+ if rrsets:
+ for single_rrset in rrsets:
+ rrset = PdnsApiRrset.init_from_dict(
+ single_rrset, appname=appname, verbose=verbose, base_dir=base_dir)
+ zone.rrsets.append(rrset)
+
zone.initialized = True
return zone
@param short: don't include local properties in resulting dict.
@type short: bool
-
+
@return: structure as dict
@rtype: dict
"""
-
+
res = super(PdnsApiZone, self).as_dict(short=short)
res['account'] = self.account
res['dnssec'] = copy.copy(self.dnssec)
res['notified_serial'] = self.notified_serial
res['serial'] = self.serial
res['url'] = self.url
- res['records'] = copy.copy(self.records)
+ res['rrsets'] = []
res['soa_edit'] = self.soa_edit
res['soa_edit_api'] = self.soa_edit_api
+ for rrset in self.rrsets:
+ if isinstance(rrset, PpBaseObject):
+ res['rrsets'].append(rrset.as_dict(short))
+ else:
+ res['rrsets'].append(rrset)
+
return res
# -------------------------------------------------------------------------
# =============================================================================
-# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list