genji

package
v0.0.29 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SysStateUnknown  SysState = 0
	SysStatePowerOff          = 1
	SysStateOffline           = 2
	SysStateOnline            = 3
)

define valid system states don't even think about changing the below as it used in communications -- add new numbers if something needs changed/added.

View Source
const (
	StoreTypeMemory StoreType = "memory"
	StoreTypeBolt             = "bolt"
	StoreTypeBadger           = "badger"
)

define valid store types

Variables

This section is empty.

Functions

func DumpDb

func DumpDb(gen *Db, out io.Writer) error

DumpDb dumps the entire gen to a file

func ImportDb

func ImportDb(gen *Db, in io.Reader) error

ImportDb imports contents of file into database

Types

type Db

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

Db is used for all db access in the application. We will eventually turn this into an interface to handle multiple Db backends.

func NewDb

func NewDb(storeType StoreType, dataDir string) (*Db, error)

NewDb creates a new Db instance for the app

func (*Db) Close

func (gen *Db) Close() error

Close closes the db

func (*Db) EdgeCopy added in v0.0.23

func (gen *Db) EdgeCopy(id, newParent string) error

EdgeCopy is used to copy a node

func (*Db) EdgeInsert added in v0.0.15

func (gen *Db) EdgeInsert(edge data.Edge) (string, error)

EdgeInsert is used to insert an edge into the database

func (*Db) EdgeMove added in v0.0.15

func (gen *Db) EdgeMove(id, oldParent, newParent string) error

EdgeMove is used to change a nodes parent

func (*Db) EdgeUp added in v0.0.15

func (gen *Db) EdgeUp(nodeID string) ([]string, error)

EdgeUp returns an array of upstream nodes for a node

func (*Db) Edges added in v0.0.15

func (gen *Db) Edges() ([]data.Edge, error)

Edges returns all edges.

func (*Db) Group

func (gen *Db) Group(id string) (data.Group, error)

Group returns the Group with the given ID.

func (*Db) GroupDelete

func (gen *Db) GroupDelete(id string) error

GroupDelete deletes a node from the database

func (*Db) GroupInsert

func (gen *Db) GroupInsert(group data.Group) (string, error)

GroupInsert inserts a new group

func (*Db) GroupUpdate

func (gen *Db) GroupUpdate(gUpdate data.Group) error

GroupUpdate updates a group

func (*Db) Groups

func (gen *Db) Groups() ([]data.Group, error)

Groups returns all groups.

func (*Db) Node

func (gen *Db) Node(id string) (data.Node, error)

Node returns data for a particular node

func (*Db) NodeDelete

func (gen *Db) NodeDelete(id, parent string) error

NodeDelete deletes a node from the database and recursively all descendents

func (*Db) NodeDescendents added in v0.0.20

func (gen *Db) NodeDescendents(id, typ string, recursive bool) ([]data.NodeEdge, error)

NodeDescendents returns all descendents for a particular node ID and type set typ to blank string to find all descendents. Set recursive to false to stop at children, true to recursively get all descendents.

func (*Db) NodeInsert

func (gen *Db) NodeInsert(node data.Node) (string, error)

NodeInsert is used to insert a node into the database

func (*Db) NodeInsertEdge added in v0.0.15

func (gen *Db) NodeInsertEdge(node data.NodeEdge) (string, error)

NodeInsertEdge -- insert a node and edge and return uuid FIXME can we replace this with NATS calls?

func (*Db) NodePoint

func (gen *Db) NodePoint(id string, point data.Point) error

NodePoint processes a Point for a particular node

func (*Db) NodeSetState

func (gen *Db) NodeSetState(id string, state string) error

NodeSetState is used to set the current system state

func (*Db) NodeSetSwUpdateState

func (gen *Db) NodeSetSwUpdateState(id string, state data.SwUpdateState) error

NodeSetSwUpdateState is used to set the SW update state of the node

func (*Db) Nodes

func (gen *Db) Nodes() ([]data.Node, error)

Nodes returns all nodes.

func (*Db) NodesForGroup

func (gen *Db) NodesForGroup(tx *bolt.Tx, groupID string) ([]data.Node, error)

NodesForGroup returns the nodes which are property of the given Group.

func (*Db) NodesForUser

func (gen *Db) NodesForUser(userID string) ([]data.NodeEdge, error)

NodesForUser returns all nodes for a particular user FIXME this should be renamed to node children or something like that

func (*Db) RootNodeID added in v0.0.16

func (gen *Db) RootNodeID() string

RootNodeID returns the ID of the root node

func (*Db) UserByEmail

func (gen *Db) UserByEmail(email string) (data.User, error)

UserByEmail returns the user with the given email, if it exists.

func (*Db) UserByID

func (gen *Db) UserByID(id string) (data.User, error)

UserByID returns the user with the given ID, if it exists.

func (*Db) UserCheck

func (gen *Db) UserCheck(email, password string) (*data.User, error)

UserCheck checks user authentication returns nil, nil if user is not found

func (*Db) UserDelete

func (gen *Db) UserDelete(id string) error

UserDelete deletes a user from the database

func (*Db) UserInsert

func (gen *Db) UserInsert(user data.User) (string, error)

UserInsert inserts a new user

func (*Db) UserIsRoot

func (gen *Db) UserIsRoot(id string) (bool, error)

UserIsRoot checks if root user

func (*Db) UserUpdate

func (gen *Db) UserUpdate(user data.User) error

UserUpdate updates a new user

func (*Db) Users

func (gen *Db) Users() ([]data.User, error)

Users returns all users, sorted by first name.

func (*Db) UsersForGroup

func (gen *Db) UsersForGroup(id string) ([]data.User, error)

UsersForGroup returns all users who who are connected to a node by a group.

type Device

type Device struct {
	ID            string        `json:"id" boltholdKey:"ID"`
	Config        DeviceConfig  `json:"config"`
	State         DeviceState   `json:"state"`
	CmdPending    bool          `json:"cmdPending"`
	SwUpdateState SwUpdateState `json:"swUpdateState"`
	Groups        []string      `json:"groups"`
	Rules         []string      `json:"rules"`
}

Device represents the state of a device The config is typically updated by the portal/UI, and the State is updated by the device. Keeping these datastructures separate reduces the possibility that one update will step on another.

func (*Device) Desc

func (d *Device) Desc() string

Desc returns Description if set, otherwise ID

func (*Device) ToNode

func (d *Device) ToNode() data.Node

ToNode converts an old device type to current node type

type DeviceConfig

type DeviceConfig struct {
	Description string `json:"description"`
}

DeviceConfig represents a device configuration (stuff that is set by user in UI)

type DeviceState

type DeviceState struct {
	Version  DeviceVersion `json:"version"`
	Ios      []data.Point  `json:"ios"`
	LastComm time.Time     `json:"lastComm"`
	SysState SysState      `json:"sysState"`
}

DeviceState represents information about a device that is collected, vs set by user.

type DeviceVersion

type DeviceVersion struct {
	OS  string `json:"os"`
	App string `json:"app"`
	HW  string `json:"hw"`
}

DeviceVersion represents the device SW version

type Meta added in v0.0.15

type Meta struct {
	Version int
	RootID  string
}

Meta contains metadata about the database

type StoreType

type StoreType string

StoreType defines the backing store used for the DB

type SwUpdateState

type SwUpdateState struct {
	Running     bool   `json:"running"`
	Error       string `json:"error"`
	PercentDone int    `json:"percentDone"`
}

SwUpdateState represents the state of an update

type SysState

type SysState int

SysState defines the system state

Jump to

Keyboard shortcuts

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