class Controller(rest.RestController): """Version 1 API controller root.""" services = zun_services.ZunServiceController() containers = container_controller.ContainersController() images = image_controller.ImagesController() @pecan.expose('json') def get(self): return V1.convert() @pecan.expose() def _route(self, args): if pecan.request.body: msg = ("Processing request: url: %(url)s, %(method)s, " "body: %(body)s" % { 'url': pecan.request.url, 'method': pecan.request.method, 'body': pecan.request.body }) LOG.debug(msg) return super(Controller, self)._route(args)
class Controller(controllers_base.Controller): """Version 1 API controller root.""" services = zun_services.ZunServiceController() containers = container_controller.ContainersController() images = image_controller.ImagesController() hosts = host_controller.HostController() capsules = capsule_controller.CapsuleController() providers = provider_controller.ContainersController() users = user_controller.ContainersController() computerates = computerate_controller.ContainersController() instances = instance_controller.ContainersController() instancetypes = instancetype_controller.ContainersController() payments = payment_controller.ContainersController() paymentmethods = paymentmethod_controller.ContainersController() provideraccounts = provideraccount_controller.ContainersController() providerregions = providerregion_controller.ContainersController() providervms = providervm_controller.ContainersController() statements = statement_controller.ContainersController() storagerates = storagerate_controller.ContainersController() usages = usage_controller.ContainersController() @pecan.expose('json') def get(self): return V1.convert() def _check_version(self, version, headers=None): if headers is None: headers = {} # ensure that major version in the URL matches the header if version.major != BASE_VERSION: raise http_error.HTTPNotAcceptableAPIVersion( _("Mutually exclusive versions requested. Version %(ver)s " "requested but not supported by this service. " "The supported version range is: " "[%(min)s, %(max)s].") % { 'ver': version, 'min': MIN_VER_STR, 'max': MAX_VER_STR }, headers=headers, max_version=str(MAX_VER), min_version=str(MIN_VER)) # ensure the minor version is within the supported range if version < MIN_VER or version > MAX_VER: raise http_error.HTTPNotAcceptableAPIVersion( _("Version %(ver)s was requested but the minor version is not " "supported by this service. The supported version range is: " "[%(min)s, %(max)s].") % { 'ver': version, 'min': MIN_VER_STR, 'max': MAX_VER_STR }, headers=headers, max_version=str(MAX_VER), min_version=str(MIN_VER)) @pecan.expose() def _route(self, args): version = ver.Version(pecan.request.headers, MIN_VER_STR, MAX_VER_STR) # Always set the basic version headers pecan.response.headers[ver.Version.min_string] = MIN_VER_STR pecan.response.headers[ver.Version.max_string] = MAX_VER_STR pecan.response.headers[ver.Version.string] = " ".join( [ver.Version.service_string, str(version)]) pecan.response.headers["vary"] = ver.Version.string # assert that requested version is supported self._check_version(version, pecan.response.headers) pecan.request.version = version if pecan.request.body: msg = ("Processing request: url: %(url)s, %(method)s, " "body: %(body)s" % { 'url': pecan.request.url, 'method': pecan.request.method, 'body': pecan.request.body }) LOG.debug(msg) return super(Controller, self)._route(args)