|
|
|
@ -1,3 +1,7 @@
|
|
|
|
|
"""
|
|
|
|
|
API: domain
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
from flask_restx import Resource, fields, abort
|
|
|
|
|
|
|
|
|
|
from . import api, response_fields, error_fields
|
|
|
|
@ -9,6 +13,7 @@ db = models.db
|
|
|
|
|
dom = api.namespace('domain', description='Domain operations')
|
|
|
|
|
alt = api.namespace('alternative', description='Alternative operations')
|
|
|
|
|
|
|
|
|
|
# TODO: use marshmallow
|
|
|
|
|
domain_fields = api.model('Domain', {
|
|
|
|
|
'name': fields.String(description='FQDN', example='example.com', required=True),
|
|
|
|
|
'comment': fields.String(description='a comment'),
|
|
|
|
@ -19,12 +24,12 @@ domain_fields = api.model('Domain', {
|
|
|
|
|
# 'dkim_key': fields.String,
|
|
|
|
|
'alternatives': fields.List(fields.String(attribute='name', description='FQDN', example='example.com')),
|
|
|
|
|
})
|
|
|
|
|
# TODO - name ist required on creation but immutable on change
|
|
|
|
|
# TODO - name and alteranatives need to be checked to be a fqdn (regex)
|
|
|
|
|
# TODO: name ist required on creation but immutable on change
|
|
|
|
|
# TODO: name and alteranatives need to be checked to be a fqdn (regex)
|
|
|
|
|
|
|
|
|
|
domain_parser = api.parser()
|
|
|
|
|
domain_parser.add_argument('max_users', type=int, help='maximum number of users')
|
|
|
|
|
# TODO ... add more (or use marshmallow)
|
|
|
|
|
# TODO: ... add more (or use marshmallow)
|
|
|
|
|
|
|
|
|
|
alternative_fields = api.model('Domain', {
|
|
|
|
|
'name': fields.String(description='alternative FQDN', example='example.com', required=True),
|
|
|
|
@ -180,4 +185,3 @@ class Domain(Resource):
|
|
|
|
|
# def delete(self, name, alt=None):
|
|
|
|
|
# """ Delete alternative (for domain) """
|
|
|
|
|
# abort(501)
|
|
|
|
|
|
|
|
|
|