package model

import "time"

type JobStatus string

const (
	JobStatusPending  JobStatus = "pending"
	JobStatusRunning  JobStatus = "running"
	JobStatusComplete JobStatus = "complete"
	JobStatusFailed   JobStatus = "failed"
	JobStatusStopped  JobStatus = "stopped"
)

type Job struct {
	ID        string     `json:"id"`
	Name      string     `json:"name"`
	Spec      string     `json:"spec"`
	Status    JobStatus  `json:"status"`
	CreatedAt time.Time  `json:"created_at"`
	StartedAt *time.Time `json:"started_at,omitempty"`
	EndedAt   *time.Time `json:"ended_at,omitempty"`
	ExitCode  int        `json:"exit_code"`
}

type TaskStatus string

const (
	TaskStatusPending  TaskStatus = "pending"
	TaskStatusRunning  TaskStatus = "running"
	TaskStatusComplete TaskStatus = "complete"
	TaskStatusFailed   TaskStatus = "failed"
	TaskStatusKilled   TaskStatus = "killed"
)

type Task struct {
	ID        string     `json:"id"`
	JobID     string     `json:"job_id"`
	Command   string     `json:"command"`
	Args      []string   `json:"args"`
	Env       []string   `json:"env,omitempty"`
	PID       int        `json:"pid"`
	ExitCode  int        `json:"exit_code"`
	Status    TaskStatus `json:"status"`
	CreatedAt time.Time  `json:"created_at"`
	StartedAt *time.Time `json:"started_at,omitempty"`
	EndedAt   *time.Time `json:"ended_at,omitempty"`
	Stdout    string     `json:"stdout,omitempty"`
	Stderr    string     `json:"stderr,omitempty"`
}
