"""module to wrap the session management in function calls to easily interact
with the current session from C#"""

from __future__ import annotations

from typing import Final

from delta_barth.constants import HTTP_BASE_CONTENT_HEADERS
from delta_barth.logging import logger_session as logger
from delta_barth.session import Session

SESSION: Final[Session] = Session(HTTP_BASE_CONTENT_HEADERS)


def setup(
    data_path: str,
    base_url: str,
) -> None:  # pragma: no cover
    # at this point: no logging configured
    SESSION.set_data_path(data_path)
    SESSION.set_base_url(base_url=base_url)
    SESSION.setup()
    logger.info("[EXT-CALL MANAGEMENT] Successfully set up current session")


def set_credentials(
    username: str,
    password: str,
    database: str,
    mandant: str,
) -> None:  # pragma: no cover
    logger.info("[EXT-CALL MANAGEMENT] Setting credentials for current session...")
    SESSION.set_credentials(
        username=username,
        password=password,
        database=database,
        mandant=mandant,
    )
    logger.info("[EXT-CALL MANAGEMENT] Successfully set credentials for current session")


# ** not part of external API, only internal
def get_credentials() -> str:  # pragma: no cover
    logger.info("[EXT-CALL MANAGEMENT] Getting credentials for current session...")
    creds = SESSION.creds
    logger.info("[EXT-CALL MANAGEMENT] Successfully got credentials for current session")
    return creds.model_dump_json()


def set_base_url(
    base_url: str,
) -> None:  # pragma: no cover
    SESSION.set_base_url(base_url=base_url)


def get_data_path() -> str:  # pragma: no cover
    return str(SESSION.data_path)


def get_base_url() -> str:  # pragma: no cover
    return SESSION.base_url
