models

package
v0.0.0-...-78a2729 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RetentionDays       = 7
	TimeFormat          = "2006-01-02 15:04"
	TimeFormatRecurring = "Monday 15:04"
)

Variables

View Source
var ErrLocked = errors.New("another execution is in progress")

ErrLocked returned when homesever has a lock

Functions

This section is empty.

Types

type Alert

type Alert struct {
	ID       string
	Name     string
	Domain   string
	Instance string
	Status   string
	Icon     string
	Summary  string
	Hints    string
	Message  string
}

Alert is Grafana alert, processed by Alerter service

type AutoLock

type AutoLock struct {
	LockedAt time.Time
	Attempt  int
}

AutoLock is a lock for the automatic execution

type Contacts

type Contacts struct {
	Emails    []string
	MXIDs     []string
	UpdatedAt time.Time
	Auto      bool
}

Contacts struct

func (*Contacts) ContainsEmail

func (c *Contacts) ContainsEmail() bool

ContainsEmail checks if the contacts contains at least one email

func (*Contacts) ContainsMXID

func (c *Contacts) ContainsMXID() bool

ContainsMXID checks if the contacts contains at least one mxid

func (*Contacts) IsEmpty

func (c *Contacts) IsEmpty() bool

IsEmpty checks if the contacts is empty

type GitPosterFile

type GitPosterFile struct {
	Path    string `json:"path"`
	Content string `json:"content"`
	Action  string `json:"action"`
	Line    string `json:"line,omitempty"`
	Regex   string `json:"regex,omitempty"`
}

GitPosterFile is the struct that represents file actions to be posted to the GitPoster API

type GitPosterRequest

type GitPosterRequest struct {
	Message string           `json:"message"`
	Files   []*GitPosterFile `json:"files"`
}

GitPosterRequest is the struct that represents the request to the GitPoster API

type Invite

type Invite struct {
	MXID   id.UserID
	RoomID id.RoomID
}

Invite record

func NewInvite

func NewInvite(mxid id.UserID, roomID id.RoomID) *Invite

NewInvite creates new invite model

type Notification

type Notification struct {
	PM          id.UserID // PM is MXID to try first
	MXID        id.UserID
	RoomID      id.RoomID
	EventID     id.EventID
	ThreadReply bool
	FromAuto    bool
	Log         string
	Homeserver  string
	Message     string
	Error       string
	Output      string
	SentAt      string
}

Notification record

func NewNotification

func NewNotification(r *Run, output string) *Notification

NewNotification creates Notification model from run record

type PSDTarget

type PSDTarget struct {
	Targets []string          `json:"targets"`
	Labels  map[string]string `json:"labels"`
}

PSDTarget - Prometheus Service Discovery item

type PSDTargets

type PSDTargets []*PSDTarget

PSDTargets - Prometheus Service Discovery items

func (PSDTargets) Contains

func (p PSDTargets) Contains(needle string) bool

Contains - check if PSDTargets contains arbitrary target

func (PSDTargets) ContainsFederation

func (p PSDTargets) ContainsFederation() bool

ContainsFederation - check if PSDTargets contains matrix federation endpoint

func (PSDTargets) ContainsMSC1929

func (p PSDTargets) ContainsMSC1929() bool

ContainsMSC1929 - check if PSDTargets contains matrix MSC1929 endpoint

func (PSDTargets) GetDomains

func (p PSDTargets) GetDomains() []string

GetDomains - get domains from service discovery labels

type PingLabel

type PingLabel struct {
	URL  string `json:"url"`
	Icon string `json:"icon"`
	Text string `json:"text"`
}

func (*PingLabel) Markdown

func (l *PingLabel) Markdown() string

Markdown returns a markdown representation of the label

type PingResponse

type PingResponse struct {
	OK      bool          `json:"ok"`
	Results []*PingResult `json:"results"`
}

PingResponse is the result of the ping request

func (*PingResponse) Markdown

func (l *PingResponse) Markdown() string

type PingResult

type PingResult struct {
	OK     bool       `json:"ok"`
	Reason string     `json:"reason"`
	Target string     `json:"url"`
	Label  *PingLabel `json:"label"`
}

PingResult

type Recurring

type Recurring struct {
	MXID       id.UserID
	RoomID     id.RoomID
	EventID    id.EventID
	UseAdmin   bool
	FromAuto   bool
	Time       string
	Homeserver string
	Message    string
	Args       string
}

Recurring record

func NewRecurring

func NewRecurring(evt *event.Event, useAdmin bool, adminRoomID id.RoomID, homeserver, command string) *Recurring

NewRecurring creates Recurring model from matrix event

func (*Recurring) Command

func (s *Recurring) Command() string

Command returns command name to run

func (*Recurring) ToSchedule

func (s *Recurring) ToSchedule(adminRoomID id.RoomID, sheduledAt string) *Schedule

ToSchedule converts recurring to scheduler model

type Run

type Run struct {
	PM         id.UserID // PM is MXID to try first
	MXID       id.UserID
	RoomID     id.RoomID
	EventID    id.EventID
	NoPM       bool
	UseAdmin   bool
	FromAuto   bool
	Prefix     string
	Log        string
	Homeserver string
	Message    string
	Args       string
	Error      string
	CreatedAt  string
	UpdatedAt  string
	ExecutedAt string
}

Run record

func NewRun

func NewRun(evt *event.Event, useAdmin bool, adminRoomID id.RoomID, homeserver, command string) *Run

NewRun creates Run model from matrix event

func (*Run) Command

func (r *Run) Command() string

Command returns command name to run

func (*Run) Executed

func (r *Run) Executed(err error)

Executed marks run model executed

type Schedule

type Schedule struct {
	MXID        id.UserID
	RoomID      id.RoomID
	EventID     id.EventID
	NoPM        bool
	Recurring   bool
	UseAdmin    bool
	FromAuto    bool
	Homeserver  string
	Message     string
	Args        string
	CreatedAt   string
	UpdatedAt   string
	ScheduledAt string
}

Schedule record

func NewSchedule

func NewSchedule(evt *event.Event, useAdmin bool, adminRoomID id.RoomID, homeserver, command string) *Schedule

NewSchedule creates Schedule model from matrix event

func (*Schedule) Command

func (s *Schedule) Command() string

Command returns command name to run

func (*Schedule) ToRun

func (s *Schedule) ToRun(adminRoomID id.RoomID, contacts *Contacts) *Run

ToRun converts schedule to run model

type Stats

type Stats struct {
	Recurring  int
	Schedules  int
	InProgress []string
	Runs       int
	TTE        map[string]time.Duration
	HSRuns     map[string]int
}

Stats of the records

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL