data

package
v2.22.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func QuerySiteName

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

QuerySiteName uses Mentix to query the name of a site 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"`
	Site        string `json:"site"`
	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 site account.

func NewAccount

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

NewAccount creates a new site 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"`
	SiteAccess  bool `json:"siteAccess"`
}

AccountData holds additional data for a site account.

type AccountSettings

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

AccountSettings holds additional settings for a site account.

type Accounts

type Accounts = []*Account

Accounts holds an array of site 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) ReadAccounts added in v2.3.0

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

ReadAccounts reads all stored accounts into the given data object.

func (*FileStorage) ReadSites added in v2.3.0

func (storage *FileStorage) ReadSites() (*Sites, error)

ReadSites reads all stored sites into the given data object.

func (*FileStorage) SiteAdded added in v2.3.0

func (storage *FileStorage) SiteAdded(site *Site)

SiteAdded is called when a site has been added.

func (*FileStorage) SiteRemoved added in v2.3.0

func (storage *FileStorage) SiteRemoved(site *Site)

SiteRemoved is called when a site has been removed.

func (*FileStorage) SiteUpdated added in v2.3.0

func (storage *FileStorage) SiteUpdated(site *Site)

SiteUpdated is called when a site has been updated.

func (*FileStorage) WriteAccounts added in v2.3.0

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

WriteAccounts writes all stored accounts from the given data object.

func (*FileStorage) WriteSites added in v2.3.0

func (storage *FileStorage) WriteSites(sites *Sites) error

WriteSites writes all stored sites from the given data object.

type Site added in v2.3.0

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

	Config SiteConfiguration `json:"config"`
}

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

func NewSite added in v2.3.0

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

NewSite creates a new site.

func (*Site) Clone added in v2.3.0

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

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

func (*Site) Update added in v2.3.0

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

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

func (*Site) UpdateTestClientCredentials added in v2.3.0

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

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

type SiteConfiguration added in v2.3.0

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

SiteConfiguration stores the global configuration of a site.

type SiteInformation

type SiteInformation struct {
	ID       string
	Name     string
	FullName string
}

SiteInformation holds the most basic information about a site.

func QueryAvailableSites

func QueryAvailableSites(mentixHost, dataEndpoint string) ([]SiteInformation, error)

QueryAvailableSites uses Mentix to query a list of all available (registered) sites.

type Sites added in v2.3.0

type Sites = []*Site

Sites holds an array of sites.

type Storage

type Storage interface {
	// ReadSites reads all stored sites into the given data object.
	ReadSites() (*Sites, error)
	// WriteSites writes all stored sites from the given data object.
	WriteSites(sites *Sites) error

	// SiteAdded is called when a site has been added.
	SiteAdded(site *Site)
	// SiteUpdated is called when a site has been updated.
	SiteUpdated(site *Site)
	// SiteRemoved is called when a site has been removed.
	SiteRemoved(site *Site)

	// 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 sites and accounts storages.

Jump to

Keyboard shortcuts

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