model

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: ISC Imports: 4 Imported by: 0

Documentation

Overview

Package model contains structs used in the PushBits API and across the application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertmanagerAlert added in v0.9.0

type AlertmanagerAlert struct {
	Labels      map[string]string `json:"labels"`
	Annotations map[string]string `json:"annotations"`
	StartsAt    string            `json:"startsAt"`
	EndsAt      string            `json:"endsAt"`
	Status      string            `json:"status"`
}

AlertmanagerAlert holds information related to a single alert in a notification.

func (*AlertmanagerAlert) ToNotification added in v0.9.0

func (alert *AlertmanagerAlert) ToNotification(titleAnnotation, messageAnnotation string) Notification

ToNotification converts an Alertmanager alert into a Notification

type AlertmanagerWebhook added in v0.9.0

type AlertmanagerWebhook struct {
	Version           string              `json:"version"`
	GroupKey          string              `json:"groupKey"`
	Receiver          string              `json:"receiver"`
	GroupLabels       map[string]string   `json:"groupLabels"`
	CommonLabels      map[string]string   `json:"commonLabels"`
	CommonAnnotations map[string]string   `json:"commonAnnotations"`
	ExternalURL       string              `json:"externalURL"`
	Alerts            []AlertmanagerAlert `json:"alerts"`
}

AlertmanagerWebhook is used to pass notifications over webhook pushes.

type Application

type Application struct {
	ID       uint   `gorm:"AUTO_INCREMENT;primary_key" json:"id"`
	Token    string `gorm:"type:string;size:64;unique" json:"token"`
	UserID   uint   `json:"-"`
	Name     string `gorm:"type:string" json:"name"`
	MatrixID string `gorm:"type:string" json:"-"`
}

Application holds information like the name, the token, and the associated user of an application.

type CreateApplication

type CreateApplication struct {
	Name                string `form:"name" query:"name" json:"name" binding:"required"`
	StrictCompatibility bool   `form:"strict_compatibility" query:"strict_compatibility" json:"strict_compatibility"`
}

CreateApplication is used to process queries for creating applications.

type CreateUser

type CreateUser struct {
	ExternalUser
	UserCredentials
}

CreateUser is used to process queries for creating users.

func (*CreateUser) IntoInternalUser

func (u *CreateUser) IntoInternalUser(cm *credentials.Manager) (*User, error)

IntoInternalUser converts a CreateUser into a User.

type DeleteNotification

type DeleteNotification struct {
	ID   string    `json:"id" form:"id"`
	Date time.Time `json:"date"`
}

DeleteNotification holds information like the message ID of a deletion notification.

type ExternalUser

type ExternalUser struct {
	ID       uint   `json:"id"`
	Name     string `json:"name" form:"name" query:"name" binding:"required"`
	IsAdmin  bool   `json:"is_admin" form:"is_admin" query:"is_admin"`
	MatrixID string `json:"matrix_id" form:"matrix_id" query:"matrix_id" binding:"required"`
}

ExternalUser represents a user for external purposes.

type Notification

type Notification struct {
	ID            string                 `json:"id"`
	URLEncodedID  string                 `json:"id_url_encoded"`
	ApplicationID uint                   `json:"appid"`
	Message       string                 `json:"message" form:"message" query:"message" binding:"required"`
	Title         string                 `json:"title" form:"title" query:"title"`
	Priority      int                    `json:"priority" form:"priority" query:"priority"`
	Extras        map[string]interface{} `json:"extras,omitempty" form:"-" query:"-"`
	Date          time.Time              `json:"date"`
}

Notification holds information like the message, the title, and the priority of a notification.

func (*Notification) Sanitize added in v0.8.0

func (n *Notification) Sanitize(application *Application)

Sanitize sets explicit defaults for a notification.

type NotificationExtras added in v0.8.0

type NotificationExtras map[string]interface{}

NotificationExtras is need to document Notification.Extras in a format that the tool can read.

type UpdateApplication

type UpdateApplication struct {
	Name                *string `form:"new_name" query:"new_name" json:"new_name"`
	RefreshToken        *bool   `form:"refresh_token" query:"refresh_token" json:"refresh_token"`
	StrictCompatibility *bool   `form:"strict_compatibility" query:"strict_compatibility" json:"strict_compatibility"`
}

UpdateApplication is used to process queries for updating applications.

type UpdateUser

type UpdateUser struct {
	Name     *string `form:"name" query:"name" json:"name"`
	Password *string `form:"password" query:"password" json:"password"`
	IsAdmin  *bool   `form:"is_admin" query:"is_admin" json:"is_admin"`
	MatrixID *string `form:"matrix_id" query:"matrix_id" json:"matrix_id"`
}

UpdateUser is used to process queries for updating users.

type User

type User struct {
	ID           uint   `gorm:"AUTO_INCREMENT;primary_key"`
	Name         string `gorm:"type:string;size:128;unique"`
	PasswordHash []byte
	IsAdmin      bool
	MatrixID     string `gorm:"type:string"`
	Applications []Application
}

User holds information like the name, the secret, and the applications of a user.

func NewUser

func NewUser(cm *credentials.Manager, name, password string, isAdmin bool, matrixID string) (*User, error)

NewUser creates a new user.

func (*User) IntoExternalUser

func (u *User) IntoExternalUser() *ExternalUser

IntoExternalUser converts a User into a ExternalUser.

type UserCredentials

type UserCredentials struct {
	Password string `json:"password,omitempty" form:"password" query:"password" binding:"required"`
}

UserCredentials holds information for authenticating a user.

Jump to

Keyboard shortcuts

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