data

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ScopeDefault is the default account panel scope.
	ScopeDefault = ""
	// ScopeGOCDB is used to access the GOCDB.
	ScopeGOCDB = "gocdb"
	// ScopeSites is used to access the global sites configuration.
	ScopeSites = "sites"
)

Variables

This section is empty.

Functions

func QueryOperatorName added in v0.0.14

func QueryOperatorName(opID string, mentixHost, dataEndpoint string) (string, error)

QueryOperatorName uses Mentix to query the name of an operator given by its ID.

func QueryOperatorSites added in v0.0.14

func QueryOperatorSites(opID string, mentixHost, dataEndpoint string) ([]string, error)

QueryOperatorSites uses Mentix to query the sites associated with the specified operator.

func QuerySiteName

func QuerySiteName(siteID string, fullName bool, mentixHost, dataEndpoint string) (string, error)

QuerySiteName uses Mentix to query the name of a sites given by its ID.

Types

type Account

type Account struct {
	Email       string `json:"email"`
	Title       string `json:"title"`
	FirstName   string `json:"firstName"`
	LastName    string `json:"lastName"`
	Operator    string `json:"operator"`
	Role        string `json:"role"`
	PhoneNumber string `json:"phoneNumber"`

	Password credentials.Password `json:"password"`

	DateCreated  time.Time `json:"dateCreated"`
	DateModified time.Time `json:"dateModified"`

	Data     AccountData     `json:"data"`
	Settings AccountSettings `json:"settings"`
}

Account represents a single sites account.

func NewAccount

func NewAccount(email string, title, firstName, lastName string, operator, role string, phoneNumber string, password string) (*Account, error)

NewAccount creates a new sites account.

func (*Account) CheckScopeAccess

func (acc *Account) CheckScopeAccess(scope string) bool

CheckScopeAccess checks whether the user can access the specified scope.

func (*Account) Cleanup

func (acc *Account) Cleanup()

Cleanup trims all string entries.

func (*Account) Clone

func (acc *Account) Clone(erasePassword bool) *Account

Clone creates a copy of the account; if erasePassword is set to true, the password will be cleared in the cloned object.

func (*Account) Configure

func (acc *Account) Configure(other *Account) error

Configure copies the settings of the given account to this account.

func (*Account) Update

func (acc *Account) Update(other *Account, setPassword bool, copyData bool) error

Update copies the data of the given account to this account.

func (*Account) UpdatePassword

func (acc *Account) UpdatePassword(pwd string) error

UpdatePassword assigns a new password to the account, hashing it first.

type AccountData

type AccountData struct {
	GOCDBAccess bool `json:"gocdbAccess"`
	SitesAccess bool `json:"sitesAccess"`
}

AccountData holds additional data for a sites account.

type AccountSettings

type AccountSettings struct {
	ReceiveAlerts bool `json:"receiveAlerts"`
}

AccountSettings holds additional settings for a sites account.

type Accounts

type Accounts = []*Account

Accounts holds an array of sites accounts.

type FileStorage

type FileStorage struct {
	Storage
	// contains filtered or unexported fields
}

FileStorage implements a filePath-based storage.

func NewFileStorage

func NewFileStorage(conf *config.Configuration, log *zerolog.Logger) (*FileStorage, error)

NewFileStorage creates a new file storage.

func (*FileStorage) AccountAdded

func (storage *FileStorage) AccountAdded(account *Account)

AccountAdded is called when an account has been added.

func (*FileStorage) AccountRemoved

func (storage *FileStorage) AccountRemoved(account *Account)

AccountRemoved is called when an account has been removed.

func (*FileStorage) AccountUpdated

func (storage *FileStorage) AccountUpdated(account *Account)

AccountUpdated is called when an account has been updated.

func (*FileStorage) OperatorAdded added in v0.0.14

func (storage *FileStorage) OperatorAdded(op *Operator)

OperatorAdded is called when a sites has been added.

func (*FileStorage) OperatorRemoved added in v0.0.14

func (storage *FileStorage) OperatorRemoved(op *Operator)

OperatorRemoved is called when a sites has been removed.

func (*FileStorage) OperatorUpdated added in v0.0.14

func (storage *FileStorage) OperatorUpdated(op *Operator)

OperatorUpdated is called when a sites has been updated.

func (*FileStorage) ReadAccounts

func (storage *FileStorage) ReadAccounts() (*Accounts, error)

ReadAccounts reads all stored accounts into the given data object.

func (*FileStorage) ReadOperators added in v0.0.14

func (storage *FileStorage) ReadOperators() (*Operators, error)

ReadOperators reads all stored operators into the given data object.

func (*FileStorage) WriteAccounts

func (storage *FileStorage) WriteAccounts(accounts *Accounts) error

WriteAccounts writes all stored accounts from the given data object.

func (*FileStorage) WriteOperators added in v0.0.14

func (storage *FileStorage) WriteOperators(ops *Operators) error

WriteOperators writes all stored operators from the given data object.

type Operator added in v0.0.14

type Operator struct {
	ID string `json:"id"`

	Sites []*Site `json:"sites"`
}

Operator represents the global operator-specific settings stored in the service.

func NewOperator added in v0.0.14

func NewOperator(id string) (*Operator, error)

NewOperator creates a new operator.

func (*Operator) Clone added in v0.0.14

func (op *Operator) Clone(eraseCredentials bool) *Operator

Clone creates a copy of the operator; if eraseCredentials is set to true, the (test user) credentials will be cleared in the cloned object.

func (*Operator) Update added in v0.0.14

func (op *Operator) Update(other *Operator, credsPassphrase string) error

Update copies the data of the given operator to this operator.

type OperatorInformation added in v0.0.14

type OperatorInformation struct {
	ID   string
	Name string

	Sites []SiteInformation
}

OperatorInformation holds the most basic information about an operator and its sites.

func QueryAvailableOperators added in v0.0.14

func QueryAvailableOperators(mentixHost, dataEndpoint string) ([]OperatorInformation, error)

QueryAvailableOperators uses Mentix to query a list of all available operators and sites.

type Operators added in v0.0.14

type Operators = []*Operator

Operators holds an array of operators.

type Site

type Site struct {
	ID string `json:"id"`

	Config SiteConfiguration `json:"config"`
}

Site represents the global sites-specific settings stored in the service.

func NewSite

func NewSite(id string) (*Site, error)

NewSite creates a new sites.

func (*Site) Clone

func (site *Site) Clone(eraseCredentials bool) *Site

Clone creates a copy of the sites; if eraseCredentials is set to true, the (test user) credentials will be cleared in the cloned object.

func (*Site) Update

func (site *Site) Update(other *Site, credsPassphrase string) error

Update copies the data of the given sites to this sites.

func (*Site) UpdateTestClientCredentials

func (site *Site) UpdateTestClientCredentials(id, secret string, passphrase string) error

UpdateTestClientCredentials assigns new test client credentials, encrypting the information first.

type SiteConfiguration

type SiteConfiguration struct {
	TestClientCredentials credentials.Credentials `json:"testClientCredentials"`
}

SiteConfiguration stores the global configuration of a sites.

type SiteInformation

type SiteInformation struct {
	ID       string
	Name     string
	FullName string
}

SiteInformation holds the most basic information about a sites.

type Storage

type Storage interface {
	// ReadOperators reads all stored operators into the given data object.
	ReadOperators() (*Operators, error)
	// WriteOperators writes all stored operators from the given data object.
	WriteOperators(ops *Operators) error

	// OperatorAdded is called when an operator has been added.
	OperatorAdded(op *Operator)
	// OperatorUpdated is called when an operator has been updated.
	OperatorUpdated(op *Operator)
	// OperatorRemoved is called when an operator has been removed.
	OperatorRemoved(op *Operator)

	// ReadAccounts reads all stored accounts into the given data object.
	ReadAccounts() (*Accounts, error)
	// WriteAccounts writes all stored accounts from the given data object.
	WriteAccounts(accounts *Accounts) error

	// AccountAdded is called when an account has been added.
	AccountAdded(account *Account)
	// AccountUpdated is called when an account has been updated.
	AccountUpdated(account *Account)
	// AccountRemoved is called when an account has been removed.
	AccountRemoved(account *Account)
}

Storage defines the interface for operators and accounts storages.

Jump to

Keyboard shortcuts

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