import os

GF_SECURITY_ADMIN_USER = os.environ["GF_SECURITY_ADMIN_USER"]
GF_SECURITY_ADMIN_PASSWORD = os.environ["GF_SECURITY_ADMIN_PASSWORD"]

METRICS_DB_URL = os.environ["REDATA_METRICS_DB_URL"]

REDATA_METRICS_DATABASE_HOST = os.environ["REDATA_METRICS_DATABASE_HOST"]
REDATA_METRICS_DATABASE_USER = os.environ["REDATA_METRICS_DATABASE_USER"]
REDATA_METRICS_DATABASE_PASSWORD = os.environ["REDATA_METRICS_DATABASE_PASSWORD"]
REDATA_METRICS_DATABASE_NAME = os.environ["REDATA_METRICS_DATABASE_NAME"]

GRAFANA_WEB_HOST = os.environ["GRAFANA_WEB_HOST"]
GRAFANA_WEB_PORT = os.environ["GRAFANA_WEB_PORT"]

REDATA_GRAFANA_SOURCE = "redata_metrics_db"

TEMPLATES_DIR_LOCATION = "redata/grafana/templates/"
HOME_DASHBOARD_LOCATION = TEMPLATES_DIR_LOCATION + "home.json"
HOME_OVERRIDES_LOCATION = TEMPLATES_DIR_LOCATION + "overrides.json"
TABLE_DASHBOARD_LOCATION = TEMPLATES_DIR_LOCATION + "table.json"
TARGETS_DASHBOARD_LOCATION = TEMPLATES_DIR_LOCATION + "targets.json"
ALERT_DASHBOARD_LOCATION = TEMPLATES_DIR_LOCATION + "alert.json"

CUSTOM_PANEL_LOCATION = TEMPLATES_DIR_LOCATION + "panel.json"
CUSTOM_ROW_LOCATION = TEMPLATES_DIR_LOCATION + "row.json"

REDATA_SOURCE_DBS = [
    {
        "name": el.replace("REDATA_SOURCE_DB_URL_", ""),
        "db_url": os.environ[el],
        "schema": os.environ.get(el.replace("_URL_", "_SCHEMA_", 1), None),
    }
    for el in os.environ
    if el.startswith("REDATA_SOURCE_DB_URL_")
]

REDATA_AIRFLOW_SCHEDULE_INTERVAL = os.environ["REDATA_AIRFLOW_SCHEDULE_INTERVAL"]
REDATA_TIME_COL_BLACKLIST_REGEX = os.environ["REDATA_TIME_COL_BLACKLIST_REGEX"]

REDATA_BIGQUERY_DOCKER_CREDS_FILE_PATH = (
    os.environ["REDATA_DEFAULT_BIGQUERY_DOCKER_CREDS_FILE_PATH"]
    if os.environ.get("REDATA_BIGQUERY_KEY_FILE")
    else None
)

ACCEPTABLE_Z_SCORE_DIFF = float(os.environ.get("REDATA_ACCEPTABLE_Z_SCORE_DIFF"))

SKIP_COLUMNS = ["id"]

REDATA_SLACK_NOTIFICATION_URL = os.environ.get("REDATA_SLACK_NOTIFICATION_URL")

FLASK_UI_SECRET_KEY = os.environ.get("REDATA_FLASK_SECRET_KEY")

GRAFNA_URL = (
    os.environ.get("GRAFANA_REACHABLE_HOST") + ":" + os.environ.get("GRAFANA_WEB_PORT")
)
