package com.cameleer.server.app.alerting.dto;

import com.cameleer.server.core.alerting.AlertInstance;
import com.cameleer.server.core.alerting.AlertSeverity;
import com.cameleer.server.core.alerting.AlertState;

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

public record AlertDto(
        UUID id,
        UUID ruleId,
        UUID environmentId,
        AlertState state,
        AlertSeverity severity,
        String title,
        String message,
        Instant firedAt,
        Instant ackedAt,
        String ackedBy,
        Instant resolvedAt,
        Instant readAt,     // global "has anyone read this"
        boolean silenced,
        Double currentValue,
        Double threshold,
        Map<String, Object> context
) {
    public static AlertDto from(AlertInstance i) {
        return new AlertDto(
                i.id(), i.ruleId(), i.environmentId(), i.state(), i.severity(),
                i.title(), i.message(), i.firedAt(), i.ackedAt(), i.ackedBy(),
                i.resolvedAt(), i.readAt(), i.silenced(),
                i.currentValue(), i.threshold(), i.context());
    }
}
