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(middleware=CONF.middleware): if not (os.path.exists('etc/armada/armada.conf')): logging.register_options(CONF) logging.set_defaults(default_log_levels=CONF.default_log_levels) logging.setup(CONF, 'armada') 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()), ('validate', Validate())) for route, service in url_routes_v1: api.add_route("/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_PATH, Health()), ('apply', Apply()), ('releases', Releases()), # TODO: Remove this in follow on release after Shipyard has # been updated to no longer depend on it. ('status', Status()), ('tests', TestReleasesManifestController()), ('test/{namespace}/{release}', TestReleasesReleaseNameController()), ('validatedesign', Validate()), (METRICS_PATH, Metrics()), ] 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(Exception, 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 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