29 lines
1020 B
Go
29 lines
1020 B
Go
package models
|
|
|
|
import "time"
|
|
|
|
// JobStatus represents the state of a job
|
|
type JobStatus string
|
|
|
|
const (
|
|
JobStatusPending JobStatus = "pending"
|
|
JobStatusRunning JobStatus = "running"
|
|
JobStatusCompleted JobStatus = "completed"
|
|
JobStatusFailed JobStatus = "failed"
|
|
JobStatusCancelled JobStatus = "cancelled"
|
|
)
|
|
|
|
// Job represents a long-running asynchronous operation
|
|
type Job struct {
|
|
ID string `json:"id"`
|
|
Type string `json:"type"` // "pool_create", "snapshot_create", etc.
|
|
Status JobStatus `json:"status"`
|
|
Progress int `json:"progress"` // 0-100
|
|
Message string `json:"message"`
|
|
Error string `json:"error,omitempty"`
|
|
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
StartedAt *time.Time `json:"started_at,omitempty"`
|
|
CompletedAt *time.Time `json:"completed_at,omitempty"`
|
|
}
|