helpers

package
v0.0.0-...-d221b79 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddAction    = "add"
	UpdateAction = "update"
	DeleteAction = "delete"
)

A list of actions to be used in reporting

View Source
const (
	BuildingsTag = "[buildings]"
	RoomsTag     = "[rooms]"
	DevicesTag   = "[devices]"
	UIConfigsTag = "[uiconfigs]"
	OptionsTag   = "[options]"
	AlertsTag    = "[alerts]"
	MetricsTag   = "[metrics]"
	StaticTag    = "[static]"
)

A list of tags for logging

Variables

This section is empty.

Functions

func AddBulkDevices

func AddBulkDevices(devices []structs.Device) []structs.BulkUpdateResponse

AddBulkDevices adds multiples devices to the database

func GetAllAttributeGroups

func GetAllAttributeGroups() ([]structs.Group, *nerr.E)

GetAllAttributeGroups gets a list of all the attribute sets from the database

func GetAllBuildings

func GetAllBuildings() ([]structs.Building, *nerr.E)

GetAllBuildings gets all buildings from the database

func GetAllDevices

func GetAllDevices() ([]structs.Device, *nerr.E)

GetAllDevices gets all devices from the database

func GetAllRooms

func GetAllRooms() ([]structs.Room, *nerr.E)

GetAllRooms gets a list of all rooms in the database

func GetAllStaticDeviceRecords

func GetAllStaticDeviceRecords() ([]sd.StaticDevice, *nerr.E)

GetAllStaticDeviceRecords returns a list of all the static device records

func GetAllStaticRoomRecords

func GetAllStaticRoomRecords() ([]sd.StaticRoom, *nerr.E)

GetAllStaticRoomRecords returns a list of all the static room records

func GetAllUIConfigs

func GetAllUIConfigs() ([]structs.UIConfig, *nerr.E)

GetAllUIConfigs gets all uiconfigs from the database

func GetAttributeGroup

func GetAttributeGroup(groupID string) (structs.Group, *nerr.E)

GetAttributeGroup gets one attribute set from the database

func GetBuilding

func GetBuilding(buildingID string) (structs.Building, *nerr.E)

GetBuilding gets a building from the database

func GetDMPSBuildings

func GetDMPSBuildings() ([]structs.Building, *nerr.E)

GetDMPSBuildings gets the list of buildings that have DMPS systems

func GetDMPSRooms

func GetDMPSRooms() ([]structs.Room, *nerr.E)

GetDMPSRooms gets the list of rooms that have DMPS systems

func GetDevice

func GetDevice(deviceID string) (structs.Device, *nerr.E)

GetDevice gets a device from the database

func GetDeviceRawIPAddress

func GetDeviceRawIPAddress(hostname string) (string, *nerr.E)

GetDeviceRawIPAddress takes a device's hostname and return the IP address associated to it

func GetDeviceRoles

func GetDeviceRoles() ([]structs.Role, *nerr.E)

GetDeviceRoles gets a list of possible device roles

func GetDeviceTypes

func GetDeviceTypes() ([]structs.DeviceType, *nerr.E)

GetDeviceTypes gets a list of possible device types

func GetDevicesByRoom

func GetDevicesByRoom(roomID string) ([]structs.Device, *nerr.E)

GetDevicesByRoom gets all the devices in a room

func GetDevicesByRoomAndRole

func GetDevicesByRoomAndRole(roomID, roleID string) ([]structs.Device, *nerr.E)

GetDevicesByRoomAndRole gets all the devices in a room with the given role

func GetDevicesByTypeAndRole

func GetDevicesByTypeAndRole(typeID, roleID string) ([]structs.Device, *nerr.E)

GetDevicesByTypeAndRole gets all the devices of the given type that have the given role

func GetIcons

func GetIcons() ([]string, *nerr.E)

GetIcons gets a list of icons from the database

func GetMenuTree

func GetMenuTree() (structs.MenuTree, *nerr.E)

GetMenuTree returns the fully built out menu tree

func GetRoomConfigurations

func GetRoomConfigurations() ([]structs.RoomConfiguration, *nerr.E)

GetRoomConfigurations gets a list of possible room configurations

func GetRoomDesignations

func GetRoomDesignations() ([]string, *nerr.E)

GetRoomDesignations gets a list of possible room designations

func GetRoomsByBuilding

func GetRoomsByBuilding(buildingID string) ([]structs.Room, *nerr.E)

GetRoomsByBuilding gets a list of all rooms in a building

func GetStaticDeviceRecord

func GetStaticDeviceRecord(id string) (sd.StaticDevice, *nerr.E)

func GetTemplates

func GetTemplates() ([]structs.Template, *nerr.E)

GetTemplates gets a list of templates from the database

func GetUIConfig

func GetUIConfig(configID string) (structs.UIConfig, *nerr.E)

GetUIConfig gets a uiconfig from the database

func NukeRoom

func NukeRoom(id string) *nerr.E

func UpdateStaticRoom

func UpdateStaticRoom(roomID string, room sd.StaticRoom) *nerr.E

Update the static rooms (putting them in and out of maintenance mode etc.)

Types

type BuildingStatus

type BuildingStatus struct {
	BuildingID        string                `json:"building-id"`
	RoomCount         int                   `json:"room-count"`
	AlertingRoomCount int                   `json:"alerting-room-count"`
	GoodRoomCount     int                   `json:"good-room-count"`
	RoomStates        map[string]RoomStatus `json:"room-states,omitempty"`
}

BuildingStatus contains information about the status of a building

type ChangeRecord

type ChangeRecord struct {
	AttributeName string `json:"attribute_name"`
	OldValue      string `json:"old_value"`
	NewValue      string `json:"new_value"`
}

ChangeRecord contains the information about what was changed about the object when it was updated

type DBResponse

type DBResponse struct {
	ObjectID string `json:"object_id"`
	Action   string `json:"action"`
	Success  bool   `json:"success"`
	Message  string `json:"message,omitempty"`
	Error    string `json:"error,omitempty"`
}

DBResponse contains the information to be reported back upon changes being made to the database

func AddBuilding

func AddBuilding(buildingID string, building structs.Building) (DBResponse, *nerr.E)

AddBuilding adds a building to the database

func AddDevice

func AddDevice(deviceID string, device structs.Device) (DBResponse, *nerr.E)

AddDevice adds a device to the database

func AddRoom

func AddRoom(roomID string, room structs.Room) (DBResponse, *nerr.E)

AddRoom adds a room to the database

func AddUIConfig

func AddUIConfig(configID string, config structs.UIConfig) (DBResponse, *nerr.E)

AddUIConfig adds a uiconfig to the database

func DeleteBuilding

func DeleteBuilding(buildingID string) (DBResponse, *nerr.E)

DeleteBuilding deletes a building from the database

func DeleteDevice

func DeleteDevice(deviceID string) (DBResponse, *nerr.E)

DeleteDevice deletes a device from the database

func DeleteRoom

func DeleteRoom(roomID string) (DBResponse, *nerr.E)

DeleteRoom deletes a room in the database

func DeleteUIConfig

func DeleteUIConfig(configID string) (DBResponse, *nerr.E)

DeleteUIConfig deletes a uiconfig from the database

func DoUIConfigDatabaseAction

func DoUIConfigDatabaseAction(config structs.UIConfig, configID, username, action string) (DBResponse, *nerr.E)

DoUIConfigDatabaseAction performs various actions on the database

func RecordBulkDeviceChanges

func RecordBulkDeviceChanges(responses []structs.BulkUpdateResponse, username string) []DBResponse

RecordBulkDeviceChanges takes the responses from calling the CreateBulkDevices database function and makes change records for all of that information

func UpdateBuilding

func UpdateBuilding(buildingID string, building structs.Building) (DBResponse, *nerr.E)

UpdateBuilding updates a building in the database

func UpdateDevice

func UpdateDevice(deviceID string, device structs.Device) (DBResponse, *nerr.E)

UpdateDevice updates a device in the database

func UpdateRoom

func UpdateRoom(roomID string, room structs.Room) (DBResponse, *nerr.E)

UpdateRoom updates a room in the database

func UpdateUIConfig

func UpdateUIConfig(configID string, config structs.UIConfig) (DBResponse, *nerr.E)

UpdateUIConfig updates a uiconfig in the database

type MetricsResponse

type MetricsResponse struct {
	ObjectID  string         `json:"object_id"`
	Action    string         `json:"action"`
	Username  string         `json:"username"`
	Timestamp string         `json:"timestamp"`
	Changes   []ChangeRecord `json:"changes,omitempty"`
}

MetricsResponse contains the information to be reported back when asked for metrics data

type RoomCombinedState

type RoomCombinedState struct {
	RoomID           string              `json:"roomID"`
	StaticRoom       sd.StaticRoom       `json:"static-room"`
	RoomIssues       []structs.RoomIssue `json:"room-issues"`
	AllAlerts        []structs.Alert     `json:"all-alerts"`
	ActiveAlertCount int                 `json:"active-alert-count"`
	TotalAlertCount  int                 `json:"total-alert-count"`
	StaticDevices    []sd.StaticDevice   `json:"static-devices"`
}

RoomCombinedState -

func GetAllRoomCombinedStateRecords

func GetAllRoomCombinedStateRecords() ([]RoomCombinedState, *nerr.E)

GetAllRoomCombinedStateRecords returns a list of combined room state records

func GetRoomCombinedStateRecord

func GetRoomCombinedStateRecord(roomID string) (RoomCombinedState, *nerr.E)

GetRoomCombinedStateRecord returns a a single toom state record

type RoomStatus

type RoomStatus struct {
	RoomID              string                           `json:"room-id"`
	DeviceCount         int                              `json:"device-count"`
	AlertingDeviceCount int                              `json:"alerting-device-count"`
	GoodDeviceCount     int                              `json:"good-device-count"`
	Alerts              map[string]statedefinition.Alert `json:"alerts"`
	DeviceStates        []statedefinition.StaticDevice   `json:"device-states,omitempty"`
}

RoomStatus contains information about the status of a room

type RoomWithGraph

type RoomWithGraph struct {
	structs.Room
	SignalPaths map[string]map[string][]string `json:"signal-paths"`
}

func GetRoom

func GetRoom(roomID string) (RoomWithGraph, *nerr.E)

GetRoom gets a room from the database

Jump to

Keyboard shortcuts

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