def create(middleware=CONF.middleware): policy.setup_policy() if middleware: api = falcon.API( request_type=ArmadaRequest, middleware=[ AuthMiddleware(), LoggingMiddleware(), ContextMiddleware() ]) else: api = falcon.API(request_type=ArmadaRequest) # Configure API routing url_routes_v1 = ( ('apply', Apply()), ('releases', Release()), ('status', Status()), ('tests', Tests()), ('test/{release}', Test()), ('validate', Validate()), ) for route, service in url_routes_v1: api.add_route("/api/v1.0/{}".format(route), service) return api
def create(enable_middleware=CONF.middleware): """Entry point for initializing Armada server. :param enable_middleware: Whether to enable middleware. :type enable_middleware: bool """ if enable_middleware: api = falcon.API(request_type=ArmadaRequest, middleware=[ AuthMiddleware(), ContextMiddleware(), LoggingMiddleware(), ]) else: api = falcon.API(request_type=ArmadaRequest) logging.set_defaults(default_log_levels=CONF.default_log_levels) logging.setup(CONF, 'armada') # Configure API routing url_routes_v1 = ( ('health', Health()), ('apply', Apply()), ('releases', Release()), ('rollback/{release}', Rollback()), ('status', Status()), ('tests', TestReleasesManifestController()), ('test/{release}', TestReleasesReleaseNameController()), ('validatedesign', Validate()), ) for route, service in url_routes_v1: api.add_route("/api/v1.0/{}".format(route), service) api.add_route('/versions', Versions()) # Initialize policy config options. policy.Enforcer(CONF) # Error handlers (FILO handling) api.add_error_handler(exceptions.ArmadaBaseException, exceptions.default_exception_handler) api.add_error_handler(exceptions.ArmadaAPIException, exceptions.ArmadaAPIException.handle) # Built-in error serializer api.set_error_serializer(exceptions.default_error_serializer) return api
def create(enable_middleware=CONF.middleware): """Entry point for intializing Armada server. :param enable_middleware: Whether to enable middleware. :type enable_middleware: bool """ if enable_middleware: api = falcon.API(request_type=ArmadaRequest, middleware=[ AuthMiddleware(), LoggingMiddleware(), ContextMiddleware() ]) else: api = falcon.API(request_type=ArmadaRequest) logging.set_defaults(default_log_levels=CONF.default_log_levels) logging.setup(CONF, 'armada') # Configure API routing url_routes_v1 = ( ('health', Health()), ('apply', Apply()), ('releases', Release()), ('status', Status()), ('tests', Tests()), ('test/{release}', Test()), ('validatedesign', Validate()), ) for route, service in url_routes_v1: api.add_route("/api/v1.0/{}".format(route), service) api.add_route('/versions', Versions()) # Initialize policy config options. policy.Enforcer(CONF) return api