db

package
v0.0.0-...-dac393e Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2019 License: MIT, MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BackupOperation         = "backup"
	RestoreOperation        = "restore"
	ShieldRestoreOperation  = "shield-restore"
	PurgeOperation          = "purge"
	TestStoreOperation      = "test-store"
	AgentStatusOperation    = "agent-status"
	AnalyzeStorageOperation = "analyze-storage"

	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 GlobalTenantUUID = uuid.NIL.String()
View Source
var Schemas = map[int]Schema{
	1: v1Schema{},
	2: v2Schema{},
	3: v3Schema{},
	4: v4Schema{},
	5: v5Schema{},
	6: v6Schema{},
	7: v7Schema{},
	8: v8Schema{},
}

Functions

func Pattern

func Pattern(glob string) string

Turns globs ('*search*') into SQL patterns ('%search%')

func PatternPrefix

func PatternPrefix(prefix string) string

func RandomID

func RandomID() string

Generate a randomized UUID

Types

type Agent

type Agent struct {
	UUID       string `json:"uuid"    mbus:"uuid"`
	Name       string `json:"name"    mbus:"name"`
	Address    string `json:"address" mbus:"address"`
	Version    string `json:"version" mbus:"version"`
	Hidden     bool   `json:"hidden"`
	LastSeenAt int64  `json:"last_seen_at" mbus:"last_seen_at"`
	LastError  string `json:"last_error"   mbus:"last_error"`
	Status     string `json:"status"       mbus:"status"`

	Meta    map[string]interface{} `json:"metadata,omitempty"`
	RawMeta string                 `json:"-"`
}

func (*Agent) Metadata

func (a *Agent) Metadata() (map[string]interface{}, error)

type AgentFilter

type AgentFilter struct {
	UUID       string
	ExactMatch bool
	Address    string
	Name       string
	Status     string
	OnlyHidden bool
	SkipHidden bool

	InflateMetadata bool
}

func (*AgentFilter) Query

func (f *AgentFilter) Query() (string, []interface{})

type Archive

type Archive struct {
	UUID           string `json:"uuid"            mbus:"uuid"`
	TenantUUID     string `json:"tenant_uuid"     mbus:"tenant_uuid"`
	TargetUUID     string `json:"target_uuid"     mbus:"target_uuid"`
	StoreUUID      string `json:"store_uuid"      mbus:"store_uuid"`
	StoreKey       string `json:"key"             mbus:"key"`
	TakenAt        int64  `json:"taken_at"        mbus:"taken_at"`
	ExpiresAt      int64  `json:"expires_at"      mbus:"expires_at"`
	Notes          string `json:"notes"           mbus:"notes"`
	Status         string `json:"status"          mbus:"status"`
	PurgeReason    string `json:"purge_reason"    mbus:"purge_reason"`
	EncryptionType string `json:"encryption_type" mbus:"encryption_type"`
	Compression    string `json:"compression"     mbus:"compression"`
	Size           int64  `json:"size"            mbus:"size"`

	TargetName     string `json:"target_name"`
	TargetPlugin   string `json:"target_plugin"`
	TargetEndpoint string `json:"target_endpoint"`
	StoreName      string `json:"store_name"`
	StorePlugin    string `json:"store_plugin"`
	StoreEndpoint  string `json:"store_endpoint"`
	StoreAgent     string `json:"store_agent"`
	Job            string `json:"job"`
}

type ArchiveFilter

type ArchiveFilter struct {
	UUID          string
	ExactMatch    bool
	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 AuthToken

type AuthToken struct {
	UUID      string `json:"uuid"`
	Session   string `json:"session,omitempty"`
	Name      string `json:"name"`
	CreatedAt int64  `json:"created_at"`
	LastSeen  *int64 `json:"last_seen"`
}

type AuthTokenFilter

type AuthTokenFilter struct {
	UUID string
	User *User
	Name string
}

func (AuthTokenFilter) Query

func (t AuthTokenFilter) Query() (string, []interface{})

type ConfigItem

type ConfigItem struct {
	Label    string `json:"label"`
	Key      string `json:"key"`
	Value    string `json:"value"`
	Type     string `json:"type"`
	Default  string `json:"default"`
	Redacted bool   `json:"redacted"`
}

func DisplayableConfig

func DisplayableConfig(typ string, info *plugin.PluginInfo, config map[string]interface{}, private bool) []ConfigItem

type DB

type DB struct {
	Driver string
	DSN    string
	// contains filtered or unexported fields
}

func Connect

func Connect(file string) (*DB, error)

Connect to the backend database

func (*DB) AddUserToTenant

func (db *DB) AddUserToTenant(user, tenant, role string) error

func (*DB) AnnotateTargetArchive

func (db *DB) AnnotateTargetArchive(target, id, notes string) error

func (*DB) AnnotateTargetTask

func (db *DB) AnnotateTargetTask(target, id string, t *TaskAnnotation) error

func (*DB) ApplyFixup

func (db *DB) ApplyFixup(id string) error

func (*DB) ApplyFixups

func (db *DB) ApplyFixups() error

func (*DB) ArchiveStorageFootprint

func (db *DB) ArchiveStorageFootprint(filter *ArchiveFilter) (int64, error)

func (*DB) CancelTask

func (db *DB) CancelTask(id string, at time.Time) error

func (*DB) CheckCurrentSchema

func (db *DB) CheckCurrentSchema() error

func (*DB) CleanArchives

func (db *DB) CleanArchives() error

func (*DB) CleanStores

func (db *DB) CleanStores() error

func (*DB) CleanTargets

func (db *DB) CleanTargets() error

func (*DB) ClearAllSessions

func (db *DB) ClearAllSessions() error

func (*DB) ClearExpiredSessions

func (db *DB) ClearExpiredSessions(expiration_threshold time.Time) error

func (*DB) ClearMembershipsFor

func (db *DB) ClearMembershipsFor(user *User) error

func (*DB) ClearSession

func (db *DB) ClearSession(id string) error

func (*DB) CompleteTask

func (db *DB) CompleteTask(id string, at time.Time) error

func (*DB) Connected

func (db *DB) Connected() bool

Are we connected?

func (*DB) Count

func (db *DB) Count(sql string, args ...interface{}) (uint, error)

Execute a data query (SELECT) and return how many rows were returned

func (*DB) CountArchives

func (db *DB) CountArchives(filter *ArchiveFilter) (int, error)

func (*DB) CountTargets

func (db *DB) CountTargets(filter *TargetFilter) (int, error)

func (*DB) CreateAgentStatusTask

func (db *DB) CreateAgentStatusTask(owner string, agent *Agent) (*Task, error)

func (*DB) CreateBackupTask

func (db *DB) CreateBackupTask(owner string, job *Job) (*Task, error)

func (*DB) CreateInternalTask

func (db *DB) CreateInternalTask(owner, op, tenant string) (*Task, error)

func (*DB) CreateJob

func (db *DB) CreateJob(job *Job) (*Job, error)

func (*DB) CreatePurgeTask

func (db *DB) CreatePurgeTask(owner string, archive *Archive) (*Task, error)

func (*DB) CreateRestoreTask

func (db *DB) CreateRestoreTask(owner string, archive *Archive, target *Target) (*Task, error)

func (*DB) CreateSession

func (db *DB) CreateSession(session *Session) (*Session, error)

func (*DB) CreateStore

func (db *DB) CreateStore(store *Store) (*Store, error)

func (*DB) CreateTarget

func (db *DB) CreateTarget(target *Target) (*Target, error)

func (*DB) CreateTaskArchive

func (db *DB) CreateTaskArchive(id, archive_id, key string, at time.Time, encryptionType, compression string, archive_size int64, tenant_uuid string) (string, error)

func (*DB) CreateTenant

func (db *DB) CreateTenant(tenant *Tenant) (*Tenant, error)

func (*DB) CreateTestStoreTask

func (db *DB) CreateTestStoreTask(owner string, store *Store) (*Task, error)

func (*DB) CreateUser

func (db *DB) CreateUser(user *User) (*User, error)

func (*DB) DeleteArchive

func (db *DB) DeleteArchive(id string) (bool, error)

func (*DB) DeleteAuthToken

func (db *DB) DeleteAuthToken(id string, user *User) error

func (*DB) DeleteJob

func (db *DB) DeleteJob(id string) (bool, error)

func (*DB) DeleteStore

func (db *DB) DeleteStore(id string) (bool, error)

func (*DB) DeleteTarget

func (db *DB) DeleteTarget(id string) (bool, error)

func (*DB) DeleteTenant

func (db *DB) DeleteTenant(tenant *Tenant, recurse bool) error

func (*DB) DeleteUser

func (db *DB) DeleteUser(user *User) error

func (*DB) Disconnect

func (db *DB) Disconnect() error

Disconnect from the backend database

func (*DB) EnsureTenant

func (db *DB) EnsureTenant(name string) (*Tenant, error)

func (*DB) Exec

func (db *DB) Exec(sql string, args ...interface{}) error

Execute a named, non-data query (INSERT, UPDATE, DELETE, etc.)

func (*DB) ExpireArchive

func (db *DB) ExpireArchive(id string) error

func (*DB) FailTask

func (db *DB) FailTask(id string, at time.Time) error

func (*DB) GenerateAuthToken

func (db *DB) GenerateAuthToken(name string, user *User) (*AuthToken, string, error)

func (*DB) GetAgent

func (db *DB) GetAgent(id string) (*Agent, error)

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

func (db *DB) GetAllArchives(filter *ArchiveFilter) ([]*Archive, error)

func (*DB) GetAllAuthTokens

func (db *DB) GetAllAuthTokens(filter *AuthTokenFilter) ([]*AuthToken, error)

func (*DB) GetAllJobs

func (db *DB) GetAllJobs(filter *JobFilter) ([]*Job, error)

func (*DB) GetAllSessions

func (db *DB) GetAllSessions(filter *SessionFilter) ([]*Session, error)

func (*DB) GetAllStores

func (db *DB) GetAllStores(filter *StoreFilter) ([]*Store, error)

func (*DB) GetAllTargets

func (db *DB) GetAllTargets(filter *TargetFilter) ([]*Target, error)

func (*DB) GetAllTasks

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) GetArchive

func (db *DB) GetArchive(id string) (*Archive, error)

func (*DB) GetArchivesNeedingPurge

func (db *DB) GetArchivesNeedingPurge() ([]*Archive, error)

func (*DB) GetAuthToken

func (db *DB) GetAuthToken(id string) (*AuthToken, error)

func (*DB) GetExpiredArchives

func (db *DB) GetExpiredArchives() ([]*Archive, error)

func (*DB) GetJob

func (db *DB) GetJob(id string) (*Job, error)

func (*DB) GetMembershipsForUser

func (db *DB) GetMembershipsForUser(user string) ([]*Membership, error)

func (*DB) GetSession

func (db *DB) GetSession(id string) (*Session, error)

func (*DB) GetStore

func (db *DB) GetStore(id string) (*Store, error)

func (*DB) GetTarget

func (db *DB) GetTarget(id string) (*Target, error)

func (*DB) GetTask

func (db *DB) GetTask(id string) (*Task, error)

func (*DB) GetTenant

func (db *DB) GetTenant(id string) (*Tenant, error)

func (*DB) GetTenantRole

func (db *DB) GetTenantRole(org string, team string) (string, string, error)

func (*DB) GetTenantsForUser

func (db *DB) GetTenantsForUser(user string) ([]*Tenant, error)

GetTenantsForUser given a user's uuid returns a slice of Tenants that the user has membership with

func (*DB) GetUser

func (db *DB) GetUser(account string, backend string) (*User, error)

func (*DB) GetUserByID

func (db *DB) GetUserByID(id string) (*User, error)

func (*DB) GetUserForSession

func (db *DB) GetUserForSession(id string) (*User, error)

func (*DB) GetUsersForTenant

func (db *DB) GetUsersForTenant(tenant string) ([]*User, error)

func (*DB) Inform

func (db *DB) Inform(mbus *bus.Bus)

Have the database start sending SHIELD Bus Events to a message bus

func (*DB) InvalidateArchive

func (db *DB) InvalidateArchive(id string) error

func (*DB) IsTaskRunnable

func (db *DB) IsTaskRunnable(task *Task) (bool, error)

func (*DB) ManuallyPurgeArchive

func (db *DB) ManuallyPurgeArchive(id string) error

func (*DB) MarkTasksIrrelevant

func (db *DB) MarkTasksIrrelevant() error

func (*DB) PauseJob

func (db *DB) PauseJob(id string) (bool, error)

func (*DB) PauseOrUnpauseJob

func (db *DB) PauseOrUnpauseJob(id string, pause bool) (bool, error)

func (*DB) PokeSession

func (db *DB) PokeSession(session *Session) error

func (*DB) PreRegisterAgent

func (db *DB) PreRegisterAgent(host, name string, port int) error

func (*DB) PurgeArchive

func (db *DB) PurgeArchive(id string) error

func (*DB) Query

func (db *DB) Query(sql string, args ...interface{}) (*sql.Rows, error)

Execute a named, data query (SELECT)

func (*DB) RedactAllTaskLogs

func (db *DB) RedactAllTaskLogs(tasks []*Task)

func (*DB) RedactTaskLog

func (db *DB) RedactTaskLog(task *Task)

func (*DB) RegisterFixups

func (db *DB) RegisterFixups() error

func (*DB) RemoveUserFromTenant

func (db *DB) RemoveUserFromTenant(user, tenant string) error

func (*DB) RescheduleJob

func (db *DB) RescheduleJob(j *Job, t time.Time) error

func (*DB) ScheduledTask

func (db *DB) ScheduledTask(id string) error

func (*DB) SchemaVersion

func (db *DB) SchemaVersion() (int, error)

func (*DB) Setup

func (db *DB) Setup(want int) (int, error)

func (*DB) SkipBackupTask

func (db *DB) SkipBackupTask(owner string, job *Job, msg string) (*Task, error)

func (*DB) StartTask

func (db *DB) StartTask(id string, at time.Time) error

func (*DB) UnpauseJob

func (db *DB) UnpauseJob(id string) (bool, error)

func (*DB) UnscheduleAllTasks

func (db *DB) UnscheduleAllTasks() error

UnscheduleAllTasks takes all tasks which are in the scheduled state and puts them back in a pending state.

func (*DB) UpdateAgent

func (db *DB) UpdateAgent(agent *Agent) error

func (*DB) UpdateArchive

func (db *DB) UpdateArchive(update *Archive) error

func (*DB) UpdateJob

func (db *DB) UpdateJob(job *Job) error

func (*DB) UpdateStore

func (db *DB) UpdateStore(store *Store) error

func (*DB) UpdateTarget

func (db *DB) UpdateTarget(target *Target) error

func (*DB) UpdateTaskLog

func (db *DB) UpdateTaskLog(id string, more string) error

func (*DB) UpdateTenant

func (db *DB) UpdateTenant(tenant *Tenant) (*Tenant, error)

func (*DB) UpdateUser

func (db *DB) UpdateUser(user *User) error

func (*DB) UpdateUserSettings

func (db *DB) UpdateUserSettings(user *User) error

type Job

type Job struct {
	TenantUUID string `json:"-" mbus:"tenant_uuid"`
	TargetUUID string `json:"-" mbus:"target_uuid"`
	StoreUUID  string `json:"-" mbus:"store_uuid"`

	UUID     string `json:"uuid"      mbus:"uuid"`
	Name     string `json:"name"      mbus:"name"`
	Summary  string `json:"summary"   mbus:"summary"`
	KeepN    int    `json:"keep_n"    mbus:"keep_n"`
	KeepDays int    `json:"keep_days" mbus:"keep_days"`
	Schedule string `json:"schedule"  mbus:"schedule"`
	Paused   bool   `json:"paused"    mbus:"paused"`
	FixedKey bool   `json:"fixed_key" mbus:"fixed_key"`

	Target struct {
		UUID        string `json:"uuid"`
		Name        string `json:"name"`
		Agent       string `json:"agent"`
		Plugin      string `json:"plugin"`
		Compression string `json:"compression"`

		Endpoint string                 `json:"endpoint,omitempty"`
		Config   map[string]interface{} `json:"config,omitempty"`
	} `json:"target"`

	Store struct {
		UUID    string `json:"uuid"`
		Name    string `json:"name"`
		Agent   string `json:"agent"`
		Plugin  string `json:"plugin"`
		Summary string `json:"summary"`
		Healthy bool   `json:"healthy"`

		Endpoint string                 `json:"endpoint,omitempty"`
		Config   map[string]interface{} `json:"config,omitempty"`
	} `json:"store"`

	Agent string `json:"agent"`

	Healthy        bool   `json:"healthy" mbus:"healthy"`
	LastRun        int64  `json:"last_run"`
	LastTaskStatus string `json:"last_task_status"`

	Spec    *timespec.Spec `json:"-"`
	NextRun int64          `json:"-"`
}

func (*Job) Reschedule

func (j *Job) Reschedule() error

func (*Job) Runnable

func (j *Job) Runnable() bool

type JobFilter

type JobFilter struct {
	UUID         string
	SkipPaused   bool
	SkipUnpaused bool

	Overdue bool

	SearchName string

	ForTenant  string
	ForTarget  string
	ForStore   string
	ExactMatch bool
}

func (*JobFilter) Query

func (f *JobFilter) Query() (string, []interface{})

type Membership

type Membership struct {
	TenantUUID string `json:"tenant_uuid" mbus:"tenant_uuid"`
	TenantName string `json:"tenant_name" mbus:"tenant_name"`
	Role       string `json:"role"        mbus:"role"`
}

type Schema

type Schema interface {
	Deploy(*DB) error
}

type Session

type Session struct {
	UUID           string `json:"uuid"`
	UserUUID       string `json:"user_uuid"`
	CreatedAt      int64  `json:"created_at"`
	LastSeen       int64  `json:"last_seen_at"`
	Token          string `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"`
}

func (*Session) Expired

func (s *Session) Expired(lifetime int) bool

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

type Store struct {
	UUID       string `json:"uuid"    mbus:"uuid"`
	TenantUUID string `json:"-"       mbus:"tenant_uuid"`
	Name       string `json:"name"    mbus:"name"`
	Summary    string `json:"summary" mbus:"summary"`
	Agent      string `json:"agent"   mbus:"agent"`
	Plugin     string `json:"plugin"  mbus:"plugin"`
	Global     bool   `json:"global"  mbus:"global"`
	Healthy    bool   `json:"healthy" mbus:"healthy"`

	DailyIncrease int64 `json:"daily_increase" mbus:"daily_increase"`
	StorageUsed   int64 `json:"storage_used"   mbus:"storage_used"`
	Threshold     int64 `json:"threshold"      mbus:"threshold"`
	ArchiveCount  int   `json:"archive_count"  mbus:"archive_count"`

	Config map[string]interface{} `json:"config,omitempty" mbus:"config"`

	LastTestTaskUUID string `json:"last_test_task_uuid"`
}

func (Store) ConfigJSON

func (store Store) ConfigJSON() (string, error)

func (*Store) Configuration

func (store *Store) Configuration(db *DB, private bool) ([]ConfigItem, error)

type StoreFilter

type StoreFilter struct {
	UUID       string
	SkipUsed   bool
	SkipUnused bool
	SearchName string
	ForPlugin  string
	ForTenant  string
	ExactMatch bool
}

func (*StoreFilter) Query

func (f *StoreFilter) Query() (string, []interface{})

type StoreStats

type StoreStats struct {
	DailyIncrease int64 `json:"daily_increase"`
	StorageUsed   int64 `json:"storage_used"`
	ArchiveCount  int   `json:"archive_count"`
}

type Target

type Target struct {
	UUID        string `json:"uuid"        mbus:"uuid"`
	TenantUUID  string `json:"-"           mbus:"tenant_uuid"`
	Name        string `json:"name"        mbus:"name"`
	Summary     string `json:"summary"     mbus:"summary"`
	Plugin      string `json:"plugin"      mbus:"plugin"`
	Agent       string `json:"agent"       mbus:"agent"`
	Compression string `json:"compression" mbus:"compression"`

	Config map[string]interface{} `json:"config,omitempty"  mbus:"config"`
}

func (Target) ConfigJSON

func (t Target) ConfigJSON() (string, error)

func (*Target) Configuration

func (target *Target) Configuration(db *DB, private bool) ([]ConfigItem, error)

type TargetFilter

type TargetFilter struct {
	UUID       string
	SkipUsed   bool
	SkipUnused bool
	SearchName string
	ForTenant  string
	ForPlugin  string
	ExactMatch bool
}

func (*TargetFilter) Query

func (f *TargetFilter) Query() (string, []interface{})

type Task

type Task struct {
	UUID           string         `json:"uuid"            mbus:"uuid"`
	TenantUUID     string         `json:"-"               mbus:"tenant_uuid"`
	Owner          string         `json:"owner"           mbus:"owner"`
	Op             string         `json:"type"            mbus:"op"`
	JobUUID        string         `json:"job_uuid"        mbus:"job_uuid"`
	ArchiveUUID    string         `json:"archive_uuid"    mbus:"archive_uuid"`
	StoreUUID      string         `json:"-"               mbus:"store_uuid"`
	StorePlugin    string         `json:"-"`
	StoreEndpoint  string         `json:"-"`
	TargetUUID     string         `json:"-"               mbus:"target_uuid"`
	TargetPlugin   string         `json:"-"`
	TargetEndpoint string         `json:"-"`
	Compression    string         `json:"-"`
	Status         string         `json:"status"          mbus:"status"`
	RequestedAt    int64          `json:"requested_at"    mbus:"requested_at"`
	StartedAt      int64          `json:"started_at"      mbus:"started_at"`
	StoppedAt      int64          `json:"stopped_at"      mbus:"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"              mbus:"ok"`
	Notes          string         `json:"notes"           mbus:"notes"`
	Clear          string         `json:"clear"           mbus:"clear"`
	TaskUUIDChan   chan *TaskInfo `json:"-"`
}

type TaskAnnotation

type TaskAnnotation struct {
	Disposition string
	Notes       string
	Clear       string
}

type TaskFilter

type TaskFilter struct {
	UUID          string
	ExactMatch    bool
	SkipActive    bool
	SkipInactive  bool
	OnlyRelevant  bool
	ForOp         string
	ForTenant     string
	ForTarget     string
	ForStatus     string
	ForArchive    string
	Limit         int
	RequestedAt   int64
	Before        int64
	StartedAfter  *time.Duration
	StoppedAfter  *time.Duration
	StartedBefore *time.Duration
	StoppedBefore *time.Duration
}

func (*TaskFilter) Query

func (f *TaskFilter) Query() (string, []interface{})

type TaskInfo

type TaskInfo struct {
	Info string //UUID if not Err. Error message if Err.
	Err  bool
}

type Tenant

type Tenant struct {
	UUID          string  `json:"uuid"              mbus:"uuid"`
	Name          string  `json:"name"              mbus:"name"`
	Members       []*User `json:"members,omitempty"`
	DailyIncrease int64   `json:"daily_increase"    mbus:"daily_increase"`
	StorageUsed   int64   `json:"storage_used"      mbus:"storage_used"`
	ArchiveCount  int     `json:"archive_count"     mbus:"archive_count"`
}

type TenantFilter

type TenantFilter struct {
	Name       string
	ExactMatch bool
	UUID       string
	Limit      int
}

func (*TenantFilter) Query

func (f *TenantFilter) Query() (string, []interface{})

type User

type User struct {
	UUID    string `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 (u *User) Authenticate(password string) bool

func (*User) IsLocal

func (u *User) IsLocal() bool

func (*User) SetPassword

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

type UserFilter

type UserFilter struct {
	UUID       string
	Backend    string
	Account    string
	SysRole    string
	ExactMatch bool
	Search     string
	Limit      int
}

func (*UserFilter) Query

func (f *UserFilter) Query() (string, []interface{})

Jump to

Keyboard shortcuts

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