package model

import (
	"time"
)

// SlaEvent represents a SLA threshold breach or compliance event.
// Reference: P2B M11 spec
type SlaEvent struct {
	ID            uint      `gorm:"primaryKey" json:"id"`
	AppliedSlaID  uint      `gorm:"not null;index" json:"applied_sla_id"`
	EventType     string    `gorm:"size:100;not null;index" json:"event_type"` // first_response_missed/next_response_missed/resolution_missed/first_response_met/...
	Metric        string    `gorm:"size:100" json:"metric"` // first_response_time/next_response_time/resolution_time
	BreachAt      *time.Time `json:"breach_at,omitempty"`
	CreatedAt     time.Time `gorm:"autoCreateTime" json:"created_at"`

	AppliedSLA AppliedSLA `gorm:"foreignKey:AppliedSlaID" json:"applied_sla,omitempty"`
}

func (SlaEvent) TableName() string { return "sla_events" }