2024-02-27 11:04:05 +00:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
2024-02-29 22:42:56 +00:00
|
|
|
"database/sql/driver"
|
|
|
|
"fmt"
|
2024-02-27 11:04:05 +00:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2024-02-29 22:42:56 +00:00
|
|
|
type Time struct {
|
|
|
|
Time time.Time
|
|
|
|
}
|
|
|
|
|
|
|
|
// rfc3339Milli is like time.RFC3339Nano, but with millisecond precision, and fractional seconds do not have trailing
|
|
|
|
// zeros removed.
|
|
|
|
const rfc3339Milli = "2006-01-02T15:04:05.000Z07:00"
|
|
|
|
|
|
|
|
// Value satisfies driver.Valuer interface.
|
|
|
|
func (t *Time) Value() (driver.Value, error) {
|
|
|
|
return t.Time.UTC().Format(rfc3339Milli), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Scan satisfies sql.Scanner interface.
|
|
|
|
func (t *Time) Scan(src any) error {
|
|
|
|
if src == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
s, ok := src.(string)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("error scanning time, got %+v", src)
|
|
|
|
}
|
|
|
|
|
|
|
|
parsedT, err := time.Parse(rfc3339Milli, s)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Time = parsedT.UTC()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-03-01 09:53:36 +00:00
|
|
|
type OAuth2State struct {
|
|
|
|
State string `db:"state"`
|
|
|
|
ExpiresAt *Time `db:"expires_at"`
|
|
|
|
}
|
|
|
|
|
2024-05-18 20:18:28 +00:00
|
|
|
type CheckState string
|
|
|
|
|
|
|
|
const (
|
|
|
|
CheckStateActive CheckState = "ACTIVE"
|
|
|
|
CheckStatePaused CheckState = "PAUSED"
|
|
|
|
CheckStateUnknown CheckState = "UNKNOWN"
|
|
|
|
)
|
|
|
|
|
2024-05-16 20:15:14 +00:00
|
|
|
type Check struct {
|
2024-03-01 09:53:36 +00:00
|
|
|
CreatedAt *Time `db:"created_at"`
|
|
|
|
UpdatedAt *Time `db:"updated_at"`
|
2024-02-27 11:04:05 +00:00
|
|
|
|
2024-05-23 16:33:30 +00:00
|
|
|
Id string `db:"id"`
|
|
|
|
Name string `db:"name"`
|
2024-02-27 11:04:05 +00:00
|
|
|
|
|
|
|
Schedule string `db:"schedule"`
|
|
|
|
Script string `db:"script"`
|
2024-05-23 16:33:30 +00:00
|
|
|
Filter string `db:"filter"`
|
2024-02-27 11:04:05 +00:00
|
|
|
}
|
|
|
|
|
2024-05-16 20:15:14 +00:00
|
|
|
type CheckWithWorkerGroups struct {
|
|
|
|
Check
|
2024-02-27 11:04:05 +00:00
|
|
|
// List of worker group names
|
|
|
|
WorkerGroups []string
|
|
|
|
}
|
|
|
|
|
|
|
|
type WorkerGroup struct {
|
2024-03-01 09:53:36 +00:00
|
|
|
CreatedAt *Time `db:"created_at"`
|
|
|
|
UpdatedAt *Time `db:"updated_at"`
|
2024-02-27 11:04:05 +00:00
|
|
|
|
2024-02-29 22:42:56 +00:00
|
|
|
Id string `db:"id"`
|
2024-02-27 11:04:05 +00:00
|
|
|
Name string `db:"name"`
|
|
|
|
}
|
|
|
|
|
2024-05-16 20:15:14 +00:00
|
|
|
type WorkerGroupWithChecks struct {
|
2024-02-27 11:04:05 +00:00
|
|
|
WorkerGroup
|
|
|
|
|
|
|
|
// List of worker group names
|
2024-05-16 20:15:14 +00:00
|
|
|
Checks []string
|
2024-02-27 11:04:05 +00:00
|
|
|
}
|
2024-04-28 19:24:00 +00:00
|
|
|
|
2024-05-18 20:18:28 +00:00
|
|
|
type TriggerState string
|
|
|
|
|
|
|
|
const (
|
|
|
|
TriggerStateActive TriggerState = "ACTIVE"
|
|
|
|
TriggerStatePaused TriggerState = "PAUSED"
|
|
|
|
TriggerStateUnknown TriggerState = "UNKNOWN"
|
|
|
|
)
|
|
|
|
|
2024-04-28 19:24:00 +00:00
|
|
|
type Trigger struct {
|
|
|
|
CreatedAt *Time `db:"created_at"`
|
|
|
|
UpdatedAt *Time `db:"updated_at"`
|
|
|
|
|
2024-05-18 20:18:28 +00:00
|
|
|
Id string `db:"id"`
|
|
|
|
Name string `db:"name"`
|
|
|
|
Script string `db:"script"`
|
2024-04-28 19:24:00 +00:00
|
|
|
}
|
|
|
|
|
2024-05-23 16:33:30 +00:00
|
|
|
type TargetVisibility string
|
|
|
|
|
|
|
|
const (
|
|
|
|
TargetVisibilityPublic TargetVisibility = "PUBLIC"
|
|
|
|
TargetVisibilityPrivate TargetVisibility = "PRIVATE"
|
|
|
|
TargetVisibilityUnknown TargetVisibility = "UNKNOWN"
|
|
|
|
)
|
|
|
|
|
|
|
|
type TargetState string
|
|
|
|
|
|
|
|
const (
|
|
|
|
TargetStateActive TargetState = "ACTIVE"
|
|
|
|
TargetStatePaused TargetState = "PAUSED"
|
|
|
|
TargetStateUnknown TargetState = "UNKNOWN"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Target struct {
|
|
|
|
CreatedAt *Time `db:"created_at"`
|
|
|
|
UpdatedAt *Time `db:"updated_at"`
|
|
|
|
|
|
|
|
Id string `db:"id"`
|
|
|
|
Name string `db:"name"`
|
|
|
|
Group string `db:"group"`
|
|
|
|
Visibility TargetVisibility `db:"visibility"`
|
|
|
|
State TargetState `db:"state"`
|
|
|
|
Metadata string `db:"metadata"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type TargetStatus string
|
|
|
|
|
|
|
|
const (
|
|
|
|
TargetStatusSuccess TargetStatus = "SUCCESS"
|
|
|
|
TargetStatusFailure TargetStatus = "FAILURE"
|
|
|
|
TargetStatusUnknown TargetStatus = "UNKNOWN"
|
|
|
|
)
|
|
|
|
|
|
|
|
type TargetHistory struct {
|
2024-04-28 19:24:00 +00:00
|
|
|
CreatedAt *Time `db:"created_at"`
|
|
|
|
|
2024-05-23 16:33:30 +00:00
|
|
|
TargetId string `db:"target_id"`
|
|
|
|
Status TargetStatus `db:"status"`
|
|
|
|
Note string `db:"note"`
|
2024-04-28 19:24:00 +00:00
|
|
|
}
|