""" Environment variables. """
from types import MappingProxyType

from octopuscl.types import Environment

####################################
# ENVIRONMENT VARIABLE DEFINITIONS #
####################################

# AWS
ENV_AWS_ACCESS_KEY_ID = 'AWS_ACCESS_KEY_ID'
ENV_AWS_SECRET_ACCESS_KEY = 'AWS_SECRET_ACCESS_KEY'

# OctopusCL: AWS EC2
ENV_OCTOPUSCL_AWS_EC2_AMI_ID = 'OCTOPUSCL_AWS_EC2_AMI_ID'
ENV_OCTOPUSCL_AWS_EC2_INSTANCE_TYPE = 'OCTOPUSCL_AWS_EC2_INSTANCE_TYPE'
ENV_OCTOPUSCL_AWS_EC2_MAX_INSTANCES = 'OCTOPUSCL_AWS_EC2_MAX_INSTANCES'
ENV_OCTOPUSCL_AWS_EC2_STORAGE_SIZE = 'OCTOPUSCL_AWS_EC2_STORAGE_SIZE'  # GB
ENV_OCTOPUSCL_AWS_EC2_USER_NAME = 'OCTOPUSCL_AWS_EC2_USER_NAME'
ENV_OCTOPUSCL_AWS_EC2_ROLE_NAME = 'OCTOPUSCL_AWS_EC2_ROLE_NAME'
ENV_OCTOPUSCL_AWS_EC2_SECURITY_GROUP = 'OCTOPUSCL_AWS_EC2_SECURITY_GROUP'

# OctopusCL: AWS S3
ENV_OCTOPUSCL_AWS_S3_BUCKET = 'OCTOPUSCL_AWS_S3_BUCKET'  # Considered only if there is no active environment
ENV_OCTOPUSCL_AWS_S3_BUCKET_D = 'OCTOPUSCL_AWS_S3_BUCKET_D'  # Development
ENV_OCTOPUSCL_AWS_S3_BUCKET_S = 'OCTOPUSCL_AWS_S3_BUCKET_S'  # Staging
ENV_OCTOPUSCL_AWS_S3_BUCKET_P = 'OCTOPUSCL_AWS_S3_BUCKET_P'  # Production

ENV_OCTOPUSCL_AWS_S3_DATASETS_DIR = 'OCTOPUSCL_AWS_S3_DATASETS_DIR'

# OctopusCL: MLflow
ENV_OCTOPUSCL_MLFLOW_TRACKING_URI_D = 'OCTOPUSCL_MLFLOW_TRACKING_URI_D'  # Development
ENV_OCTOPUSCL_MLFLOW_TRACKING_URI_S = 'OCTOPUSCL_MLFLOW_TRACKING_URI_S'  # Staging
ENV_OCTOPUSCL_MLFLOW_TRACKING_URI_P = 'OCTOPUSCL_MLFLOW_TRACKING_URI_P'  # Production

# OctopusCL: Docker
ENV_OCTOPUSCL_DOCKER_IMG = 'OCTOPUSCL_DOCKER_IMG'
ENV_OCTOPUSCL_DOCKER_IMG_CMD = 'OCTOPUSCL_DOCKER_IMG_CMD'

# MLflow
ENV_MLFLOW_TRACKING_URI = 'MLFLOW_TRACKING_URI'  # Considered only if there is no active environment
ENV_MLFLOW_TRACKING_USERNAME = 'MLFLOW_TRACKING_USERNAME'
ENV_MLFLOW_TRACKING_PASSWORD = 'MLFLOW_TRACKING_PASSWORD'

#######################################################
# ENVIRONMENT VARIABLES REQUIRED FOR EACH ENVIRONMENT #
#######################################################

_development_env_vars = []

_staging_env_vars = [
    ENV_AWS_ACCESS_KEY_ID, ENV_AWS_SECRET_ACCESS_KEY, ENV_OCTOPUSCL_AWS_EC2_AMI_ID, ENV_OCTOPUSCL_AWS_EC2_INSTANCE_TYPE,
    ENV_OCTOPUSCL_AWS_EC2_MAX_INSTANCES, ENV_OCTOPUSCL_AWS_EC2_STORAGE_SIZE, ENV_OCTOPUSCL_AWS_EC2_USER_NAME,
    ENV_OCTOPUSCL_AWS_EC2_ROLE_NAME, ENV_OCTOPUSCL_AWS_EC2_SECURITY_GROUP, ENV_OCTOPUSCL_AWS_S3_BUCKET_S,
    ENV_OCTOPUSCL_AWS_S3_DATASETS_DIR, ENV_OCTOPUSCL_DOCKER_IMG, ENV_OCTOPUSCL_DOCKER_IMG_CMD,
    ENV_OCTOPUSCL_MLFLOW_TRACKING_URI_S
]

_production_env_vars = [
    ENV_AWS_ACCESS_KEY_ID, ENV_AWS_SECRET_ACCESS_KEY, ENV_OCTOPUSCL_AWS_EC2_AMI_ID, ENV_OCTOPUSCL_AWS_EC2_INSTANCE_TYPE,
    ENV_OCTOPUSCL_AWS_EC2_MAX_INSTANCES, ENV_OCTOPUSCL_AWS_EC2_STORAGE_SIZE, ENV_OCTOPUSCL_AWS_EC2_USER_NAME,
    ENV_OCTOPUSCL_AWS_EC2_ROLE_NAME, ENV_OCTOPUSCL_AWS_EC2_SECURITY_GROUP, ENV_OCTOPUSCL_AWS_S3_BUCKET_P,
    ENV_OCTOPUSCL_AWS_S3_DATASETS_DIR, ENV_OCTOPUSCL_DOCKER_IMG, ENV_OCTOPUSCL_DOCKER_IMG_CMD,
    ENV_OCTOPUSCL_MLFLOW_TRACKING_URI_P
]

REQUIRED_ENV_VARS = MappingProxyType({
    Environment.DEVELOPMENT: _development_env_vars,
    Environment.STAGING: _staging_env_vars,
    Environment.PRODUCTION: _production_env_vars,
})
