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