from enum import Enum


class ActorEventType(str, Enum):
    """Possible values of actor event type."""

    #: Info about CPU usage of the actor
    CPU_INFO = 'cpuInfo'
    #: Info about resource usage of the actor
    SYSTEM_INFO = 'systemInfo'
    #: Sent when the actor is about to migrate
    MIGRATING = 'migrating'
    #: Sent when the actor should persist its state (every minute or when migrating)
    PERSIST_STATE = 'persistState'
    #: Sent when the actor is aborting
    ABORTING = 'aborting'


class ApifyEnvVars(str, Enum):
    """Possible Apify env vars."""

    ACT_ID = 'APIFY_ACT_ID'
    ACT_RUN_ID = 'APIFY_ACT_RUN_ID'
    ACTOR_BUILD_ID = 'APIFY_ACTOR_BUILD_ID'
    ACTOR_BUILD_NUMBER = 'APIFY_ACTOR_BUILD_NUMBER'
    ACTOR_EVENTS_WS_URL = 'APIFY_ACTOR_EVENTS_WS_URL'
    ACTOR_ID = 'APIFY_ACTOR_ID'
    ACTOR_RUN_ID = 'APIFY_ACTOR_RUN_ID'
    ACTOR_TASK_ID = 'APIFY_ACTOR_TASK_ID'
    API_BASE_URL = 'APIFY_API_BASE_URL'
    API_PUBLIC_BASE_URL = 'APIFY_API_PUBLIC_BASE_URL'
    CHROME_EXECUTABLE_PATH = 'APIFY_CHROME_EXECUTABLE_PATH'
    CONTAINER_PORT = 'APIFY_CONTAINER_PORT'
    CONTAINER_URL = 'APIFY_CONTAINER_URL'
    DEDICATED_CPUS = 'APIFY_DEDICATED_CPUS'
    DEFAULT_DATASET_ID = 'APIFY_DEFAULT_DATASET_ID'
    DEFAULT_KEY_VALUE_STORE_ID = 'APIFY_DEFAULT_KEY_VALUE_STORE_ID'
    DEFAULT_REQUEST_QUEUE_ID = 'APIFY_DEFAULT_REQUEST_QUEUE_ID'
    DISABLE_OUTDATED_WARNING = 'APIFY_DISABLE_OUTDATED_WARNING'
    FACT = 'APIFY_FACT'
    HEADLESS = 'APIFY_HEADLESS'
    INPUT_KEY = 'APIFY_INPUT_KEY'
    INPUT_SECRETS_PRIVATE_KEY_FILE = 'APIFY_INPUT_SECRETS_PRIVATE_KEY_FILE'
    INPUT_SECRETS_PRIVATE_KEY_PASSPHRASE = 'APIFY_INPUT_SECRETS_PRIVATE_KEY_PASSPHRASE'
    IS_AT_HOME = 'APIFY_IS_AT_HOME'
    LOCAL_STORAGE_DIR = 'APIFY_LOCAL_STORAGE_DIR'
    LOG_FORMAT = 'APIFY_LOG_FORMAT'
    LOG_LEVEL = 'APIFY_LOG_LEVEL'
    MEMORY_MBYTES = 'APIFY_MEMORY_MBYTES'
    META_ORIGIN = 'APIFY_META_ORIGIN'
    PROXY_HOSTNAME = 'APIFY_PROXY_HOSTNAME'
    PROXY_PASSWORD = 'APIFY_PROXY_PASSWORD'
    PROXY_PORT = 'APIFY_PROXY_PORT'
    PROXY_STATUS_URL = 'APIFY_PROXY_STATUS_URL'
    SDK_LATEST_VERSION = 'APIFY_SDK_LATEST_VERSION'
    STARTED_AT = 'APIFY_STARTED_AT'
    TIMEOUT_AT = 'APIFY_TIMEOUT_AT'
    TOKEN = 'APIFY_TOKEN'
    USER_ID = 'APIFY_USER_ID'
    WORKFLOW_KEY = 'APIFY_WORKFLOW_KEY'
    XVFB = 'APIFY_XVFB'

    # Extra ones not in consts:
    METAMORPH_AFTER_SLEEP_MILLIS = 'APIFY_METAMORPH_AFTER_SLEEP_MILLIS'
    PERSIST_STATE_INTERVAL_MILLIS = 'APIFY_PERSIST_STATE_INTERVAL_MILLIS'
    PURGE_ON_START = 'APIFY_PURGE_ON_START'


INTEGER_ENV_VARS = [
    ApifyEnvVars.CONTAINER_PORT.value,
    ApifyEnvVars.DEDICATED_CPUS.value,
    ApifyEnvVars.MEMORY_MBYTES.value,
    ApifyEnvVars.METAMORPH_AFTER_SLEEP_MILLIS.value,
    ApifyEnvVars.PERSIST_STATE_INTERVAL_MILLIS.value,
    ApifyEnvVars.PROXY_PORT.value,
]

BOOL_ENV_VARS = [
    ApifyEnvVars.HEADLESS.value,
    ApifyEnvVars.IS_AT_HOME.value,
    ApifyEnvVars.PURGE_ON_START.value,
    ApifyEnvVars.XVFB.value,
]

DATETIME_ENV_VARS = [
    ApifyEnvVars.STARTED_AT.value,
    ApifyEnvVars.TIMEOUT_AT.value,
]
