# -*- encoding: utf-8 -*- from aiohttp import web from phi.logging import get_logger from phi.async_ldap.client import AsyncClient from phi.async_ldap.model import Hackers, Robots, Congregations from phi.api.routes import api_routes log = get_logger(__name__) def api_app(config): log.info("Initializing API sub-app.") app = web.Application() ldap_client = AsyncClient(**config.get("ldap", {})) app["ldap_client"] = ldap_client app["users"] = Hackers(ldap_client) app["services"] = Robots(ldap_client) app["groups"] = Congregations(ldap_client) app["log"] = log app.router.add_routes(api_routes) return app