Documentation ¶
Index ¶
- Constants
- func NewError(code ECode, format string, a ...interface{}) error
- type AccessKey
- type AccessKeyCreateParams
- type AccessKeys
- type AuthRequest
- type AuthResponse
- type Backup
- type BackupStatus
- type BackupType
- type Backups
- type ECode
- type Empty
- type EmptyResponse
- type Error
- type NotificationParams
- type Project
- type ProjectCreateParams
- type ProjectUpdateParams
- type Projects
- type TestSlackNotificationRequest
- type TestTelegramNotificationRequest
- type TestWebhookNotificationPayload
- type TestWebhookNotificationRequest
- type User
- type UserChangePasswordRequest
- type Users
Constants ¶
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 ¶
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
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 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 ¶
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
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 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 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
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 TestSlackNotificationRequest ¶
type TestSlackNotificationRequest struct {
Target string `json:"target"`
}
TestSlackNotificationRequest contains parameters to send test Slack notification
func (*TestSlackNotificationRequest) String ¶
func (p *TestSlackNotificationRequest) String() string
String converts an object to string
func (*TestSlackNotificationRequest) ToMessage ¶
func (p *TestSlackNotificationRequest) ToMessage() *notify.SlackMessage
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 ¶
func (p *TestTelegramNotificationRequest) String() string
String converts an object to string
func (*TestTelegramNotificationRequest) ToMessage ¶
func (p *TestTelegramNotificationRequest) ToMessage() *notify.TelegramMessage
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 ¶
func (p *TestWebhookNotificationRequest) String() string
String converts an object to string
func (*TestWebhookNotificationRequest) ToMessage ¶
func (p *TestWebhookNotificationRequest) ToMessage() *notify.WebhookMessage
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 ¶
CheckPassword checks user's password
func (*User) SetPassword ¶
SetPassword sets user's password
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