model

package module
v0.0.0-...-2bb7d6a Latest Latest
Warning

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

Go to latest
Published: May 2, 2021 License: MIT Imports: 7 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// DefaultRetain is a default value for Project.Retain
	DefaultRetain = 10
	// DefaultPeriod is a default value for Project.Period
	DefaultPeriod = (24 + 8) * 3600 // 1d 8h
)

Variables

This section is empty.

Functions

func NewError

func NewError(code ECode, format string, a ...interface{}) error

NewError creates new error object

Types

type AccessKey

type AccessKey struct {
	ID        int    `json:"id"`
	Label     string `json:"label"`
	Key       string `json:"key"`
	ProjectID string `json:"-"`
}

AccessKey contains information about project's access key

func (AccessKey) String

func (p AccessKey) String() string

String converts an object to string

type AccessKeyCreateParams

type AccessKeyCreateParams struct {
	Label string `json:"label"`
}

AccessKeyCreateParams contains parameters for access key creation

func (*AccessKeyCreateParams) Normalize

func (p *AccessKeyCreateParams) Normalize()

Normalize normalizes request's fields

func (AccessKeyCreateParams) String

func (p AccessKeyCreateParams) String() string

String converts an object to string

type AccessKeys

type AccessKeys []*AccessKey

AccessKeys is a list of AccessKey

type AuthRequest

type AuthRequest struct {
	Username string `json:"username" binding:"required"`
	Password string `json:"password" binding:"required"`
}

AuthRequest contains parameters for authentication

func (AuthRequest) String

func (p AuthRequest) String() string

String converts an object to string

type AuthResponse

type AuthResponse struct {
	Token string `json:"token"`
	User  *User  `json:"user"`
}

AuthResponse contains a generated access token

func (AuthResponse) String

func (p AuthResponse) String() string

String converts an object to string

type Backup

type Backup struct {
	ID              string     `json:"id"`
	FileName        string     `json:"filename"`
	Time            time.Time  `json:"time"`
	Type            BackupType `json:"type"`
	StorageFilePath string     `json:"-"`
	ProjectID       string     `json:"-"`
	Length          int64      `json:"length"`
}

Backup contains information about project's backup

func (Backup) String

func (p Backup) String() string

String converts an object to string

type BackupStatus

type BackupStatus string

BackupStatus represent backup status for a project

const (
	// BackupStatusOk means than project backup exists and is up to date
	BackupStatusOk BackupStatus = "ok"

	// BackupStatusNone means than project backup doesn't exist
	BackupStatusNone BackupStatus = "none"

	// BackupStatusOutdated means than project backup exists but is out of date
	BackupStatusOutdated BackupStatus = "outdated"
)

type BackupType

type BackupType string

BackupType is a type of backup - last or archive

const (
	// BackupTypeLast means last backup for a project
	BackupTypeLast BackupType = "last"

	// BackupTypeArchive means non-last backup for a project
	BackupTypeArchive BackupType = "archive"
)

type Backups

type Backups []*Backup

Backups is a list of Backup

type ECode

type ECode string

ECode is a error code (coarse-grained)

const (
	// EBadRequest is an error code for malformed arguments
	EBadRequest ECode = "bad_request"

	// ENotFound is an error code for a non-existing entity
	ENotFound ECode = "not_found"

	// EConflict is an error code for a conflicting entity
	EConflict ECode = "conflict"

	// EInternalError is an error code for an unexpected internal error
	EInternalError ECode = "internal_error"

	// EAccessDenied is an error code for an access error
	EAccessDenied ECode = "access_denied"
)

type Empty

type Empty struct {
}

Empty is an empty JSON object

type EmptyResponse

type EmptyResponse struct{}

EmptyResponse is an empty API response object

type Error

type Error struct {
	Code    ECode  `json:"error"`
	Message string `json:"message"`
}

Error is a service error object

func (*Error) Error

func (e *Error) Error() string

Error implements error interface

func (*Error) String

func (e *Error) String() string

String converts object to a string

type NotificationParams

type NotificationParams struct {
	Enabled       bool     `json:"enabled"`
	SlackUsers    []string `json:"slack"`
	TelegramUsers []string `json:"telegram"`
	Webhooks      []string `json:"webhook"`
}

NotificationParams contains list of targets to send notifications to

func (*NotificationParams) ApplyTo

func (p *NotificationParams) ApplyTo(proj *NotificationParams)

ApplyTo applies request values to a NotificationParams

func (*NotificationParams) String

func (p *NotificationParams) String() string

String converts an object to string

type Project

type Project struct {
	ID               string              `json:"id"`
	Name             string              `json:"name"`
	IsActive         bool                `json:"isActive"`
	BackupRetention  int                 `json:"backupRetention"`
	BackupFrequency  int                 `json:"backupFrequency"`
	Notifications    *NotificationParams `json:"notifications"`
	BackupStatus     BackupStatus        `json:"backupStatus"`
	LastBackup       *Backup             `json:"lastBackup"`
	LastNotification *time.Time          `json:"-"`
}

Project contains information about project

func (*Project) CalcBackupStatus

func (p *Project) CalcBackupStatus(lastBackup *Backup) BackupStatus

CalcBackupStatus evaluates project's backup status

func (*Project) String

func (p *Project) String() string

String converts an object to string

type ProjectCreateParams

type ProjectCreateParams struct {
	ID              string              `json:"id" binding:"required"`
	Name            string              `json:"name" binding:"required"`
	BackupRetention *int                `json:"backupRetention"`
	BackupFrequency *int                `json:"backupFrequency"`
	Enable          *bool               `json:"isActive"`
	Notifications   *NotificationParams `json:"notifications"`
	Webhooks        *[]string           `json:"webhook"`
}

ProjectCreateParams contains parameters for project creation

func (*ProjectCreateParams) ApplyTo

func (p *ProjectCreateParams) ApplyTo(proj *Project)

ApplyTo applies request values to a Project

func (*ProjectCreateParams) Normalize

func (p *ProjectCreateParams) Normalize()

Normalize normalizes request's fields

func (*ProjectCreateParams) String

func (p *ProjectCreateParams) String() string

String converts an object to string

func (*ProjectCreateParams) Validate

func (p *ProjectCreateParams) Validate() error

Validate validates request's fields

type ProjectUpdateParams

type ProjectUpdateParams struct {
	Name             *string             `json:"name"`
	BackupRetention  *int                `json:"backupRetention"`
	BackupFrequency  *int                `json:"backupFrequency"`
	IsActive         *bool               `json:"isActive"`
	Notifications    *NotificationParams `json:"notifications"`
	LastNotification *time.Time          `json:"-"`
}

ProjectUpdateParams contains parameters for project modification

func (*ProjectUpdateParams) ApplyTo

func (p *ProjectUpdateParams) ApplyTo(proj *Project)

ApplyTo applies request values to a Project

func (*ProjectUpdateParams) Normalize

func (p *ProjectUpdateParams) Normalize()

Normalize normalizes request's fields

func (*ProjectUpdateParams) String

func (p *ProjectUpdateParams) String() string

String converts an object to string

func (*ProjectUpdateParams) Validate

func (p *ProjectUpdateParams) Validate() error

Validate validates request's fields

type Projects

type Projects []*Project

Projects is a list of Project

type TestSlackNotificationRequest

type TestSlackNotificationRequest struct {
	Target string `json:"target"`
}

TestSlackNotificationRequest contains parameters to send test Slack notification

func (*TestSlackNotificationRequest) String

String converts an object to string

func (*TestSlackNotificationRequest) ToMessage

ToMessage converts request values to a SlackMessage

type TestTelegramNotificationRequest

type TestTelegramNotificationRequest struct {
	Target string `json:"target"`
}

TestTelegramNotificationRequest contains parameters to send test Telegram notification

func (*TestTelegramNotificationRequest) String

String converts an object to string

func (*TestTelegramNotificationRequest) ToMessage

ToMessage converts request values to a TelegramMessage

type TestWebhookNotificationPayload

type TestWebhookNotificationPayload struct {
	Test    bool   `json:"test"`
	Message string `json:"message"`
}

TestWebhookNotificationPayload is a JSON payload for Webhook notification tests

type TestWebhookNotificationRequest

type TestWebhookNotificationRequest struct {
	Target string `json:"target"`
}

TestWebhookNotificationRequest contains parameters to send test Webhook notification

func (*TestWebhookNotificationRequest) String

String converts an object to string

func (*TestWebhookNotificationRequest) ToMessage

ToMessage converts request values to a WebhookMessage

type User

type User struct {
	ID           int    `json:"id"`
	UserName     string `json:"username"`
	PasswordHash string `json:"-"`
}

User contains information about application user

func (*User) CheckPassword

func (p *User) CheckPassword(password string) bool

CheckPassword checks user's password

func (*User) SetPassword

func (p *User) SetPassword(password string) error

SetPassword sets user's password

func (*User) String

func (p *User) String() string

String converts an object to string

type UserChangePasswordRequest

type UserChangePasswordRequest struct {
	OldPassword string `json:"oldPassword"`
	NewPassword string `json:"newPassword"`
}

UserChangePasswordRequest contains parameters to change user's password

func (*UserChangePasswordRequest) String

func (p *UserChangePasswordRequest) String() string

String converts an object to string

type Users

type Users []*User

Users is a list of User

Jump to

Keyboard shortcuts

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