Documentation ¶
Index ¶
- Constants
- Variables
- func NewErrExists(format string, args ...interface{}) error
- func Pattern(glob string) string
- func ValidateEffectiveUnix(effective time.Time) int64
- type Agent
- type AgentFilter
- type Archive
- type ArchiveFilter
- type AuthToken
- type AuthTokenFilter
- type DB
- func (db *DB) AddUserToTenant(user, tenant, role string) error
- func (db *DB) Alias(name string, sql string) error
- func (db *DB) AnnotateTargetArchive(target uuid.UUID, id string, notes string) error
- func (db *DB) AnnotateTargetTask(target uuid.UUID, id string, ann *TaskAnnotation) error
- func (db *DB) ArchiveStorageFootprint(filter *ArchiveFilter) (int64, error)
- func (db *DB) CancelTask(id uuid.UUID, effective time.Time) error
- func (db *DB) CheckCurrentSchema() error
- func (db *DB) ClearAllSessions() error
- func (db *DB) ClearExpiredSessions(expiration_threshold time.Time) error
- func (db *DB) ClearMembershipsFor(user *User) error
- func (db *DB) ClearSession(id string) error
- func (db *DB) CompleteTask(id uuid.UUID, effective time.Time) error
- func (db *DB) Connect() error
- func (db *DB) Connected() bool
- func (db *DB) Copy() *DB
- func (db *DB) Count(sql_or_name string, args ...interface{}) (uint, error)
- func (db *DB) CountArchives(filter *ArchiveFilter) (int, error)
- func (db *DB) CountTargets(filter *TargetFilter) (int, error)
- func (db *DB) CreateBackupTask(owner string, job *Job) (*Task, error)
- func (db *DB) CreateJob(job *Job) (*Job, error)
- func (db *DB) CreatePurgeTask(owner string, archive *Archive, agent string) (*Task, error)
- func (db *DB) CreateRestoreTask(owner string, archive *Archive, target *Target) (*Task, error)
- func (db *DB) CreateRetentionPolicy(p *RetentionPolicy) (*RetentionPolicy, error)
- func (db *DB) CreateSession(session *Session) (*Session, error)
- func (db *DB) CreateStore(s *Store) (*Store, error)
- func (db *DB) CreateTarget(in *Target) (*Target, error)
- func (db *DB) CreateTaskArchive(id uuid.UUID, archive_id uuid.UUID, key string, effective time.Time, ...) (uuid.UUID, error)
- func (db *DB) CreateTenant(given_uuid string, given_name string) (*Tenant, error)
- func (db *DB) CreateTestStoreTask(owner string, store *Store) (*Task, error)
- func (db *DB) CreateUser(user *User) (*User, error)
- func (db *DB) DeleteArchive(id uuid.UUID) (bool, error)
- func (db *DB) DeleteAuthToken(id string, user *User) error
- func (db *DB) DeleteJob(id uuid.UUID) (bool, error)
- func (db *DB) DeleteRetentionPolicy(id uuid.UUID) (bool, error)
- func (db *DB) DeleteStore(id uuid.UUID) (bool, error)
- func (db *DB) DeleteTarget(id uuid.UUID) (bool, error)
- func (db *DB) DeleteTenant(tenant *Tenant) error
- func (db *DB) DeleteUser(user *User) error
- func (db *DB) Disconnect() error
- func (db *DB) EnsureTenant(name string) (*Tenant, error)
- func (db *DB) Exec(sql_or_name string, args ...interface{}) error
- func (db *DB) ExpireArchive(id uuid.UUID) error
- func (db *DB) FailTask(id uuid.UUID, effective time.Time) error
- func (db *DB) GenerateAuthToken(name string, user *User) (*AuthToken, string, error)
- func (db *DB) GetAgent(id uuid.UUID) (*Agent, error)
- func (db *DB) GetAgentPluginMetadata(addr, name string) (*plugin.PluginInfo, error)
- func (db *DB) GetAllAgents(filter *AgentFilter) ([]*Agent, error)
- func (db *DB) GetAllArchives(filter *ArchiveFilter) ([]*Archive, error)
- func (db *DB) GetAllAuthTokens(filter *AuthTokenFilter) ([]*AuthToken, error)
- func (db *DB) GetAllJobs(filter *JobFilter) ([]*Job, error)
- func (db *DB) GetAllRetentionPolicies(filter *RetentionFilter) ([]*RetentionPolicy, error)
- func (db *DB) GetAllSessions(filter *SessionFilter) ([]*Session, error)
- func (db *DB) GetAllStores(filter *StoreFilter) ([]*Store, error)
- func (db *DB) GetAllTargets(filter *TargetFilter) ([]*Target, error)
- func (db *DB) GetAllTasks(filter *TaskFilter) ([]*Task, error)
- func (db *DB) GetAllTenants(filter *TenantFilter) ([]*Tenant, error)
- func (db *DB) GetAllUsers(filter *UserFilter) ([]*User, error)
- func (db *DB) GetArchive(id uuid.UUID) (*Archive, error)
- func (db *DB) GetArchivesNeedingPurge() ([]*Archive, error)
- func (db *DB) GetAuthToken(id string) (*AuthToken, error)
- func (db *DB) GetExpiredArchives() ([]*Archive, error)
- func (db *DB) GetJob(id uuid.UUID) (*Job, error)
- func (db *DB) GetMembershipsForUser(user uuid.UUID) ([]*Membership, error)
- func (db *DB) GetRetentionPolicy(id uuid.UUID) (*RetentionPolicy, error)
- func (db *DB) GetSession(id string) (*Session, error)
- func (db *DB) GetStore(id uuid.UUID) (*Store, error)
- func (db *DB) GetTarget(id uuid.UUID) (*Target, error)
- func (db *DB) GetTask(id uuid.UUID) (*Task, error)
- func (db *DB) GetTenant(id string) (*Tenant, error)
- func (db *DB) GetTenantByName(name string) (*Tenant, error)
- func (db *DB) GetTenantRole(org string, team string) (uuid.UUID, string, error)
- func (db *DB) GetTenantsForUser(user uuid.UUID) ([]*Tenant, error)
- func (db *DB) GetUser(account string, backend string) (*User, error)
- func (db *DB) GetUserByID(id string) (*User, error)
- func (db *DB) GetUserForSession(id string) (*User, error)
- func (db *DB) GetUsersForTenant(tenant uuid.UUID) ([]*User, error)
- func (db *DB) InheritRetentionTemplates(tenant *Tenant) error
- func (db *DB) InvalidateArchive(id uuid.UUID) error
- func (db *DB) IsTaskRunnable(task *Task) (bool, error)
- func (db *DB) MarkTasksIrrelevant() error
- func (db *DB) PauseJob(id uuid.UUID) (bool, error)
- func (db *DB) PauseOrUnpauseJob(id uuid.UUID, pause bool) (bool, error)
- func (db *DB) PokeSession(session *Session) error
- func (db *DB) PreRegisterAgent(host, name string, port int) error
- func (db *DB) PurgeArchive(id uuid.UUID) error
- func (db *DB) Query(sql_or_name string, args ...interface{}) (*sql.Rows, error)
- func (db *DB) RemoveUserFromTenant(user, tenant string) error
- func (db *DB) RescheduleJob(j *Job, t time.Time) error
- func (db *DB) ScheduledTask(id uuid.UUID) error
- func (db *DB) SchemaVersion() (int, error)
- func (db *DB) Setup(want int) (int, error)
- func (db *DB) StartTask(id uuid.UUID, effective time.Time) error
- func (db *DB) UnpauseJob(id uuid.UUID) (bool, error)
- func (db *DB) UpdateAgent(agent *Agent) error
- func (db *DB) UpdateArchive(update *Archive) error
- func (db *DB) UpdateJob(job *Job) error
- func (db *DB) UpdateRetentionPolicy(p *RetentionPolicy) error
- func (db *DB) UpdateStore(s *Store) error
- func (db *DB) UpdateTarget(t *Target) error
- func (db *DB) UpdateTaskLog(id uuid.UUID, more string) error
- func (db *DB) UpdateTenant(t *Tenant) (*Tenant, error)
- func (db *DB) UpdateUser(user *User) error
- func (db *DB) UpdateUserSettings(user *User) error
- type ErrExists
- type Job
- type JobFilter
- type Membership
- type NullUUID
- type RetentionFilter
- type RetentionPolicy
- type Schema
- type Session
- type SessionFilter
- type Store
- type StoreConfigItem
- type StoreFilter
- type StoreStats
- type Target
- type TargetFilter
- type Task
- type TaskAnnotation
- type TaskFilter
- type TaskInfo
- type Tenant
- type TenantFilter
- type User
- type UserFilter
Constants ¶
View Source
const ( BackupOperation = "backup" RestoreOperation = "restore" PurgeOperation = "purge" TestStoreOperation = "test-store" PendingStatus = "pending" ScheduledStatus = "scheduled" RunningStatus = "running" CanceledStatus = "canceled" FailedStatus = "failed" DoneStatus = "done" )
View Source
const ( BcryptWorkFactor = 14 LocalBackend = `local` )
Variables ¶
View Source
var CurrentSchema int = currentSchema()
View Source
var Schemas = map[int]Schema{
1: v1Schema{},
2: v2Schema{},
3: v3Schema{},
4: v4Schema{},
}
Functions ¶
func NewErrExists ¶
NewErrExists makes a new ErrExists object... works a hell of a lot like fmt.Errorf
func ValidateEffectiveUnix ¶ added in v0.4.1
Types ¶
type Agent ¶
type Agent struct { UUID uuid.UUID `json:"uuid"` Name string `json:"name"` Address string `json:"address"` Version string `json:"version"` Hidden bool `json:"hidden"` LastSeenAt int64 `json:"last_seen_at"` LastError string `json:"last_error"` Status string `json:"status"` RawMeta string `json:"-"` }
type AgentFilter ¶
type AgentFilter struct { Address string Name string Status string OnlyHidden bool SkipHidden bool }
func (*AgentFilter) Query ¶
func (f *AgentFilter) Query() (string, []interface{})
type Archive ¶ added in v0.6.4
type Archive struct { UUID uuid.UUID `json:"uuid"` StoreKey string `json:"key"` TakenAt int64 `json:"taken_at"` ExpiresAt int64 `json:"expires_at"` Notes string `json:"notes"` Status string `json:"status"` PurgeReason string `json:"purge_reason"` TargetUUID uuid.UUID `json:"target_uuid"` TargetName string `json:"target_name"` TargetPlugin string `json:"target_plugin"` TargetEndpoint string `json:"target_endpoint"` StoreUUID uuid.UUID `json:"store_uuid"` StoreName string `json:"store_name"` StorePlugin string `json:"store_plugin"` StoreEndpoint string `json:"store_endpoint"` Job string `json:"job"` EncryptionType string `json:"encryption_type"` TenantUUID uuid.UUID `json:"tenant_uuid"` Size int64 `json:"size"` }
type ArchiveFilter ¶
type ArchiveFilter struct { ForTarget string ForStore string Before *time.Time After *time.Time ExpiresBefore *time.Time ExpiresAfter *time.Time WithStatus []string WithOutStatus []string ForTenant string Limit int }
func (*ArchiveFilter) Query ¶
func (f *ArchiveFilter) Query() (string, []interface{})
type AuthTokenFilter ¶
func (AuthTokenFilter) Query ¶
func (t AuthTokenFilter) Query() (string, []interface{})
type DB ¶
func (*DB) AddUserToTenant ¶
Manual close of sql transaction necessary to avoid database lockup due to defer
func (*DB) AnnotateTargetArchive ¶
func (*DB) AnnotateTargetTask ¶
func (*DB) ArchiveStorageFootprint ¶
func (db *DB) ArchiveStorageFootprint(filter *ArchiveFilter) (int64, error)
func (*DB) CheckCurrentSchema ¶
func (*DB) ClearAllSessions ¶
func (*DB) ClearExpiredSessions ¶
func (*DB) ClearMembershipsFor ¶
func (*DB) ClearSession ¶
func (*DB) CountArchives ¶
func (db *DB) CountArchives(filter *ArchiveFilter) (int, error)
func (*DB) CountTargets ¶
func (db *DB) CountTargets(filter *TargetFilter) (int, error)
func (*DB) CreatePurgeTask ¶
func (*DB) CreateRestoreTask ¶
func (*DB) CreateRetentionPolicy ¶
func (db *DB) CreateRetentionPolicy(p *RetentionPolicy) (*RetentionPolicy, error)
func (*DB) CreateTaskArchive ¶
func (*DB) CreateTenant ¶
func (*DB) CreateTestStoreTask ¶
func (*DB) DeleteTenant ¶
func (*DB) DeleteUser ¶
func (*DB) GenerateAuthToken ¶
func (*DB) GetAgentPluginMetadata ¶
func (db *DB) GetAgentPluginMetadata(addr, name string) (*plugin.PluginInfo, error)
func (*DB) GetAllAgents ¶
func (db *DB) GetAllAgents(filter *AgentFilter) ([]*Agent, error)
func (*DB) GetAllArchives ¶ added in v0.6.4
func (db *DB) GetAllArchives(filter *ArchiveFilter) ([]*Archive, error)
func (*DB) GetAllAuthTokens ¶
func (db *DB) GetAllAuthTokens(filter *AuthTokenFilter) ([]*AuthToken, error)
func (*DB) GetAllRetentionPolicies ¶ added in v0.6.4
func (db *DB) GetAllRetentionPolicies(filter *RetentionFilter) ([]*RetentionPolicy, error)
func (*DB) GetAllSessions ¶
func (db *DB) GetAllSessions(filter *SessionFilter) ([]*Session, error)
func (*DB) GetAllStores ¶ added in v0.6.4
func (db *DB) GetAllStores(filter *StoreFilter) ([]*Store, error)
func (*DB) GetAllTargets ¶ added in v0.6.4
func (db *DB) GetAllTargets(filter *TargetFilter) ([]*Target, error)
func (*DB) GetAllTasks ¶ added in v0.6.4
func (db *DB) GetAllTasks(filter *TaskFilter) ([]*Task, error)
func (*DB) GetAllTenants ¶
func (db *DB) GetAllTenants(filter *TenantFilter) ([]*Tenant, error)
func (*DB) GetAllUsers ¶
func (db *DB) GetAllUsers(filter *UserFilter) ([]*User, error)
func (*DB) GetArchivesNeedingPurge ¶
func (*DB) GetExpiredArchives ¶
func (*DB) GetMembershipsForUser ¶
func (db *DB) GetMembershipsForUser(user uuid.UUID) ([]*Membership, error)
func (*DB) GetRetentionPolicy ¶ added in v0.6.4
func (db *DB) GetRetentionPolicy(id uuid.UUID) (*RetentionPolicy, error)
func (*DB) GetTenantRole ¶
func (*DB) GetTenantsForUser ¶
GetTenantsForUser given a user's uuid returns a slice of Tenants that the user has membership with
func (*DB) InheritRetentionTemplates ¶
InheritRetentionTemplates gives a tenant the global (templated) retention policies
func (*DB) MarkTasksIrrelevant ¶
func (*DB) PauseOrUnpauseJob ¶
func (*DB) PokeSession ¶
func (*DB) RemoveUserFromTenant ¶
func (*DB) SchemaVersion ¶
func (*DB) UpdateAgent ¶
func (*DB) UpdateArchive ¶
func (*DB) UpdateRetentionPolicy ¶
func (db *DB) UpdateRetentionPolicy(p *RetentionPolicy) error
func (*DB) UpdateStore ¶
func (*DB) UpdateTarget ¶
func (*DB) UpdateUser ¶
func (*DB) UpdateUserSettings ¶
type ErrExists ¶
type ErrExists struct {
// contains filtered or unexported fields
}
ErrExists is the error that should be returned from a db function if an item could not be inserted because it already exists in the database
type Job ¶ added in v0.6.4
type Job struct { TenantUUID uuid.UUID `json:"-"` TargetUUID uuid.UUID `json:"-"` StoreUUID uuid.UUID `json:"-"` PolicyUUID uuid.UUID `json:"-"` UUID uuid.UUID `json:"uuid"` Name string `json:"name"` Summary string `json:"summary"` Expiry int `json:"expiry"` Schedule string `json:"schedule"` Paused bool `json:"paused"` FixedKey bool `json:"fixed_key"` Target struct { UUID uuid.UUID `json:"uuid"` Name string `json:"name"` Agent string `json:"agent"` Plugin string `json:"plugin"` Endpoint string `json:"endpoint,omitempty"` Config map[string]interface{} `json:"config,omitempty"` } Store struct { UUID uuid.UUID `json:"uuid"` Name string `json:"name"` Agent string `json:"agent"` Plugin string `json:"plugin"` Summary string `json:"summary"` Endpoint string `json:"endpoint,omitempty"` Config map[string]interface{} `json:"config,omitempty"` } `json:"store"` Policy struct { UUID uuid.UUID `json:"uuid"` Name string `json:"name"` Summary string `json:"summary"` } `json:"policy"` Agent string `json:"agent"` LastRun int64 `json:"last_run"` LastTaskStatus string `json:"last_task_status"` Spec *timespec.Spec `json:"-"` NextRun int64 `json:"-"` }
func (*Job) Reschedule ¶ added in v0.6.4
type JobFilter ¶
type RetentionFilter ¶
type RetentionFilter struct { ForTenant string SkipUsed bool SkipUnused bool SearchName string ExactMatch bool }
func (*RetentionFilter) Query ¶
func (f *RetentionFilter) Query() (string, []interface{})
type RetentionPolicy ¶ added in v0.6.4
type Session ¶
type Session struct { UUID uuid.UUID `json:"uuid"` UserUUID uuid.UUID `json:"user_uuid"` CreatedAt int64 `json:"created_at"` LastSeen int64 `json:"last_seen_at"` Token uuid.UUID `json:"token_uuid"` Name string `json:"name"` IP string `json:"ip_addr"` UserAgent string `json:"user_agent"` UserAccount string `json:"user_account"` CurrentSession bool `json:"current_session"` }
type SessionFilter ¶
type SessionFilter struct { Name string ExactMatch bool UUID string UserUUID string Limit int IP string IsToken bool }
func (*SessionFilter) Query ¶
func (f *SessionFilter) Query() (string, []interface{})
type Store ¶ added in v0.6.4
type Store struct { UUID uuid.UUID `json:"uuid"` Name string `json:"name"` Summary string `json:"summary"` Agent string `json:"agent"` Plugin string `json:"plugin"` Global bool `json:"global"` PublicConfig string `json:"-"` PrivateConfig string `json:"-"` Config map[string]interface{} `json:"config,omitempty"` DisplayConfig []StoreConfigItem `json:"display_config,omitempty"` TenantUUID uuid.UUID `json:"-"` DailyIncrease int64 `json:"daily_increase"` StorageUsed int64 `json:"storage_used"` Threshold int64 `json:"threshold"` ArchiveCount int `json:"archive_count"` Healthy bool `json:"healthy"` LastTestTaskUUID uuid.UUID `json:"last_test_task_uuid"` }
func (*Store) CacheConfigs ¶
func (Store) ConfigJSON ¶
func (*Store) DisplayPrivate ¶
func (*Store) DisplayPublic ¶
type StoreConfigItem ¶
type StoreFilter ¶
type StoreFilter struct { SkipUsed bool SkipUnused bool SearchName string ForPlugin string ForTenant string ExactMatch bool }
func (*StoreFilter) Query ¶
func (f *StoreFilter) Query() (string, []interface{})
type StoreStats ¶
type Target ¶ added in v0.6.4
type Target struct { TenantUUID uuid.UUID `json:"-"` UUID uuid.UUID `json:"uuid"` Name string `json:"name"` Summary string `json:"summary"` Plugin string `json:"plugin"` Agent string `json:"agent"` Config map[string]interface{} `json:"config,omitempty"` }
func (Target) ConfigJSON ¶
type TargetFilter ¶
type TargetFilter struct { SkipUsed bool SkipUnused bool SearchName string ForTenant string ForPlugin string ExactMatch bool }
func (*TargetFilter) Query ¶
func (f *TargetFilter) Query() (string, []interface{})
type Task ¶ added in v0.6.4
type Task struct { UUID uuid.UUID `json:"uuid"` TenantUUID uuid.UUID `json:"-"` Owner string `json:"owner"` Op string `json:"type"` JobUUID uuid.UUID `json:"job_uuid"` ArchiveUUID uuid.UUID `json:"archive_uuid"` StoreUUID uuid.UUID `json:"-"` StorePlugin string `json:"-"` StoreEndpoint string `json:"-"` TargetUUID uuid.UUID `json:"-"` TargetPlugin string `json:"-"` TargetEndpoint string `json:"-"` Status string `json:"status"` RequestedAt int64 `json:"requested_at"` StartedAt int64 `json:"started_at"` StoppedAt int64 `json:"stopped_at"` TimeoutAt int64 `json:"-"` Attempts int `json:"-"` RestoreKey string `json:"-"` FixedKey bool `json:"-"` Agent string `json:"-"` Log string `json:"log"` OK bool `json:"ok"` Notes string `json:"notes"` Clear string `json:"clear"` TaskUUIDChan chan *TaskInfo `json:"-"` }
type TaskAnnotation ¶
type TaskFilter ¶
type TaskFilter struct { UUID string SkipActive bool SkipInactive bool OnlyRelevant bool ForOp string ForTenant string ForTarget string ForStatus string ForArchive string Limit int }
func (*TaskFilter) Query ¶
func (f *TaskFilter) Query() (string, []interface{})
type TenantFilter ¶
func (*TenantFilter) Query ¶
func (f *TenantFilter) Query() (string, []interface{})
type User ¶
type User struct { UUID uuid.UUID `json:"uuid"` Name string `json:"name"` Account string `json:"account"` Backend string `json:"backend"` SysRole string `json:"sysrole"` Role string `json:"role,omitempty"` DefaultTenant string `json:"default_tenant"` // contains filtered or unexported fields }
func (*User) Authenticate ¶
func (*User) SetPassword ¶
Click to show internal directories.
Click to hide internal directories.