package io.github.shirainbown.sharelink.model;

import java.time.Instant;
import lombok.Data;
import lombok.EqualsAndHashCode;
import run.halo.app.extension.AbstractExtension;
import run.halo.app.extension.GVK;

/**
 * A single download event. The metadata name is a random UUID; {@code spec.resourceSlug}
 * is indexed for per-resource queries.
 */
@GVK(group = "sharelink.halo.run", version = "v1alpha1", kind = "DownloadRecord",
    plural = "downloadrecords", singular = "downloadrecord")
@Data
@EqualsAndHashCode(callSuper = true)
public class DownloadRecord extends AbstractExtension {

    private Spec spec;

    @Data
    public static class Spec {

        private String resourceSlug;

        /**
         * Verified email of the downloader; blank for resources without email
         * verification.
         */
        private String email;

        private String ip;

        private String userAgent;

        private Instant downloadedAt;
    }
}
