Füge Modelle für Flows, FlowRuns, TaskRuns, WorkPools, WorkQueues, Deployments, Variablen, FlowRunStates, Logs, und Blocks samt zugehöriger Unmarshal-Logik und Zeitfeld-Unterstützung hinzu; ergänze Tests für die FlowRunStates-Service-Methoden.

This commit is contained in:
Gregor Schulte
2026-03-27 14:02:32 +01:00
parent 3aff707116
commit 57531a7d95
36 changed files with 3165 additions and 0 deletions

58
pkg/models/events.go Normal file
View File

@@ -0,0 +1,58 @@
package models
import (
"time"
"github.com/google/uuid"
)
// EventOrder represents sort order for events.
type EventOrder string
const (
EventOrderAsc EventOrder = "ASC"
EventOrderDesc EventOrder = "DESC"
)
// Resource represents an observable business object.
type Resource map[string]string
// RelatedResource represents a resource with a specific role in an event.
type RelatedResource map[string]string
// Event represents a Prefect event.
type Event struct {
Occurred time.Time `json:"occurred"`
Event string `json:"event"`
Resource Resource `json:"resource"`
Related []RelatedResource `json:"related,omitempty"`
ID uuid.UUID `json:"id"`
Payload map[string]interface{} `json:"payload,omitempty"`
Received *time.Time `json:"received,omitempty"`
}
// EventFilter represents filter criteria for querying events.
type EventFilter struct {
Occurred interface{} `json:"occurred,omitempty"`
Event interface{} `json:"event,omitempty"`
Resource interface{} `json:"resource,omitempty"`
Related interface{} `json:"related,omitempty"`
ID interface{} `json:"id,omitempty"`
Order EventOrder `json:"order,omitempty"`
}
// EventPage represents a page of events.
type EventPage struct {
Events []Event `json:"events"`
Total int `json:"total"`
NextPage *string `json:"next_page"`
}
// EventCount represents a count of events for a given filter value.
type EventCount struct {
Value string `json:"value"`
Label string `json:"label"`
Count int `json:"count"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
}