117 lines
3.7 KiB
Go
117 lines
3.7 KiB
Go
package event_ingress
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
EventSchemaVersion = "yovision.event/v1"
|
|
EvidenceSchemaVersion = "yovision.evidence-reference/v1"
|
|
)
|
|
|
|
type Event struct {
|
|
SchemaVersion string `json:"schema_version"`
|
|
ProducerID string `json:"producer_id"`
|
|
SourceEventID string `json:"source_event_id"`
|
|
SiteRef string `json:"site_ref"`
|
|
DeviceRef string `json:"device_ref"`
|
|
ProfileRef string `json:"profile_ref"`
|
|
EventType string `json:"event_type"`
|
|
OccurredAt string `json:"occurred_at"`
|
|
Severity string `json:"severity"`
|
|
Rule Rule `json:"rule"`
|
|
Model Model `json:"model"`
|
|
Observation Observation `json:"observation"`
|
|
Region Region `json:"region"`
|
|
Evidence []Evidence `json:"evidence"`
|
|
}
|
|
|
|
type Rule struct {
|
|
RuleID string `json:"rule_id"`
|
|
Version string `json:"version"`
|
|
}
|
|
|
|
type Model struct {
|
|
Name string `json:"name"`
|
|
Version string `json:"version"`
|
|
}
|
|
|
|
type Observation struct {
|
|
TrackID string `json:"track_id"`
|
|
Category string `json:"category"`
|
|
Confidence float64 `json:"confidence"`
|
|
BBoxNormalized []float64 `json:"bbox_normalized,omitempty"`
|
|
}
|
|
|
|
type Region struct {
|
|
RegionID string `json:"region_id"`
|
|
Kind string `json:"kind"`
|
|
CrossingDirection string `json:"crossing_direction,omitempty"`
|
|
}
|
|
|
|
type Evidence struct {
|
|
SchemaVersion string `json:"schema_version"`
|
|
EvidenceID string `json:"evidence_id"`
|
|
OwnerID string `json:"owner_id"`
|
|
Type string `json:"type"`
|
|
Status string `json:"status"`
|
|
CapturedAt string `json:"captured_at"`
|
|
StatusUpdatedAt string `json:"status_updated_at"`
|
|
ExpiresAt string `json:"expires_at,omitempty"`
|
|
ContentType string `json:"content_type,omitempty"`
|
|
Integrity *EvidenceIntegrity `json:"integrity,omitempty"`
|
|
Failure *EvidenceFailure `json:"failure,omitempty"`
|
|
}
|
|
|
|
type EvidenceIntegrity struct {
|
|
Algorithm string `json:"algorithm"`
|
|
Digest string `json:"digest"`
|
|
SizeBytes int64 `json:"size_bytes"`
|
|
}
|
|
|
|
type EvidenceFailure struct {
|
|
Code string `json:"code"`
|
|
Retryable bool `json:"retryable"`
|
|
}
|
|
|
|
type IngestResult struct {
|
|
EventID string `json:"event_id"`
|
|
ProducerID string `json:"producer_id"`
|
|
SourceEventID string `json:"source_event_id"`
|
|
Disposition string `json:"disposition"`
|
|
PayloadSHA256 string `json:"payload_sha256"`
|
|
}
|
|
|
|
type Problem struct {
|
|
Code string `json:"code"`
|
|
Message string `json:"message"`
|
|
Field string `json:"field,omitempty"`
|
|
ExistingEventID string `json:"existing_event_id,omitempty"`
|
|
}
|
|
|
|
type ParsedEvent struct {
|
|
Event Event
|
|
Canonical json.RawMessage
|
|
Digest string
|
|
Occurred time.Time
|
|
}
|
|
|
|
// EvidenceStatus is mutable Bell-owned resolution metadata kept separately
|
|
// from the immutable Event and from Alert acknowledgement/close facts.
|
|
type EvidenceStatus struct {
|
|
EventID string `gorm:"type:uuid;primaryKey"`
|
|
EvidenceID string `gorm:"size:128;primaryKey"`
|
|
OwnerID string `gorm:"size:128;not null;index"`
|
|
Status string `gorm:"size:16;not null"`
|
|
Resolution string `gorm:"size:16;not null;index"`
|
|
CurrentPayload json.RawMessage `gorm:"column:current_payload;type:jsonb;not null"`
|
|
LastError string `gorm:"size:64;not null;default:''"`
|
|
ExpiresAt *time.Time `gorm:"index"`
|
|
CheckedAt *time.Time
|
|
CreatedAt time.Time `gorm:"not null"`
|
|
UpdatedAt time.Time `gorm:"not null"`
|
|
}
|
|
|
|
func (EvidenceStatus) TableName() string { return "bell_evidence_status" }
|