Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateAPIKey() (string, error)
- func HashAPIKey(key string) string
- type APIKey
- type APIKeyStore
- func (s *APIKeyStore) Create(ctx context.Context, name string) (string, *APIKey, error)
- func (s *APIKeyStore) Delete(ctx context.Context, id int) error
- func (s *APIKeyStore) GetByHash(ctx context.Context, keyHash string) (*APIKey, error)
- func (s *APIKeyStore) List(ctx context.Context) ([]*APIKey, error)
- func (s *APIKeyStore) UpdateLastUsed(ctx context.Context, id int) error
- func (s *APIKeyStore) ValidateAPIKey(ctx context.Context, rawKey string) (*APIKey, error)
- type BackupItem
- type BackupRun
- type BackupRunKind
- type BackupRunStatus
- type BackupSettings
- type BackupStore
- func (s *BackupStore) CleanupRun(ctx context.Context, runID int64) error
- func (s *BackupStore) CountBlobReferences(ctx context.Context, relPath string) (int, error)
- func (s *BackupStore) CountRunsByKind(ctx context.Context, instanceID int, kind BackupRunKind) (int, error)
- func (s *BackupStore) CreateRun(ctx context.Context, run *BackupRun) error
- func (s *BackupStore) DeleteItemsByRunIDs(ctx context.Context, runIDs []int64) error
- func (s *BackupStore) DeleteRun(ctx context.Context, runID int64) error
- func (s *BackupStore) DeleteRunsByIDs(ctx context.Context, runIDs []int64) error
- func (s *BackupStore) DeleteRunsOlderThan(ctx context.Context, instanceID int, kind BackupRunKind, keep int) ([]int64, error)
- func (s *BackupStore) FindCachedTorrentBlob(ctx context.Context, instanceID int, hash string) (*string, error)
- func (s *BackupStore) FindIncompleteRuns(ctx context.Context) ([]*BackupRun, error)
- func (s *BackupStore) GetInstanceName(ctx context.Context, instanceID int) (string, error)
- func (s *BackupStore) GetItemByHash(ctx context.Context, runID int64, hash string) (*BackupItem, error)
- func (s *BackupStore) GetRun(ctx context.Context, runID int64) (*BackupRun, error)
- func (s *BackupStore) GetSettings(ctx context.Context, instanceID int) (*BackupSettings, error)
- func (s *BackupStore) InsertItems(ctx context.Context, runID int64, items []BackupItem) error
- func (s *BackupStore) LatestRunByKind(ctx context.Context, instanceID int, kind BackupRunKind) (*BackupRun, error)
- func (s *BackupStore) ListEnabledSettings(ctx context.Context) ([]*BackupSettings, error)
- func (s *BackupStore) ListItems(ctx context.Context, runID int64) ([]*BackupItem, error)
- func (s *BackupStore) ListRunIDs(ctx context.Context, instanceID int) ([]int64, error)
- func (s *BackupStore) ListRuns(ctx context.Context, instanceID int, limit, offset int) ([]*BackupRun, error)
- func (s *BackupStore) ListRunsByKind(ctx context.Context, instanceID int, kind BackupRunKind, limit int) ([]*BackupRun, error)
- func (s *BackupStore) RemoveFailedRunsBefore(ctx context.Context, cutoff time.Time) (int64, error)
- func (s *BackupStore) UpdateRunMetadata(ctx context.Context, runID int64, updateFn func(*BackupRun) error) error
- func (s *BackupStore) UpsertSettings(ctx context.Context, settings *BackupSettings) error
- type CategorySnapshot
- type ClientAPIKey
- type ClientAPIKeyStore
- func (s *ClientAPIKeyStore) Create(ctx context.Context, clientName string, instanceID int) (string, *ClientAPIKey, error)
- func (s *ClientAPIKeyStore) Delete(ctx context.Context, id int) error
- func (s *ClientAPIKeyStore) DeleteByInstanceID(ctx context.Context, instanceID int) error
- func (s *ClientAPIKeyStore) GetAll(ctx context.Context) ([]*ClientAPIKey, error)
- func (s *ClientAPIKeyStore) GetByKeyHash(ctx context.Context, keyHash string) (*ClientAPIKey, error)
- func (s *ClientAPIKeyStore) UpdateLastUsed(ctx context.Context, keyHash string) error
- func (s *ClientAPIKeyStore) ValidateKey(ctx context.Context, rawKey string) (*ClientAPIKey, error)
- type Instance
- type InstanceError
- type InstanceErrorStore
- type InstanceStore
- func (s *InstanceStore) Create(ctx context.Context, name, rawHost, username, password string, ...) (*Instance, error)
- func (s *InstanceStore) Delete(ctx context.Context, id int) error
- func (s *InstanceStore) Get(ctx context.Context, id int) (*Instance, error)
- func (s *InstanceStore) GetDecryptedBasicPassword(instance *Instance) (*string, error)
- func (s *InstanceStore) GetDecryptedPassword(instance *Instance) (string, error)
- func (s *InstanceStore) List(ctx context.Context) ([]*Instance, error)
- func (s *InstanceStore) Update(ctx context.Context, id int, name, rawHost, username, password string, ...) (*Instance, error)
- type LicenseInfo
- type ProductLicense
- type User
- type UserStore
- func (s *UserStore) Create(ctx context.Context, username, passwordHash string) (*User, error)
- func (s *UserStore) Exists(ctx context.Context) (bool, error)
- func (s *UserStore) Get(ctx context.Context) (*User, error)
- func (s *UserStore) GetByUsername(ctx context.Context, username string) (*User, error)
- func (s *UserStore) UpdatePassword(ctx context.Context, passwordHash string) error
Constants ¶
const ( ErrorTypeConnection = "connection" ErrorTypeAuthentication = "authentication" ErrorTypeBan = "ban" ErrorTypeAPI = "api" )
Error types for categorization
const ( LicenseStatusActive = "active" LicenseStatusInvalid = "invalid" )
LicenseStatus constants
Variables ¶
var ErrAPIKeyNotFound = errors.New("api key not found")
var ErrClientAPIKeyNotFound = errors.New("client api key not found")
var ErrInstanceNotFound = errors.New("instance not found")
var ErrInvalidAPIKey = errors.New("invalid api key")
var (
ErrLicenseNotFound = errors.New("license not found")
)
var ErrUserAlreadyExists = errors.New("user already exists")
var ErrUserNotFound = errors.New("user not found")
Functions ¶
func HashAPIKey ¶
HashAPIKey creates a SHA256 hash of the API key
Types ¶
type APIKeyStore ¶
type APIKeyStore struct {
// contains filtered or unexported fields
}
func NewAPIKeyStore ¶
func NewAPIKeyStore(db dbinterface.Querier) *APIKeyStore
func (*APIKeyStore) UpdateLastUsed ¶
func (s *APIKeyStore) UpdateLastUsed(ctx context.Context, id int) error
func (*APIKeyStore) ValidateAPIKey ¶
ValidateAPIKey validates a raw API key and returns the associated APIKey if valid
type BackupItem ¶ added in v1.5.0
type BackupItem struct {
ID int64 `json:"id"`
RunID int64 `json:"runId"`
TorrentHash string `json:"torrentHash"`
Name string `json:"name"`
Category *string `json:"category,omitempty"`
SizeBytes int64 `json:"sizeBytes"`
ArchiveRelPath *string `json:"archiveRelPath,omitempty"`
InfoHashV1 *string `json:"infohashV1,omitempty"`
InfoHashV2 *string `json:"infohashV2,omitempty"`
Tags *string `json:"tags,omitempty"`
TorrentBlobPath *string `json:"torrentBlobPath,omitempty"`
CreatedAt time.Time `json:"createdAt"`
}
type BackupRun ¶ added in v1.5.0
type BackupRun struct {
ID int64 `json:"id"`
InstanceID int `json:"instanceId"`
Kind BackupRunKind `json:"kind"`
Status BackupRunStatus `json:"status"`
RequestedBy string `json:"requestedBy"`
RequestedAt time.Time `json:"requestedAt"`
StartedAt *time.Time `json:"startedAt,omitempty"`
CompletedAt *time.Time `json:"completedAt,omitempty"`
ArchivePath *string `json:"archivePath,omitempty"`
ManifestPath *string `json:"manifestPath,omitempty"`
TotalBytes int64 `json:"totalBytes"`
TorrentCount int `json:"torrentCount"`
CategoryCounts map[string]int `json:"categoryCounts,omitempty"`
ErrorMessage *string `json:"errorMessage,omitempty"`
Categories map[string]CategorySnapshot `json:"categories,omitempty"`
Tags []string `json:"tags,omitempty"`
// contains filtered or unexported fields
}
type BackupRunKind ¶ added in v1.5.0
type BackupRunKind string
const ( BackupRunKindManual BackupRunKind = "manual" BackupRunKindHourly BackupRunKind = "hourly" BackupRunKindDaily BackupRunKind = "daily" BackupRunKindWeekly BackupRunKind = "weekly" BackupRunKindMonthly BackupRunKind = "monthly" )
type BackupRunStatus ¶ added in v1.5.0
type BackupRunStatus string
const ( BackupRunStatusPending BackupRunStatus = "pending" BackupRunStatusRunning BackupRunStatus = "running" BackupRunStatusSuccess BackupRunStatus = "success" BackupRunStatusFailed BackupRunStatus = "failed" BackupRunStatusCanceled BackupRunStatus = "canceled" )
type BackupSettings ¶ added in v1.5.0
type BackupSettings struct {
InstanceID int `json:"instanceId"`
Enabled bool `json:"enabled"`
HourlyEnabled bool `json:"hourlyEnabled"`
DailyEnabled bool `json:"dailyEnabled"`
WeeklyEnabled bool `json:"weeklyEnabled"`
MonthlyEnabled bool `json:"monthlyEnabled"`
KeepHourly int `json:"keepHourly"`
KeepDaily int `json:"keepDaily"`
KeepWeekly int `json:"keepWeekly"`
KeepMonthly int `json:"keepMonthly"`
IncludeCategories bool `json:"includeCategories"`
IncludeTags bool `json:"includeTags"`
CustomPath *string `json:"customPath,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func DefaultBackupSettings ¶ added in v1.5.0
func DefaultBackupSettings(instanceID int) *BackupSettings
type BackupStore ¶ added in v1.5.0
type BackupStore struct {
// contains filtered or unexported fields
}
func NewBackupStore ¶ added in v1.5.0
func NewBackupStore(db dbinterface.TxBeginner) *BackupStore
func (*BackupStore) CleanupRun ¶ added in v1.5.0
func (s *BackupStore) CleanupRun(ctx context.Context, runID int64) error
func (*BackupStore) CountBlobReferences ¶ added in v1.5.0
func (*BackupStore) CountRunsByKind ¶ added in v1.5.0
func (s *BackupStore) CountRunsByKind(ctx context.Context, instanceID int, kind BackupRunKind) (int, error)
func (*BackupStore) CreateRun ¶ added in v1.5.0
func (s *BackupStore) CreateRun(ctx context.Context, run *BackupRun) error
func (*BackupStore) DeleteItemsByRunIDs ¶ added in v1.5.0
func (s *BackupStore) DeleteItemsByRunIDs(ctx context.Context, runIDs []int64) error
func (*BackupStore) DeleteRun ¶ added in v1.5.0
func (s *BackupStore) DeleteRun(ctx context.Context, runID int64) error
func (*BackupStore) DeleteRunsByIDs ¶ added in v1.5.0
func (s *BackupStore) DeleteRunsByIDs(ctx context.Context, runIDs []int64) error
func (*BackupStore) DeleteRunsOlderThan ¶ added in v1.5.0
func (s *BackupStore) DeleteRunsOlderThan(ctx context.Context, instanceID int, kind BackupRunKind, keep int) ([]int64, error)
func (*BackupStore) FindCachedTorrentBlob ¶ added in v1.5.0
func (*BackupStore) FindIncompleteRuns ¶ added in v1.6.0
func (s *BackupStore) FindIncompleteRuns(ctx context.Context) ([]*BackupRun, error)
FindIncompleteRuns returns all backup runs that are in pending or running status. These are runs that were interrupted by a restart or crash.
func (*BackupStore) GetInstanceName ¶ added in v1.5.0
func (*BackupStore) GetItemByHash ¶ added in v1.5.0
func (s *BackupStore) GetItemByHash(ctx context.Context, runID int64, hash string) (*BackupItem, error)
func (*BackupStore) GetSettings ¶ added in v1.5.0
func (s *BackupStore) GetSettings(ctx context.Context, instanceID int) (*BackupSettings, error)
func (*BackupStore) InsertItems ¶ added in v1.5.0
func (s *BackupStore) InsertItems(ctx context.Context, runID int64, items []BackupItem) error
func (*BackupStore) LatestRunByKind ¶ added in v1.5.0
func (s *BackupStore) LatestRunByKind(ctx context.Context, instanceID int, kind BackupRunKind) (*BackupRun, error)
func (*BackupStore) ListEnabledSettings ¶ added in v1.5.0
func (s *BackupStore) ListEnabledSettings(ctx context.Context) ([]*BackupSettings, error)
func (*BackupStore) ListItems ¶ added in v1.5.0
func (s *BackupStore) ListItems(ctx context.Context, runID int64) ([]*BackupItem, error)
func (*BackupStore) ListRunIDs ¶ added in v1.5.0
func (*BackupStore) ListRunsByKind ¶ added in v1.5.0
func (s *BackupStore) ListRunsByKind(ctx context.Context, instanceID int, kind BackupRunKind, limit int) ([]*BackupRun, error)
func (*BackupStore) RemoveFailedRunsBefore ¶ added in v1.5.0
RemoveFailedRunsBefore deletes failed runs older than the provided cutoff and returns the number of rows affected.
func (*BackupStore) UpdateRunMetadata ¶ added in v1.5.0
func (*BackupStore) UpsertSettings ¶ added in v1.5.0
func (s *BackupStore) UpsertSettings(ctx context.Context, settings *BackupSettings) error
type CategorySnapshot ¶ added in v1.5.0
type CategorySnapshot struct {
SavePath string `json:"savePath,omitempty"`
}
type ClientAPIKey ¶ added in v1.0.0
type ClientAPIKeyStore ¶ added in v1.0.0
type ClientAPIKeyStore struct {
// contains filtered or unexported fields
}
func NewClientAPIKeyStore ¶ added in v1.0.0
func NewClientAPIKeyStore(db dbinterface.Querier) *ClientAPIKeyStore
func (*ClientAPIKeyStore) Create ¶ added in v1.0.0
func (s *ClientAPIKeyStore) Create(ctx context.Context, clientName string, instanceID int) (string, *ClientAPIKey, error)
func (*ClientAPIKeyStore) Delete ¶ added in v1.0.0
func (s *ClientAPIKeyStore) Delete(ctx context.Context, id int) error
func (*ClientAPIKeyStore) DeleteByInstanceID ¶ added in v1.0.0
func (s *ClientAPIKeyStore) DeleteByInstanceID(ctx context.Context, instanceID int) error
func (*ClientAPIKeyStore) GetAll ¶ added in v1.0.0
func (s *ClientAPIKeyStore) GetAll(ctx context.Context) ([]*ClientAPIKey, error)
func (*ClientAPIKeyStore) GetByKeyHash ¶ added in v1.0.0
func (s *ClientAPIKeyStore) GetByKeyHash(ctx context.Context, keyHash string) (*ClientAPIKey, error)
func (*ClientAPIKeyStore) UpdateLastUsed ¶ added in v1.0.0
func (s *ClientAPIKeyStore) UpdateLastUsed(ctx context.Context, keyHash string) error
func (*ClientAPIKeyStore) ValidateKey ¶ added in v1.0.0
func (s *ClientAPIKeyStore) ValidateKey(ctx context.Context, rawKey string) (*ClientAPIKey, error)
type Instance ¶
type Instance struct {
ID int `json:"id"`
Name string `json:"name"`
Host string `json:"host"`
Username string `json:"username"`
PasswordEncrypted string `json:"-"`
BasicUsername *string `json:"basic_username,omitempty"`
BasicPasswordEncrypted *string `json:"-"`
TLSSkipVerify bool `json:"tlsSkipVerify"`
}
func (Instance) MarshalJSON ¶ added in v1.0.0
func (*Instance) UnmarshalJSON ¶ added in v1.0.0
type InstanceError ¶ added in v1.0.0
type InstanceErrorStore ¶ added in v1.0.0
type InstanceErrorStore struct {
// contains filtered or unexported fields
}
func NewInstanceErrorStore ¶ added in v1.0.0
func NewInstanceErrorStore(db dbinterface.Querier) *InstanceErrorStore
func (*InstanceErrorStore) ClearErrors ¶ added in v1.0.0
func (s *InstanceErrorStore) ClearErrors(ctx context.Context, instanceID int) error
ClearErrors removes all errors for an instance (called on successful connection)
func (*InstanceErrorStore) GetRecentErrors ¶ added in v1.0.0
func (s *InstanceErrorStore) GetRecentErrors(ctx context.Context, instanceID int, limit int) ([]InstanceError, error)
GetRecentErrors retrieves the last N errors for an instance
func (*InstanceErrorStore) RecordError ¶ added in v1.0.0
RecordError stores an error for an instance with simple deduplication
type InstanceStore ¶
type InstanceStore struct {
// contains filtered or unexported fields
}
func NewInstanceStore ¶
func NewInstanceStore(db dbinterface.Querier, encryptionKey []byte) (*InstanceStore, error)
func (*InstanceStore) GetDecryptedBasicPassword ¶
func (s *InstanceStore) GetDecryptedBasicPassword(instance *Instance) (*string, error)
GetDecryptedBasicPassword returns the decrypted basic auth password for an instance
func (*InstanceStore) GetDecryptedPassword ¶
func (s *InstanceStore) GetDecryptedPassword(instance *Instance) (string, error)
GetDecryptedPassword returns the decrypted password for an instance
type LicenseInfo ¶ added in v1.0.0
type LicenseInfo struct {
Key string `json:"key"`
ProductName string `json:"productName"`
CustomerID string `json:"customerId"`
ProductID string `json:"productId"`
ExpiresAt *time.Time `json:"expiresAt,omitempty"`
Valid bool `json:"valid"`
ErrorMessage string `json:"errorMessage,omitempty"`
}
LicenseInfo contains license validation information
type ProductLicense ¶ added in v1.0.0
type ProductLicense struct {
ID int `json:"id"`
LicenseKey string `json:"licenseKey"`
ProductName string `json:"productName"`
Status string `json:"status"`
ActivatedAt time.Time `json:"activatedAt"`
ExpiresAt *time.Time `json:"expiresAt,omitempty"`
LastValidated time.Time `json:"lastValidated"`
PolarCustomerID *string `json:"polarCustomerId,omitempty"`
PolarProductID *string `json:"polarProductId,omitempty"`
PolarActivationID string `json:"polarActivationId,omitempty"`
Username string `json:"username"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
ProductLicense represents a product license in the database
type UserStore ¶
type UserStore struct {
// contains filtered or unexported fields
}
func NewUserStore ¶
func NewUserStore(db dbinterface.Querier) *UserStore