package com.cameleer.server.core.runtime;

import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public record Deployment(
        UUID id,
        UUID appId,
        UUID appVersionId,
        UUID environmentId,
        DeploymentStatus status,
        String targetState,
        String deploymentStrategy,
        List<Map<String, Object>> replicaStates,
        String deployStage,
        String containerId,
        String containerName,
        String errorMessage,
        Map<String, Object> resolvedConfig,
        DeploymentConfigSnapshot deployedConfigSnapshot,
        Instant deployedAt,
        Instant stoppedAt,
        Instant createdAt,
        String createdBy
) {
    public Deployment withStatus(DeploymentStatus newStatus) {
        return new Deployment(id, appId, appVersionId, environmentId, newStatus,
                targetState, deploymentStrategy, replicaStates, deployStage,
                containerId, containerName, errorMessage, resolvedConfig,
                deployedConfigSnapshot, deployedAt, stoppedAt, createdAt, createdBy);
    }

    public Deployment withDeployedConfigSnapshot(DeploymentConfigSnapshot snapshot) {
        return new Deployment(id, appId, appVersionId, environmentId, status,
                targetState, deploymentStrategy, replicaStates, deployStage,
                containerId, containerName, errorMessage, resolvedConfig,
                snapshot, deployedAt, stoppedAt, createdAt, createdBy);
    }
}
