import os
import logging
logger = logging.getLogger(__name__)
from acelerai_config import PACKAGE_ENV, PACKAGE_VERSION

__version__ = PACKAGE_VERSION

__mode = os.environ.get("EXEC_LOCATION", "LOCAL")
logger.info(f"EXEC_LOCATION: {__mode} (PACKAGE_ENV: {PACKAGE_ENV})")

if __mode == "LOCAL":
    if PACKAGE_ENV == "production":
        DATA_URL        = os.environ.get("DATA_URL"         , "https://stream.aceler.ai")
        QUERY_MANAGER   = os.environ.get("QUERY_MANAGER"    , "https://stream.aceler.ai")  
        APIGW           = os.environ.get("APIGW"            , "https://app.aceler.ai/api")
    else:
        DATA_URL        = os.environ.get("DATA_URL"         , "https://stream-staging.aceler.ai")
        QUERY_MANAGER   = os.environ.get("QUERY_MANAGER"    , "https://stream-staging.aceler.ai")  
        APIGW           = os.environ.get("APIGW"            , "https://app-staging.aceler.ai/api")
    VERIFY_HTTPS = os.environ.get("VERIFY_HTTPS", "true").lower().strip() == "true"

elif __mode == "PRODUCTION":
    if PACKAGE_ENV == "production":
        DATA_URL        = os.environ.get("DATA_URL"         , "http://inputstreamdata-service.aceler-ai-production.svc.cluster.local")
        QUERY_MANAGER   = os.environ.get("QUERY_MANAGER"    , "http://querymanager-service.aceler-ai-production.svc.cluster.local")
        APIGW           = os.environ.get("APIGW"            , "http://core-service.aceler-ai-production.svc.cluster.local/api")
    else:
        DATA_URL        = os.environ.get("DATA_URL"         , "http://inputstreamdata-service.aceler-ai-staging.svc.cluster.local")
        QUERY_MANAGER   = os.environ.get("QUERY_MANAGER"    , "http://querymanager-service.aceler-ai-staging.svc.cluster.local")
        APIGW           = os.environ.get("APIGW"            , "http://core-service.aceler-ai-staging.svc.cluster.local/api")
    VERIFY_HTTPS = False

else:
    raise Exception(f"Invalid environment {__mode}, please check the EXEC_LOCATION environment variable")
    
from acelerai_inputstream.models.inputstream import INSERTION_MODE, Inputstream
from acelerai_inputstream.inputstream_client import InputstreamClient