package com.ai.trackwalker.api.dto;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;

import java.util.List;
import java.util.Map;

public final class ModelManagementRequests {
    private ModelManagementRequests() {
    }

    public record CreateParameterProfileRequest(
            @NotBlank String modelVersionId,
            @NotBlank String name,
            String scopeType,
            Map<String, Object> scopeValue,
            @NotNull Map<String, Object> parameters,
            String basedOnId,
            String changeReason,
            String operator
    ) {
    }

    public record CreateParameterRevisionRequest(
            @NotNull Map<String, Object> parameters,
            Map<String, Object> scopeValue,
            String changeReason,
            String operator
    ) {
    }

    public record ValidateParametersRequest(
            @NotBlank String modelGroupId,
            @NotBlank String modelVersionId,
            @NotNull Map<String, Object> parameters
    ) {
    }

    public record CreateUploadSessionRequest(
            @NotBlank String modelGroupId,
            Integer retentionDays,
            String operator
    ) {
    }

    public record CreateChunkedFileRequest(
            @NotBlank String fileName,
            String contentType,
            @NotNull Long totalSizeBytes,
            Integer partSizeBytes,
            String sha256
    ) {
    }

    public record SampleSetPreviewRequest(
            @NotEmpty List<String> sampleIds
    ) {
    }

    public record TestMatrixItem(
            @NotBlank String modelVersionId,
            String parameterProfileId,
            Map<String, Object> temporaryParameters
    ) {
    }

    public record TestInputSelection(
            List<String> librarySampleIds,
            List<String> uploadSessionIds
    ) {
    }

    public record CreateModelTestRequest(
            @NotBlank String name,
            @NotBlank String testType,
            @NotBlank String modelGroupId,
            @NotEmpty List<@Valid TestMatrixItem> matrix,
            @NotNull TestInputSelection inputs,
            Map<String, Object> options,
            String operator
    ) {
    }

    public record ResultFeedbackRequest(
            @NotBlank String feedbackType,
            String comment,
            Boolean archiveAsSample,
            String operator
    ) {
    }

    public record CreateReleaseRequest(
            @NotBlank String modelGroupId,
            @NotBlank String modelVersionId,
            @NotBlank String parameterProfileId,
            String evaluationTaskId,
            Map<String, Object> grayStrategy,
            String applicant,
            String comment
    ) {
    }

    public record ReleaseDecisionRequest(String operator, String comment) {
    }

    public record GrayReleaseRequest(Integer grayPercent, Map<String, Object> strategy, String operator, String comment) {
    }

    public record RollbackReleaseRequest(
            @NotBlank String targetVersionId,
            @NotBlank String targetProfileId,
            String operator,
            String comment
    ) {
    }

    public record SaveRuntimeDeploymentRequest(
            @NotBlank String modelVersionId,
            @NotBlank String name,
            @NotBlank String environment,
            @NotBlank String serviceUrl,
            String healthPath,
            String runtimePath,
            @NotBlank String inferencePath,
            @NotBlank String testPath,
            @NotBlank String runtimeEngine,
            @NotBlank String executionProvider,
            @NotBlank String device,
            @NotBlank String precision,
            String artifactUri,
            String authSecretRef,
            @Min(1) @Max(100) Integer replicas,
            @Min(1) @Max(1000) Integer maxConcurrency,
            @Min(1) @Max(3600) Integer requestTimeoutSeconds,
            Map<String, Object> config,
            String operator
    ) {
    }

    public record SwitchRuntimeDeploymentRequest(
            Boolean force,
            String operator,
            String reason
    ) {
    }
}
