"""
Database related APIs.
"""

import logging
from typing import List

from fastapi import APIRouter, Depends
from sqlmodel import Session, select

from datajunction.models.database import Database
from datajunction.utils import get_session

_logger = logging.getLogger(__name__)
router = APIRouter()


@router.get("/databases/", response_model=List[Database])
def read_databases(*, session: Session = Depends(get_session)) -> List[Database]:
    """
    List the available databases.
    """
    return session.exec(select(Database)).all()

fastapi.Depends sqlmodel.select logging.getLogger fastapi.APIRouter
[((253, 280), 'logging.getLogger', 'logging.getLogger', (['__name__'], {}), '(__name__)\n', (270, 280), False, 'import logging\n'), ((290, 301), 'fastapi.APIRouter', 'APIRouter', ([], {}), '()\n', (299, 301), False, 'from fastapi import APIRouter, Depends\n'), ((403, 423), 'fastapi.Depends', 'Depends', (['get_session'], {}), '(get_session)\n', (410, 423), False, 'from fastapi import APIRouter, Depends\n'), ((518, 534), 'sqlmodel.select', 'select', (['Database'], {}), '(Database)\n', (524, 534), False, 'from sqlmodel import Session, select\n')]