Merge "Moved v2 API errors to separate controller"

This commit is contained in:
Jenkins 2014-07-21 15:46:19 +00:00 committed by Gerrit Code Review
commit acd1b29b8e
4 changed files with 42 additions and 17 deletions

View File

@ -43,8 +43,8 @@ def factory(global_config, **local_conf):
'root': 'designate.api.v2.controllers.root.RootController',
'modules': ['designate.api.v2'],
'errors': {
404: '/not_found',
405: '/method_not_allowed',
404: '/errors/not_found',
405: '/errors/method_not_allowed',
'__force_dict__' : True
}
}

View File

@ -0,0 +1,37 @@
# Copyright 2014 Hewlett-Packard Development Company, L.P.
#
# Author: Graham Hayes <graham.hayes@hp.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from designate import exceptions
from designate.openstack.common import log as logging
from pecan import expose
LOG = logging.getLogger(__name__)
class ErrorsController(object):
@expose(content_type='text/plain')
@expose(content_type='text/dns')
@expose(content_type='application/json')
def not_found(self):
raise exceptions.NotFound('resource not found')
@expose(content_type='text/plain')
@expose(content_type='text/dns')
@expose(content_type='application/json')
def method_not_allowed(self):
raise exceptions.MethodNotAllowed()

View File

@ -16,7 +16,6 @@
from oslo.config import cfg
from stevedore import named
from designate import exceptions
from designate.openstack.common import log as logging
from designate.api.v2.controllers import limits
from designate.api.v2.controllers import reverse
@ -24,8 +23,7 @@ from designate.api.v2.controllers import schemas
from designate.api.v2.controllers import tlds
from designate.api.v2.controllers import zones
from designate.api.v2.controllers import blacklists
from pecan import expose
from designate.api.v2.controllers import errors
LOG = logging.getLogger(__name__)
@ -57,15 +55,4 @@ class RootController(object):
tlds = tlds.TldsController()
zones = zones.ZonesController()
blacklists = blacklists.BlacklistsController()
@expose(content_type='text/plain')
@expose(content_type='text/dns')
@expose(content_type='application/json')
def not_found(self):
raise exceptions.NotFound
@expose(content_type='text/plain')
@expose(content_type='text/dns')
@expose(content_type='application/json')
def method_not_allowed(self):
raise exceptions.MethodNotAllowed
errors = errors.ErrorsController()

View File

@ -162,6 +162,7 @@ class DomainHasSubdomain(Base):
class Forbidden(Base):
error_code = 403
error_type = 'forbidden'
expected = True
class Duplicate(Base):