from os import environ
from typing import Any

from promptquality.types.config import Config
from promptquality.utils.logger import logger


def login(**kwargs: Any) -> Config:
    """
    Login to Galileo Environment.

    By default, this will login to Galileo Cloud but can be used to login to the enterprise version of Galileo by
    passing in the console URL for the environment.
    """
    if "console_url" in kwargs:
        if environ.get("GALILEO_CONSOLE_URL") == kwargs["console_url"]:
            logger.warning(
                "The console URL provided is the same as the one in the environment variable GALILEO_CONSOLE_URL and is not required to be passed in."
            )
    return Config.set(**kwargs)
