upda/api/constants.go
Varakh 10bc3a59bb feat(updates,events): Streamline update state changes into one event type only (#27)
Reviewed-on: #27
Co-authored-by: Varakh <varakh@varakh.de>
Co-committed-by: Varakh <varakh@varakh.de>
2024-04-28 22:27:34 +02:00

108 lines
2.3 KiB
Go

package api
// UpdateState state of an update
type UpdateState string
const (
UpdateStatePending UpdateState = "pending"
UpdateStateApproved UpdateState = "approved"
UpdateStateIgnored UpdateState = "ignored"
)
func (e *UpdateState) Scan(value interface{}) error {
*e = UpdateState(value.([]byte))
return nil
}
func (e UpdateState) Value() string {
return string(e)
}
// WebhookType type of webhook
type WebhookType string
const (
WebhookTypeGeneric WebhookType = "generic"
WebhookTypeDiun WebhookType = "diun"
)
func (e *WebhookType) Scan(value interface{}) error {
*e = WebhookType(value.([]byte))
return nil
}
func (e WebhookType) Value() string {
return string(e)
}
// EventName name of event
type EventName string
const (
EventNameUpdateCreated EventName = "update_created"
EventNameUpdateUpdated EventName = "update_updated"
EventNameUpdateUpdatedState EventName = "update_updated_state"
EventNameUpdateDeleted EventName = "update_deleted"
)
func (e *EventName) Scan(value interface{}) error {
*e = EventName(value.([]byte))
return nil
}
func (e EventName) Value() string {
return string(e)
}
// EventState name of event
type EventState string
const (
EventStateCreated EventState = "created"
EventStateEnqueued EventState = "enqueued"
)
func (e *EventState) Scan(value interface{}) error {
*e = EventState(value.([]byte))
return nil
}
func (e EventState) Value() string {
return string(e)
}
// ActionType state of an update
type ActionType string
const (
ActionTypeShoutrrr ActionType = "shoutrrr"
)
func (e *ActionType) Scan(value interface{}) error {
*e = ActionType(value.([]byte))
return nil
}
func (e ActionType) Value() string {
return string(e)
}
// ActionInvocationState state of an action invocation
type ActionInvocationState string
const (
ActionInvocationStateCreated ActionInvocationState = "created"
ActionInvocationStateRunning ActionInvocationState = "running"
ActionInvocationStateRetrying ActionInvocationState = "retrying"
ActionInvocationStateSuccess ActionInvocationState = "success"
ActionInvocationStateError ActionInvocationState = "error"
)
func (e *ActionInvocationState) Scan(value interface{}) error {
*e = ActionInvocationState(value.([]byte))
return nil
}
func (e ActionInvocationState) Value() string {
return string(e)
}