Documentation ¶
Index ¶
- Constants
- func DumpDb(gen *Db, out io.Writer) error
- func ImportDb(gen *Db, in io.Reader) error
- type Db
- func (gen *Db) Close() error
- func (gen *Db) EdgeCopy(id, newParent string) error
- func (gen *Db) EdgeInsert(edge data.Edge) (string, error)
- func (gen *Db) EdgeMove(id, oldParent, newParent string) error
- func (gen *Db) EdgeUp(nodeID string) ([]string, error)
- func (gen *Db) Edges() ([]data.Edge, error)
- func (gen *Db) Group(id string) (data.Group, error)
- func (gen *Db) GroupDelete(id string) error
- func (gen *Db) GroupInsert(group data.Group) (string, error)
- func (gen *Db) GroupUpdate(gUpdate data.Group) error
- func (gen *Db) Groups() ([]data.Group, error)
- func (gen *Db) Node(id string) (data.Node, error)
- func (gen *Db) NodeDelete(id, parent string) error
- func (gen *Db) NodeDescendents(id, typ string, recursive bool) ([]data.NodeEdge, error)
- func (gen *Db) NodeInsert(node data.Node) (string, error)
- func (gen *Db) NodeInsertEdge(node data.NodeEdge) (string, error)
- func (gen *Db) NodePoint(id string, point data.Point) error
- func (gen *Db) NodeSetState(id string, state string) error
- func (gen *Db) NodeSetSwUpdateState(id string, state data.SwUpdateState) error
- func (gen *Db) Nodes() ([]data.Node, error)
- func (gen *Db) NodesForGroup(tx *bolt.Tx, groupID string) ([]data.Node, error)
- func (gen *Db) NodesForUser(userID string) ([]data.NodeEdge, error)
- func (gen *Db) RootNodeID() string
- func (gen *Db) UserByEmail(email string) (data.User, error)
- func (gen *Db) UserByID(id string) (data.User, error)
- func (gen *Db) UserCheck(email, password string) (*data.User, error)
- func (gen *Db) UserDelete(id string) error
- func (gen *Db) UserInsert(user data.User) (string, error)
- func (gen *Db) UserIsRoot(id string) (bool, error)
- func (gen *Db) UserUpdate(user data.User) error
- func (gen *Db) Users() ([]data.User, error)
- func (gen *Db) UsersForGroup(id string) ([]data.User, error)
- type Device
- type DeviceConfig
- type DeviceState
- type DeviceVersion
- type Meta
- type StoreType
- type SwUpdateState
- type SysState
Constants ¶
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.
const ( StoreTypeMemory StoreType = "memory" StoreTypeBolt = "bolt" StoreTypeBadger = "badger" )
define valid store types
Variables ¶
This section is empty.
Functions ¶
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 (*Db) EdgeInsert ¶ added in v0.0.15
EdgeInsert is used to insert an edge into the database
func (*Db) GroupDelete ¶
GroupDelete deletes a node from the database
func (*Db) GroupInsert ¶
GroupInsert inserts a new group
func (*Db) GroupUpdate ¶
GroupUpdate updates a group
func (*Db) NodeDelete ¶
NodeDelete deletes a node from the database and recursively all descendents
func (*Db) NodeDescendents ¶ added in v0.0.20
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 ¶
NodeInsert is used to insert a node into the database
func (*Db) NodeInsertEdge ¶ added in v0.0.15
NodeInsertEdge -- insert a node and edge and return uuid FIXME can we replace this with NATS calls?
func (*Db) NodeSetState ¶
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) NodesForGroup ¶
NodesForGroup returns the nodes which are property of the given Group.
func (*Db) NodesForUser ¶
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
RootNodeID returns the ID of the root node
func (*Db) UserByEmail ¶
UserByEmail returns the user with the given email, if it exists.
func (*Db) UserDelete ¶
UserDelete deletes a user from the database
func (*Db) UserInsert ¶
UserInsert inserts a new user
func (*Db) UserIsRoot ¶
UserIsRoot checks if root user
func (*Db) UserUpdate ¶
UserUpdate updates a new user
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.
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 ¶
DeviceVersion represents the device SW version
type SwUpdateState ¶
type SwUpdateState struct { Running bool `json:"running"` Error string `json:"error"` PercentDone int `json:"percentDone"` }
SwUpdateState represents the state of an update