from snowflake.connector.connection import SnowflakeConnection
from typing import Any


from snowflake.connector import connect
from snowflake.connector.network import OAUTH_AUTHENTICATOR, KEY_PAIR_AUTHENTICATOR

def get_call_centers(token: str) -> Any:
    """
    Gets all call centers from Snowflake database
    """
    # validate values can be found here https://github.com/snowflakedb/snowflake-connector-python/blob/master/src/snowflake/connector/connection.py#L213
    connection_args: dict = {
        "user": "chris_b_bacon",
        "application": __name__,
        "account": "zz46508",
        "region": "central-us",
        "token": token,
        "authenticator": OAUTH_AUTHENTICATOR,
        "database": "SNOWFLAKE_SAMPLE_DATA",
        "schema": "TPCDS_SF10TCL"
    }
    snow_conn: SnowflakeConnection = connect(**connection_args)
    cur = snow_conn.cursor()

    try:
        cur.execute("SELECT * from CALL_CENTER")
        results = cur.fetchone()
        return results
    except Exception as e:
        return e
    finally:
        snow_conn.close()