package com.atlassian.bitbucket.internal.mirroring;

import com.atlassian.bitbucket.user.ApplicationUser;
import com.atlassian.bitbucket.validation.annotation.RequiredString;
import com.atlassian.bitbucket.validation.annotation.RequiredUri;

import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;
import java.net.URI;
import java.util.Date;

import static com.atlassian.bitbucket.internal.mirroring.MirroringConstants.*;

/**
 * Represents a request to act as a mirror.
 */
public interface MirroringRequest {

    @RequiredUri(size = MAX_ADDON_DESCRIPTOR_URL_LENGTH)
    URI getAddonDescriptorUri();

    /**
     * @return the date when the request was first created
     */
    @NotNull
    Date getCreatedDate();

    /**
     * @return the unique ID of the request. This will only ever be null for non-registered requests
     */
    @Nullable
    Integer getId();

    /**
     * @return the mirror's base URL
     */
    @RequiredString(size = MAX_BASE_URL_LENGTH)
    @NotNull
    String getBaseUrl();

    /**
     * @return the unique ID of the mirror
     */
    @RequiredString(size = MAX_MIRROR_ID_LENGTH)
    @NotNull
    String getMirrorId();

    /**
     * @return the non-unique name of the mirror
     */
    @RequiredString(size = MAX_MIRROR_NAME_LENGTH)
    @NotNull
    String getMirrorName();

    /**
     * @return the name of the software product running the mirror
     */
    @RequiredString(size = MAX_PRODUCT_TYPE_LENGTH)
    @NotNull
    String getProductType();

    /**
     * @return the version of the software product running the mirror
     */
    @RequiredString(size = MAX_PRODUCT_VERSION_LENGTH)
    @NotNull
    String getProductVersion();

    /**
     * @return if {@link MirroringRequestState#ACCEPTED accepted} or
     * {@link MirroringRequestState#REJECTED rejected}, the date when this occurred; null otherwise
     */
    @Nullable
    Date getResolvedDate();

    /**
     * @return if {@link MirroringRequestState#ACCEPTED accepted} or
     * {@link MirroringRequestState#REJECTED rejected}, the user who performed this operation; null otherwise
     */
    @Nullable
    ApplicationUser getResolver();

    /**
     * @return the state of the request
     */
    @NotNull
    MirroringRequestState getState();
}
