boltdb

package
v0.0.0-...-baca4c3 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

README

Deprecated Package.

Move to Datastore package. It will slowly be removed in future updates.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

func Initialise

func Initialise(server *mattrax.Server) error

Initialise the database connection and mount the services to the server

Types

type DeviceStore

type DeviceStore struct {
	// contains filtered or unexported fields
}

DeviceStore saves and loads devices

func NewDeviceStore

func NewDeviceStore(db *bolt.DB) (DeviceStore, error)

NewDeviceStore creates and initialises a new DeviceStore from a DB connection

func (DeviceStore) EditOrCreate

func (ds DeviceStore) EditOrCreate(device devices.Device) error

EditOrCreate adds a new device or edits the existing device in the DB

func (DeviceStore) Get

func (ds DeviceStore) Get(uuid string) (devices.Device, error)

Get returns a device from its UUID

func (DeviceStore) GetAll

func (ds DeviceStore) GetAll() ([]devices.Device, error)

GetAll returns all devices

func (DeviceStore) GetXDevices

func (ds DeviceStore) GetXDevices(firstDeviceUUID *string, count int64) ([]devices.Device, error)

GetXDevices returns X (set by count) devices starting at the firstDeviceUUID

func (DeviceStore) Search

func (ds DeviceStore) Search(query string) ([]devices.Device, error)

Search returns a list of device from a query

type PolicyService

type PolicyService struct {
	// contains filtered or unexported fields
}

PolicyService contains the implemented functionality for policies

func NewPolicyService

func NewPolicyService(db *bolt.DB) (PolicyService, error)

NewPolicyService creates and initialises a new PolicyService from a DB connection

func (PolicyService) CreateOrEdit

func (ps PolicyService) CreateOrEdit(uuid types.PolicyUUID, policy types.Policy) error

CreateOrEdit creates or edits an existing policy if one exists

func (PolicyService) Get

func (ps PolicyService) Get(uuid types.PolicyUUID) (types.Policy, error)

Get returns a policy by its uuid

func (PolicyService) GetAll

func (ps PolicyService) GetAll() ([]types.Policy, error)

GetAll returns all policies

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

UserService contains the implemented functionality for users

func NewUserService

func NewUserService(db *bolt.DB) (UserService, error)

NewUserService creates and initialises a new UserService from a DB connection

func (UserService) CreateOrEdit

func (us UserService) CreateOrEdit(email string, user types.User) error

CreateOrEdit creates or edits an existing user if one exists

func (UserService) Get

func (us UserService) Get(email string) (types.User, error)

Get returns a user by their email

func (UserService) GetAll

func (us UserService) GetAll() ([]types.User, error)

GetAll returns all users

func (UserService) HasPermission

func (us UserService) HasPermission(email string, permission string) (bool, error)

HasPermission takes a users email & a permission and checks if the user contains that permission. It also handles wildcard permissions that can be given to a user.

func (UserService) HashPassword

func (us UserService) HashPassword(password []byte) (types.RawPassword, error)

HashPassword returns a password in hashed form ready to be stored into the DB

func (UserService) VerifyLogin

func (us UserService) VerifyLogin(email string, password string) (bool, error)

VerifyLogin takes in a users email & password and checks if they match the users hashed password

Jump to

Keyboard shortcuts

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