# vim: set encoding=utf-8 et sw=4 sts=4 :
-# TODO documentation, validation
+# TODO documentation
-from pymin.seqtools import Sequence
+from pymin.validation import Item, Field, HostName, IPAddress
from pymin.service.util import DictComposedSubHandler
__all__ = ('HostHandler',)
-class Host(Sequence):
- def __init__(self, name, ip):
- self.name = name
- self.ip = ip
- def update(self, ip=None):
- if ip is not None: self.ip = ip
- def as_tuple(self):
- return (self.name, self.ip)
+
+class Host(Item):
+ name = Field(HostName(not_empty=True))
+ ip = Field(IPAddress(not_empty=True))
class HostHandler(DictComposedSubHandler):
handler_help = u"Manage DNS hosts"
# vim: set encoding=utf-8 et sw=4 sts=4 :
-# TODO documentation, validation
+# TODO documentation
-from pymin.seqtools import Sequence
+from pymin.validation import Item, Field, FullyQualifiedHostName, UInt16
from pymin.service.util import DictComposedSubHandler
__all__ = ('MailExchangeHandler',)
-class MailExchange(Sequence):
- def __init__(self, mx, prio):
- self.mx = mx
- self.prio = prio
- def update(self, prio=None):
- if prio is not None: self.prio = prio
- def as_tuple(self):
- return (self.mx, self.prio)
+class MailExchange(Item):
+ mx = Field(FullyQualifiedHostName(not_empty=True))
+ prio = Field(UInt16(not_empty=True))
class MailExchangeHandler(DictComposedSubHandler):
handler_help = u"Manage DNS mail exchangers (MX)"
# vim: set encoding=utf-8 et sw=4 sts=4 :
-# TODO documentation, validation
+# TODO documentation
-from pymin.seqtools import Sequence
+from pymin.validation import Item, Field, FullyQualifiedHostName
from pymin.service.util import DictComposedSubHandler
__all__ = ('NameServerHandler',)
-class NameServer(Sequence):
- def __init__(self, name):
- self.name = name
- def as_tuple(self):
- return (self.name,)
+class NameServer(Item):
+ name = Field(FullyQualifiedHostName(not_empty=True))
class NameServerHandler(DictComposedSubHandler):
handler_help = u"Manage DNS name servers (NS)"
# vim: set encoding=utf-8 et sw=4 sts=4 :
-# TODO documentation, validation
+# TODO documentation
-from pymin.seqtools import Sequence
+from pymin.validation import Item, Field, FullyQualifiedHostName
from pymin.service.util import DictSubHandler
__all__ = ('DnsHandler',)
-class Zone(Sequence):
- def __init__(self, name):
- self.name = name
+class Zone(Item):
+ name = Field(FullyQualifiedHostName(not_empty=True))
+ def __init__(self, *args, **kwargs):
+ Item.__init__(self, *args, **kwargs)
self.hosts = dict()
self.mxs = dict()
self.nss = dict()
self._add = False
self._update = False
self._delete = False
- def as_tuple(self):
- return (self.name, self.hosts, self.mxs, self.nss)
class ZoneHandler(DictSubHandler):
handler_help = u"Manage DNS zones"