Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
utils.py44 linesDownload Raw Back to amadeus
1"""O365 tool utils."""2 3from __future__ import annotations4 5import logging6import os7from typing import TYPE_CHECKING8 9if TYPE_CHECKING:10    from amadeus import Client11 12logger = logging.getLogger(__name__)13 14 15def authenticate() -> Client:16    """Authenticate using the Amadeus API"""17    try:18        from amadeus import Client19    except ImportError as e:20        raise ImportError(21            "Cannot import amadeus. Please install the package with "22            "`pip install amadeus`."23        ) from e24 25    if "AMADEUS_CLIENT_ID" in os.environ and "AMADEUS_CLIENT_SECRET" in os.environ:26        client_id = os.environ["AMADEUS_CLIENT_ID"]27        client_secret = os.environ["AMADEUS_CLIENT_SECRET"]28    else:29        logger.error(30            "Error: The AMADEUS_CLIENT_ID and AMADEUS_CLIENT_SECRET environmental "31            "variables have not been set. Visit the following link on how to "32            "acquire these authorization tokens: "33            "https://developers.amadeus.com/register"34        )35        return None36 37    hostname = "test"  # Default hostname38    if "AMADEUS_HOSTNAME" in os.environ:39        hostname = os.environ["AMADEUS_HOSTNAME"]40 41    client = Client(client_id=client_id, client_secret=client_secret, hostname=hostname)42 43    return client44 
codekingpro/portable-devtools · Team Ai