# generated by fastapi-codegen:
#   filename:  connector
#   timestamp: 2025-12-16T15:57:14+00:00

from __future__ import annotations

from contextlib import asynccontextmanager

from fastapi import FastAPI

from centra_sdk.utils.context import IntegrationContextApi

from .routers import (
    agents,
    authentication,
    control,
    enforcement,
    health,
    info,
    inventory,
    logging,
    onboarding,
    operations,
)


@asynccontextmanager
async def lifespan(app: FastAPI):
    started_tasks = IntegrationContextApi.start_bg_tasks()
    yield
    await IntegrationContextApi.clean()
    IntegrationContextApi.stop_bg_tasks(started_tasks)


app = FastAPI(
    title='Centra Integration API',
    description='Centra Integration API is used by Integration Controller as base interface to integrate with 3rd party platforms.\n\nSome useful links:\n- [Contracts OpenApi spec](https://github.com/guardicore/contracts)',
    license={
        'name': 'Apache 2.0',
        'url': 'https://www.apache.org/licenses/LICENSE-2.0.html',
    },
    version='1.10.0',
    servers=[{'url': 'http://127.0.0.1:8000'}],
    lifespan=lifespan,
)

app.include_router(agents.router)
app.include_router(authentication.router)
app.include_router(control.router)
app.include_router(enforcement.router)
app.include_router(health.router)
app.include_router(info.router)
app.include_router(inventory.router)
app.include_router(logging.router)
app.include_router(onboarding.router)
app.include_router(operations.router)
