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) 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) NodeCmds() ([]data.NodeCmd, error)
- func (gen *Db) NodeDelete(id string) error
- func (gen *Db) NodeDeleteCmd(id string) error
- func (gen *Db) NodeGetCmd(id string) (data.NodeCmd, error)
- func (gen *Db) NodeInsert(node data.Node) (string, error)
- func (gen *Db) NodePoint(id string, point data.Point) error
- func (gen *Db) NodeSetCmd(cmd data.NodeCmd) error
- func (gen *Db) NodeSetState(id string, state int) error
- func (gen *Db) NodeSetSwUpdateState(id string, state data.SwUpdateState) error
- func (gen *Db) NodeUpdateGroups(id string, groups []string) 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.Node, error)
- func (gen *Db) RuleByID(id string) (data.Rule, error)
- func (gen *Db) RuleDelete(id string) error
- func (gen *Db) RuleInsert(rule data.Rule) (string, error)
- func (gen *Db) RuleUpdateConfig(id string, config data.RuleConfig) error
- func (gen *Db) RuleUpdateState(id string, state data.RuleState) error
- func (gen *Db) Rules() ([]data.Rule, error)
- 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 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) 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
func (*Db) NodeDeleteCmd ¶
NodeDeleteCmd delets a cmd for a node and clears the the cmd pending flag
func (*Db) NodeGetCmd ¶
NodeGetCmd gets a cmd for a node. If the cmd is no null, the command is deleted, and the cmdPending flag cleared in the Node data structure.
func (*Db) NodeInsert ¶
NodeInsert is used to insert a node into the database
func (*Db) NodeSetCmd ¶
NodeSetCmd sets a cmd for a node, and sets the CmdPending flag in the node structure.
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) NodeUpdateGroups ¶
NodeUpdateGroups updates the groups for a 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
func (*Db) RuleDelete ¶
RuleDelete deletes a rule from the database
func (*Db) RuleInsert ¶
RuleInsert inserts a new rule
func (*Db) RuleUpdateConfig ¶
func (gen *Db) RuleUpdateConfig(id string, config data.RuleConfig) error
RuleUpdateConfig updates a rule config
func (*Db) RuleUpdateState ¶
RuleUpdateState updates a rule state
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