package com.atlassian.bitbucket.internal.mirroring.mirror;

import java.util.concurrent.TimeUnit;

public class MirrorConstants {

    public static final String PROPERTY_PREFIX = "plugin.mirroring.";
    public static final String PROPERTY_STATE_REFRESH_INTERVAL = PROPERTY_PREFIX + "state.refresh.interval";
    public static final String PROPERTY_SYNC_DELAY_INITIAL = PROPERTY_PREFIX + "synchronization.delay.initial";
    public static final String PROPERTY_SYNC_FETCH_TIMEOUT_EXEC = PROPERTY_PREFIX + "synchronization.fetch.timeout.execution";
    public static final String PROPERTY_SYNC_FETCH_TIMEOUT_IDLE = PROPERTY_PREFIX + "synchronization.fetch.timeout.idle";
    public static final String PROPERTY_SYNC_INTERVAL = PROPERTY_PREFIX + "synchronization.interval";
    public static final String PROPERTY_SYNC_MAX_FAILURES = PROPERTY_PREFIX + "synchronization.max.failures";
    public static final String PROPERTY_SYNC_REPOS_PAGE_SIZE_MAX = PROPERTY_PREFIX + "synchronization.repository.page.size.max";
    public static final String PROPERTY_SYNC_THREADS = PROPERTY_PREFIX + "synchronization.threads";
    public static final String PROPERTY_UPSTREAM_REQUEST_TIMEOUT = PROPERTY_PREFIX + "upstream.request.timeout";
    public static final String PROPERTY_UPSTREAM_REQUEST_SO_TIMEOUT = PROPERTY_PREFIX + "upstream.request.socket.timeout";
    public static final String PROPERTY_UPSTREAM_REGO_RETRY_PREFIX = PROPERTY_PREFIX + "upstream.registration.retry.";
    public static final String PROPERTY_UPSTREAM_REGO_RETRY_BACKOFF_FACTOR = PROPERTY_UPSTREAM_REGO_RETRY_PREFIX + "backoff.factor";
    public static final String PROPERTY_UPSTREAM_REGO_RETRY_INTERVAL = PROPERTY_UPSTREAM_REGO_RETRY_PREFIX + "interval";
    public static final String PROPERTY_UPSTREAM_REGO_RETRY_MAX = PROPERTY_UPSTREAM_REGO_RETRY_PREFIX + "max.interval";
    public static final String PROPERTY_UPSTREAM_NAMESPACE = PROPERTY_PREFIX + "upstream.namespace";
    /**
     * This must be kept in sync with {@code com.atlassian.stash.internal.bootstrap.BootstrapOperation#KEY_MIRROR_UPSTREAM}.
     */
    public static final String PROPERTY_UPSTREAM_URL = PROPERTY_PREFIX + "upstream.url";
    /**
     * This must be kept in sync with {@code com.atlassian.stash.internal.bootstrap.BootstrapOperation#KEY_MIRROR_TYPE}
     */
    public static final String PROPERTY_UPSTREAM_TYPE = PROPERTY_PREFIX + "upstream.type";
    public static final String PROPERTY_CLOUD_URL = PROPERTY_PREFIX + "cloud.url";

    public static final int DEFAULT_UPSTREAM_REQUEST_SO_TIMEOUT_SECONDS = 30;
    public static final int DEFAULT_UPSTREAM_REQUEST_TIMEOUT_SECONDS = 30;
    public static final long DEFAULT_REFRESH_INTERVAL_MINUTES = 15;
    public static final long DEFAULT_SYNC_DELAY_SECONDS = 20;
    public static final long DEFAULT_SYNC_TIMEOUT_EXEC_SECONDS = TimeUnit.HOURS.toSeconds(4);
    public static final long DEFAULT_SYNC_TIMEOUT_IDLE_SECONDS = TimeUnit.MINUTES.toSeconds(5);
    public static final long DEFAULT_SYNC_INTERVAL_MINUTES = 15;
    public static final int DEFAULT_SYNC_MAX_FAILURES = 3;
    public static final int DEFAULT_SYNC_REPO_REQUEST_MAX_PAGE = 100;
    public static final int DEFAULT_SYNC_THREADS = 2;
    public static final long DEFAULT_UPSTREAM_REGO_RETRY_INTERVAL_MS = TimeUnit.SECONDS.toMillis(10);
    public static final double DEFAULT_UPSTREAM_REGO_RETRY_EXP_FACTOR = 1.3d;
    public static final long DEFAULT_UPSTREAM_REGO_RETRY_MAX_INTERVAL_MS = TimeUnit.MINUTES.toMillis(15);

    public static final String PARAM_HIGHEST_PERM = "highest-permission";
    public static final String PARAM_UPSTREAM_USERNAME = "upstream-username";
    public static final String PARAM_UPSTREAM_USERNAME_TEMPLATE = "{user.username}";

    public static final String ATTR_JWT_HIGHEST_PERM = "bitbucket.jwt.highest.permission";
    public static final String ATTR_JWT_IMP_USER = "bitbucket.jwt.subject.user";
    public static final String ATTR_JWT_PAYLOAD = "bitbucket.jwt.payload";

    private MirrorConstants() {
        throw new UnsupportedOperationException("MirrorConstants is a utility class");
    }
}