data

package
v1.0.50 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetKey

func GetKey(entityType string, keyPart ...string) string

GetKey returns a key to be used in the storage system

Types

type Event added in v1.0.9

type Event struct {
	ID          string    `json:"id"`          // Unique Event ID
	Created     time.Time `json:"created"`     // Event creation time
	SourceIP    string    `json:"ip"`          // Source IP address of the event
	EventType   string    `json:"eventtype"`   // One of: System startup, Trigger created, Trigger fired, Trigger deleted, System shutdown
	TriggerType string    `json:"triggertype"` // The type of trigger involved: Motion, Button, Time
	Details     string    `json:"details"`     // Additional information (like the trigger name involved)
}

Event represents an event in the system. These events can be logged or passed (as meta information) to other systems

type Manager

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

Manager is the data manager

func NewManager

func NewManager(systemdbpath string) (*Manager, error)

NewManager creates a new instance of a Manager and returns it

func (Manager) AddEvent added in v1.0.10

func (store Manager) AddEvent(eventtype, triggertype, details string, ip string, expiresafter time.Duration) (Event, error)

AddEvent adds an event to the system

func (Manager) AddTrigger added in v1.0.5

func (store Manager) AddTrigger(name, description string, gpiopin int, webhooks []WebHook, minimumsleep int) (Trigger, error)

AddTrigger adds a trigger to the system

func (Manager) Close

func (store Manager) Close() error

Close closes the data Manager

func (Manager) DeleteTrigger added in v1.0.6

func (store Manager) DeleteTrigger(id string) error

DeleteTrigger deletes a trigger from the system

func (Manager) GetAllEvents added in v1.0.10

func (store Manager) GetAllEvents() ([]Event, error)

GetAllEvents gets all events in the system

func (Manager) GetAllTriggers added in v1.0.6

func (store Manager) GetAllTriggers() ([]Trigger, error)

GetAllTriggers gets all triggers in the system

func (Manager) GetEvent added in v1.0.10

func (store Manager) GetEvent(id string) (Event, error)

GetEvent gets an event from the system

func (Manager) GetTrigger added in v1.0.6

func (store Manager) GetTrigger(id string) (Trigger, error)

GetTrigger gets information about a single trigger in the system based on its id

func (Manager) UpdateTrigger added in v1.0.18

func (store Manager) UpdateTrigger(updatedTrigger Trigger) (Trigger, error)

AddTrigger adds a trigger to the system

type Trigger added in v1.0.5

type Trigger struct {
	ID                            string    `json:"id"`                            // Unique Trigger ID
	Enabled                       bool      `json:"enabled"`                       // Trigger enabled or not
	Created                       time.Time `json:"created"`                       // Trigger create time
	Name                          string    `json:"name"`                          // The trigger name
	Description                   string    `json:"description"`                   // Additional information about the trigger
	GPIOPin                       int       `json:"gpiopin"`                       // The GPIO pin the sensor or button is on
	WebHooks                      []WebHook `json:"webhooks"`                      // The webhooks to send when triggered
	MinimumSecondsBeforeRetrigger int       `json:"minimumsecondsbeforeretrigger"` // Minimum time (in seconds) before a retrigger
}

Trigger represents sensor/button trigger information.

type WebHook added in v1.0.5

type WebHook struct {
	URL     string            `json:"url"`               // The URL to connect to
	Headers map[string]string `json:"headers,omitempty"` // The HTTP headers to send
	Body    []byte            `json:"body,omitempty"`    // The HTTP body to send.  This can be empty
}

WebHook represents a notification message sent to an endpoint It's always content type: application/json It's always HTTP verb POST

Jump to

Keyboard shortcuts

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