package be.iminds.ilabt.jfed.preferences;

import be.iminds.ilabt.jfed.util.OSDetector;

/**
* CorePreferenceKey
*/
public enum CorePreferenceKey implements JFedPreferences.PreferenceKey {
    PREF_DEBUG_CPU("debug.cpu"), //periodic dumping of CPU usage to logs or not (default false)   (should be passed to SfaConnectionPool)

    PREF_LOGGING_OVERWRITE("logging.overwrite"), //should jFed settings overwrite default settings? (if false, jFed will not try to change logging settings)
    PREF_LOGGING_ROOT_LEVEL("logging.logger.root_level"), //root log level
    PREF_LOGGING_EXTTERM_LEVEL("logging.logger.terminal_level"), //log level for starting external terminals
//    PREF_LOGGING_APPENDER_STDOUT_LEVEL("logging.appender.stdout_level"),
//    PREF_LOGGING_APPENDER_BUGREPORT_LEVEL("logging.appender.bugreport_level"),

    RETRY_TIMEOUT_MAX("retry.timeoutMaxRetries"),
    RETRY_TIMEOUT_MS_DELAY("retry.timeoutMsBeforeRetry"),
    RETRY_BUSY_MAX("retry.busyMaxRetries"),
    RETRY_BUSY_MS_DELAY("retry.busyMsBeforeRetry"),
    RETRY_POSTEMPERR_MAX("retry.possibleTemporaryErrorMaxRetries"),
    RETRY_POSTEMPERR_MS_DELAY("retry.possibleTemporaryErrorMsBeforeRetry"),

    PREF_JFED_WEBAPI_URL("webapi.url"),  //"http*" or "BUILTIN"
    PREF_TESTBEDS_JSON_SOURCE("testbed.testbeds_json.source"),  //"AUTO" (= use online f4f testbeds.json or fallback), "file:*" or "http*" or "BUILTIN" or "CACHE"
    PREF_GUICONFIG_SOURCE("guiconfig.source"),  //"AUTO" (= use online or fallback), "file:*" or "http*" or "BUILTIN" or "CACHE"
    PREF_GUICONFIG_EXTRA_FLAGS("guiconfig.extra_flags"), //extra flags to pass to the server when requesting userinfo (String with comma separated list)

    PREF_SCS_URN("scs.urn"),
    PREF_SCS_URL("scs.url"),

    PREF_TESTBEDSPECIFIC_EXOGENI_FORCE_EXOSM("testbed.exogeni.force_exo_sm"),  //AUTO (= use testbeds.xml), YES or NO
    PREF_TESTBEDSPECIFIC_EXOGENI_RECOVER_METHOD("testbed.exogeni.recover_method"),  //BOTH or SINGLE:
                                                                                    //BOTH (= first use exoSM, fall back to others if nothing found there),
                                                                                    //SINGLE (= use what testbed.exogeni.force_exo_sm says)

    /*
    //override SSH proxy settings. private key MUST be unencrypted. On windows it needs to be PuTTY key file.
    PREF_SSHPROXY_OVERRIDE("sshproxy.override"),
    PREF_SSHPROXY_HOSTNAME("sshproxy.hostname"),
    PREF_SSHPROXY_PORT("sshproxy.port"),
    PREF_SSHPROXY_USERNAME("sshproxy.username"),
    PREF_SSHPROXY_HOSTKEY("sshproxy.hostkey"),
    PREF_SSHPROXY_PUBLIC_KEY_FILE("sshproxy.public_key.file"),
    PREF_SSHPROXY_PRIVATE_KEY_FILE("sshproxy.private_key.file"),
    PREF_SSHPROXY_PUTTY_KEY_FILE("sshproxy.putty_key.file"),
    PREF_SSHPROXY_PUBLIC_KEY("sshproxy.public_key.text"),
    PREF_SSHPROXY_PRIVATE_KEY("sshproxy.private_key.text"),   */

    PREF_SSHPROXY_USE_FOR_JFED("sshproxy.use_for_jfed"), //AUTO, ALWAYS or NEVER
    PREF_SSHPROXY_USE_FOR_SSH("sshproxy.use_for_ssh"), //AUTO, ALWAYS or NEVER

    PREF_SSHPROXY_DNS_OVER_PROXY_JFED("sshproxy.dns_over_proxy_for_jfed"), //boolean
    PREF_SSHPROXY_DNS_OVER_PROXY_SSH("sshproxy.dns_over_proxy_for_ssh"), //boolean
    ;

    final String key;
    final OSDetector.OSFilter osFilter;

    CorePreferenceKey(String key) {
        this.key = key;
        this.osFilter = null;
    }

    CorePreferenceKey(String key, OSDetector.OSFilter osFilter) {
        this.key = key;
        this.osFilter = osFilter;
    }

    @Override
    public String toString() {
        return key;
    }

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public boolean isOSSpecific() {
        return osFilter != null;
    }

    @Override
    public OSDetector.OSFilter getOSFilter() {
        return osFilter;
    }

}
