Documentation ¶
Index ¶
- func GetKey(entityType string, keyPart ...string) string
- type Event
- type Manager
- func (store Manager) AddEvent(eventtype, triggertype, details string, ip string, expiresafter time.Duration) (Event, error)
- func (store Manager) AddTrigger(name, description string, gpiopin int, webhooks []WebHook, minimumsleep int) (Trigger, error)
- func (store Manager) Close() error
- func (store Manager) DeleteTrigger(id string) error
- func (store Manager) GetAllEvents() ([]Event, error)
- func (store Manager) GetAllTriggers() ([]Trigger, error)
- func (store Manager) GetEvent(id string) (Event, error)
- func (store Manager) GetTrigger(id string) (Trigger, error)
- func (store Manager) UpdateTrigger(updatedTrigger Trigger) (Trigger, error)
- type Trigger
- type WebHook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
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) DeleteTrigger ¶ added in v1.0.6
DeleteTrigger deletes a trigger from the system
func (Manager) GetAllEvents ¶ added in v1.0.10
GetAllEvents gets all events in the system
func (Manager) GetAllTriggers ¶ added in v1.0.6
GetAllTriggers gets all triggers in the system
func (Manager) GetTrigger ¶ added in v1.0.6
GetTrigger gets information about a single trigger in the system based on its id
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