Documentation ¶
Index ¶
- Constants
- func ConstructEventMappingSchema(name string, mapping map[string]interface{}) (piazza.JsonString, error)
- func IsSystemEvent(name string) bool
- func LoggedError(mssg string, args ...interface{}) error
- type Alert
- type AlertDB
- func (db *AlertDB) DeleteByID(id piazza.Ident, actor string) (bool, error)
- func (db *AlertDB) GetAlertsByDslQuery(dslString string, actor string) ([]Alert, int64, error)
- func (db *AlertDB) GetAll(format *piazza.JsonPagination, actor string) ([]Alert, int64, error)
- func (db *AlertDB) GetAllByTrigger(format *piazza.JsonPagination, triggerID piazza.Ident, actor string) ([]Alert, int64, error)
- func (db *AlertDB) GetOne(id piazza.Ident, actor string) (*Alert, bool, error)
- func (db *AlertDB) PostData(alert *Alert) error
- type AlertExt
- type Client
- func (c *Client) DeleteAlert(id piazza.Ident) error
- func (c *Client) DeleteEvent(id piazza.Ident) error
- func (c *Client) DeleteEventType(id piazza.Ident) error
- func (c *Client) DeleteTrigger(id piazza.Ident) error
- func (c *Client) GetAlert(id piazza.Ident) (*Alert, error)
- func (c *Client) GetAlertByTrigger(id piazza.Ident) (*[]Alert, error)
- func (c *Client) GetAllAlerts(perPage int, page int) (*[]Alert, error)
- func (c *Client) GetAllEventTypes(perPage, page int) (*[]EventType, error)
- func (c *Client) GetAllEvents(perPage, page int) (*[]Event, error)
- func (c *Client) GetAllEventsByEventType(eventTypeID piazza.Ident) (*[]Event, error)
- func (c *Client) GetAllTriggers(perPage int, page int) (*[]Trigger, error)
- func (c *Client) GetEvent(id piazza.Ident) (*Event, error)
- func (c *Client) GetEventType(id piazza.Ident) (*EventType, error)
- func (c *Client) GetEventTypeByName(name string) (*EventType, error)
- func (c *Client) GetNumAlerts() (int, error)
- func (c *Client) GetNumEventTypes() (int, error)
- func (c *Client) GetNumEvents() (int, error)
- func (c *Client) GetNumTriggers() (int, error)
- func (c *Client) GetStats() (*Stats, error)
- func (c *Client) GetTrigger(id piazza.Ident) (*Trigger, error)
- func (c *Client) GetVersion() (*piazza.Version, error)
- func (c *Client) PostAlert(alert *Alert) (*Alert, error)
- func (c *Client) PostEvent(event *Event) (*Event, error)
- func (c *Client) PostEventType(eventType *EventType) (*EventType, error)
- func (c *Client) PostTrigger(trigger *Trigger) (*Trigger, error)
- func (c *Client) PutAlert(alert *Alert) (*Alert, error)
- func (c *Client) PutEvent(event *Event) (*Event, error)
- func (c *Client) PutEventType(eventType *EventType) (*EventType, error)
- func (c *Client) PutTrigger(id piazza.Ident, triggerUpdate *TriggerUpdate) error
- func (c *Client) QueryAlerts(query map[string]interface{}) (*[]Alert, error)
- func (c *Client) QueryEventTypes(query map[string]interface{}) (*[]EventType, error)
- func (c *Client) QueryEvents(query map[string]interface{}) (*[]Event, error)
- func (c *Client) QueryTriggers(query map[string]interface{}) (*[]Trigger, error)
- func (c *Client) TestElasticsearchGetOne(id piazza.Ident) (*TestElasticsearchBody, error)
- func (c *Client) TestElasticsearchGetVersion() (*string, error)
- func (c *Client) TestElasticsearchPost(body *TestElasticsearchBody) (*TestElasticsearchBody, error)
- type CronDB
- type Event
- type EventDB
- func (db *EventDB) AddMapping(name string, mapping map[string]interface{}, actor string) error
- func (db *EventDB) DeleteByID(mapping string, id piazza.Ident, actor string) (bool, error)
- func (db *EventDB) GetAll(mapping string, format *piazza.JsonPagination, actor string) ([]Event, int64, error)
- func (db *EventDB) GetEventsByDslQuery(mapping string, jsnString string, actor string) ([]Event, int64, error)
- func (db *EventDB) GetEventsByEventTypeID(format *piazza.JsonPagination, mapping string, eventTypeID piazza.Ident, ...) ([]Event, int64, error)
- func (db *EventDB) GetOne(mapping string, id piazza.Ident, actor string) (*Event, bool, error)
- func (db *EventDB) NameExists(name string, actor string) (bool, error)
- func (db *EventDB) PercolateEventData(eventType string, data map[string]interface{}, id piazza.Ident, actor string) (*[]piazza.Ident, error)
- func (db *EventDB) PostData(event *Event, typ string) error
- type EventList
- type EventType
- type EventTypeDB
- func (db *EventTypeDB) DeleteByID(id piazza.Ident, actor string) (bool, error)
- func (db *EventTypeDB) GetAll(format *piazza.JsonPagination, actor string) ([]EventType, int64, error)
- func (db *EventTypeDB) GetEventTypesByDslQuery(dslString string, actor string) ([]EventType, int64, error)
- func (db *EventTypeDB) GetIDByName(format *piazza.JsonPagination, name string, actor string) (*piazza.Ident, bool, error)
- func (db *EventTypeDB) GetOne(id piazza.Ident, actor string) (*EventType, bool, error)
- func (db *EventTypeDB) PostData(eventType *EventType) error
- type EventTypeList
- type JobRequest
- type JobType
- type Kit
- type ResourceDB
- type Server
- type Service
- func (service *Service) DeleteAlert(id piazza.Ident) *piazza.JsonResponse
- func (service *Service) DeleteEvent(id piazza.Ident) *piazza.JsonResponse
- func (service *Service) DeleteEventType(id piazza.Ident) *piazza.JsonResponse
- func (service *Service) DeleteTrigger(id piazza.Ident) *piazza.JsonResponse
- func (service *Service) GetAlert(id piazza.Ident) *piazza.JsonResponse
- func (service *Service) GetAllAlerts(params *piazza.HttpQueryParams) *piazza.JsonResponse
- func (service *Service) GetAllEventTypes(params *piazza.HttpQueryParams) *piazza.JsonResponse
- func (service *Service) GetAllEvents(params *piazza.HttpQueryParams) *piazza.JsonResponse
- func (service *Service) GetAllTriggers(params *piazza.HttpQueryParams) *piazza.JsonResponse
- func (service *Service) GetEvent(id piazza.Ident) *piazza.JsonResponse
- func (service *Service) GetEventType(id piazza.Ident, actor string) *piazza.JsonResponse
- func (service *Service) GetStats() *piazza.JsonResponse
- func (service *Service) GetTrigger(id piazza.Ident) *piazza.JsonResponse
- func (service *Service) Init(sys *piazza.SystemConfig, logWriter pzsyslog.Writer, ...) error
- func (service *Service) InitCron() error
- func (service *Service) PostAlert(alert *Alert) *piazza.JsonResponse
- func (service *Service) PostEvent(event *Event) *piazza.JsonResponse
- func (service *Service) PostEventType(eventType *EventType) *piazza.JsonResponse
- func (service *Service) PostRepeatingEvent(event *Event) *piazza.JsonResponse
- func (service *Service) PostTrigger(trigger *Trigger) *piazza.JsonResponse
- func (service *Service) PutTrigger(id piazza.Ident, update *TriggerUpdate) *piazza.JsonResponse
- func (service *Service) QueryAlerts(dslString string, params *piazza.HttpQueryParams) *piazza.JsonResponse
- func (service *Service) QueryEventTypes(dslString string, params *piazza.HttpQueryParams) *piazza.JsonResponse
- func (service *Service) QueryEvents(jsonString string, params *piazza.HttpQueryParams) *piazza.JsonResponse
- func (service *Service) QueryTriggers(dslString string, params *piazza.HttpQueryParams) *piazza.JsonResponse
- func (service *Service) TestElasticsearchGetOne(id piazza.Ident) *piazza.JsonResponse
- func (service *Service) TestElasticsearchPost(body *TestElasticsearchBody) *piazza.JsonResponse
- func (service *Service) TestElasticsearchVersion() *piazza.JsonResponse
- type Stats
- type TestElasticsearchBody
- type TestElasticsearchDB
- type Trigger
- type TriggerDB
- func (db *TriggerDB) DeleteTrigger(id piazza.Ident, actor string) (bool, error)
- func (db *TriggerDB) GetAll(format *piazza.JsonPagination, actor string) ([]Trigger, int64, error)
- func (db *TriggerDB) GetOne(id piazza.Ident, actor string) (*Trigger, bool, error)
- func (db *TriggerDB) GetTriggersByDslQuery(dslString string, actor string) ([]Trigger, int64, error)
- func (db *TriggerDB) GetTriggersByEventTypeID(format *piazza.JsonPagination, id piazza.Ident, actor string) ([]Trigger, int64, error)
- func (db *TriggerDB) PostData(trigger *Trigger) error
- func (db *TriggerDB) PutTrigger(trigger *Trigger, update *TriggerUpdate, actor string) (*Trigger, error)
- type TriggerList
- type TriggerUpdate
Constants ¶
const AlertDBMapping string = "Alert"
AlertDBMapping is the name of the Elasticsearch type to which Alerts are added
const CronDBMapping = "Cron"
const EventDBMapping string = "_default_"
const EventTypeDBMapping string = "EventType"
EventTypeDBMapping is the name of the Elasticsearch type to which Events are added
const TestElasticsearchMapping = "TestElasticsearch"
const TriggerDBMapping string = "Trigger"
TriggerDBMapping is the name of the Elasticsearch type to which Triggers are added
const Version = "1.0.0"
Variables ¶
This section is empty.
Functions ¶
func IsSystemEvent ¶
IsSystemEvent returns true if the event was generated within Piazza.
TODO: Instead, check if createdBy=system
func LoggedError ¶
LoggedError logs the error's message and creates an error
Types ¶
type Alert ¶
type Alert struct { AlertID piazza.Ident `json:"alertId"` TriggerID piazza.Ident `json:"triggerId"` EventID piazza.Ident `json:"eventId"` JobID piazza.Ident `json:"jobId"` CreatedBy string `json:"createdBy"` CreatedOn piazza.TimeStamp `json:"createdOn"` }
Alert is a notification, automatically created when a Trigger happens
type AlertDB ¶
type AlertDB struct { *ResourceDB // contains filtered or unexported fields }
func NewAlertDB ¶
func NewAlertDB(service *Service, esi elasticsearch.IIndex) (*AlertDB, error)
func (*AlertDB) DeleteByID ¶
func (*AlertDB) GetAlertsByDslQuery ¶
func (*AlertDB) GetAllByTrigger ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) GetAlertByTrigger ¶
func (*Client) GetAllAlerts ¶
func (*Client) GetAllEventTypes ¶
func (*Client) GetAllEventsByEventType ¶
func (*Client) GetAllTriggers ¶
func (*Client) GetEventTypeByName ¶
func (*Client) GetNumAlerts ¶
func (*Client) GetNumEventTypes ¶
func (*Client) GetNumEvents ¶
func (*Client) GetNumTriggers ¶
func (*Client) PostEventType ¶
func (*Client) PutEventType ¶
func (*Client) PutTrigger ¶
func (c *Client) PutTrigger(id piazza.Ident, triggerUpdate *TriggerUpdate) error
func (*Client) QueryAlerts ¶
func (*Client) QueryEventTypes ¶
func (*Client) QueryEvents ¶
func (*Client) QueryTriggers ¶
func (*Client) TestElasticsearchGetOne ¶
func (c *Client) TestElasticsearchGetOne(id piazza.Ident) (*TestElasticsearchBody, error)
func (*Client) TestElasticsearchGetVersion ¶
func (*Client) TestElasticsearchPost ¶
func (c *Client) TestElasticsearchPost(body *TestElasticsearchBody) (*TestElasticsearchBody, error)
type CronDB ¶
type CronDB struct { *ResourceDB // contains filtered or unexported fields }
CronDB TODO
func NewCronDB ¶
func NewCronDB(service *Service, esi elasticsearch.IIndex) (*CronDB, error)
NewCronDB TODO
func (*CronDB) DeleteByID ¶
type Event ¶
type Event struct { EventID piazza.Ident `json:"eventId"` EventTypeID piazza.Ident `json:"eventTypeId" binding:"required"` Data map[string]interface{} `json:"data"` CreatedBy string `json:"createdBy"` CreatedOn piazza.TimeStamp `json:"createdOn"` CronSchedule string `json:"cronSchedule"` }
An Event is posted by some source (service, user, etc) to indicate Something Happened Data is specific to the event type
type EventDB ¶
type EventDB struct {
*ResourceDB
}
func NewEventDB ¶
func NewEventDB(service *Service, esi elasticsearch.IIndex) (*EventDB, error)
func (*EventDB) AddMapping ¶
func (*EventDB) DeleteByID ¶
func (*EventDB) GetEventsByDslQuery ¶
func (*EventDB) GetEventsByEventTypeID ¶
func (*EventDB) NameExists ¶
NameExists checks if an EventType name exists. This is easier to check in EventDB, as the mappings use the EventType.Name.
func (*EventDB) PercolateEventData ¶
type EventType ¶
type EventType struct { EventTypeID piazza.Ident `json:"eventTypeId"` Name string `json:"name" binding:"required"` Mapping map[string]interface{} `json:"mapping" binding:"required"` CreatedBy string `json:"createdBy"` CreatedOn piazza.TimeStamp `json:"createdOn"` }
EventType describes an Event that is to be sent to workflow by a client or service
type EventTypeDB ¶
type EventTypeDB struct { *ResourceDB // contains filtered or unexported fields }
func NewEventTypeDB ¶
func NewEventTypeDB(service *Service, esi elasticsearch.IIndex) (*EventTypeDB, error)
func (*EventTypeDB) DeleteByID ¶
func (db *EventTypeDB) DeleteByID(id piazza.Ident, actor string) (bool, error)
func (*EventTypeDB) GetAll ¶
func (db *EventTypeDB) GetAll(format *piazza.JsonPagination, actor string) ([]EventType, int64, error)
func (*EventTypeDB) GetEventTypesByDslQuery ¶
func (*EventTypeDB) GetIDByName ¶
func (db *EventTypeDB) GetIDByName(format *piazza.JsonPagination, name string, actor string) (*piazza.Ident, bool, error)
func (*EventTypeDB) GetOne ¶
func (db *EventTypeDB) GetOne(id piazza.Ident, actor string) (*EventType, bool, error)
func (*EventTypeDB) PostData ¶
func (db *EventTypeDB) PostData(eventType *EventType) error
type JobRequest ¶
type Kit ¶
type Kit struct { Service *Service Server *Server LogWriter pzsyslog.Writer AuditWriter pzsyslog.Writer Sys *piazza.SystemConfig GenericServer *piazza.GenericServer Url string // contains filtered or unexported fields }
type ResourceDB ¶
type ResourceDB struct { Esi elasticsearch.IIndex // contains filtered or unexported fields }
func NewResourceDB ¶
func NewResourceDB(service *Service, esi elasticsearch.IIndex) (*ResourceDB, error)
type Server ¶
type Server struct { Routes []piazza.RouteData // contains filtered or unexported fields }
type Service ¶
func (*Service) DeleteAlert ¶
func (service *Service) DeleteAlert(id piazza.Ident) *piazza.JsonResponse
DeleteAlert TODO
func (*Service) DeleteEvent ¶
func (service *Service) DeleteEvent(id piazza.Ident) *piazza.JsonResponse
func (*Service) DeleteEventType ¶
func (service *Service) DeleteEventType(id piazza.Ident) *piazza.JsonResponse
DeleteEventType TODO
func (*Service) DeleteTrigger ¶
func (service *Service) DeleteTrigger(id piazza.Ident) *piazza.JsonResponse
func (*Service) GetAllAlerts ¶
func (service *Service) GetAllAlerts(params *piazza.HttpQueryParams) *piazza.JsonResponse
func (*Service) GetAllEventTypes ¶
func (service *Service) GetAllEventTypes(params *piazza.HttpQueryParams) *piazza.JsonResponse
GetAllEventTypes TODO
func (*Service) GetAllEvents ¶
func (service *Service) GetAllEvents(params *piazza.HttpQueryParams) *piazza.JsonResponse
GetAllEvents TODO
func (*Service) GetAllTriggers ¶
func (service *Service) GetAllTriggers(params *piazza.HttpQueryParams) *piazza.JsonResponse
func (*Service) GetEvent ¶
func (service *Service) GetEvent(id piazza.Ident) *piazza.JsonResponse
GetEvent TODO
func (*Service) GetEventType ¶
GetEventType TODO
func (*Service) GetTrigger ¶
func (service *Service) GetTrigger(id piazza.Ident) *piazza.JsonResponse
func (*Service) Init ¶
func (service *Service) Init( sys *piazza.SystemConfig, logWriter pzsyslog.Writer, auditWriter pzsyslog.Writer, indices *map[string]elasticsearch.IIndex, pen string, ) error
Init TODO
func (*Service) PostEventType ¶
PostEventType TODO
func (*Service) PostRepeatingEvent ¶
PostRepeatingEvent deals with events that have a "CronSchedule" field specified. This field is checked for validity, and then set up to repeat at the interval specified by the CronSchedule. The createdBy field of each subsequent event is filled with the eventId of this initial event, so that searching for events created by the initial event is easier.
func (*Service) PostTrigger ¶
func (*Service) PutTrigger ¶
func (service *Service) PutTrigger(id piazza.Ident, update *TriggerUpdate) *piazza.JsonResponse
func (*Service) QueryAlerts ¶
func (*Service) QueryEventTypes ¶
func (*Service) QueryEvents ¶
func (*Service) QueryTriggers ¶
func (*Service) TestElasticsearchGetOne ¶
func (service *Service) TestElasticsearchGetOne(id piazza.Ident) *piazza.JsonResponse
func (*Service) TestElasticsearchPost ¶
func (service *Service) TestElasticsearchPost(body *TestElasticsearchBody) *piazza.JsonResponse
func (*Service) TestElasticsearchVersion ¶
func (service *Service) TestElasticsearchVersion() *piazza.JsonResponse
type Stats ¶
type Stats struct { CreatedOn piazza.TimeStamp `json:"createdOn"` NumEventTypes int `json:"numEventTypes"` NumEvents int `json:"numEvents"` NumTriggers int `json:"numTriggers"` NumAlerts int `json:"numAlerts"` NumTriggeredJobs int `json:"numTriggeredJobs"` }
func (*Stats) IncrAlerts ¶
func (stats *Stats) IncrAlerts()
func (*Stats) IncrEventTypes ¶
func (stats *Stats) IncrEventTypes()
func (*Stats) IncrEvents ¶
func (stats *Stats) IncrEvents()
func (*Stats) IncrTriggerJobs ¶
func (stats *Stats) IncrTriggerJobs()
func (*Stats) IncrTriggers ¶
func (stats *Stats) IncrTriggers()
type TestElasticsearchBody ¶
type TestElasticsearchBody struct { ID piazza.Ident `json:"id"` Value int `json:"value"` }
type TestElasticsearchDB ¶
type TestElasticsearchDB struct { *ResourceDB // contains filtered or unexported fields }
func NewTestElasticsearchDB ¶
func NewTestElasticsearchDB(service *Service, esi elasticsearch.IIndex) (*TestElasticsearchDB, error)
func (*TestElasticsearchDB) GetOne ¶
func (db *TestElasticsearchDB) GetOne(id piazza.Ident) (*TestElasticsearchBody, bool, error)
func (*TestElasticsearchDB) GetVersion ¶
func (db *TestElasticsearchDB) GetVersion() (string, error)
func (*TestElasticsearchDB) PostData ¶
func (db *TestElasticsearchDB) PostData(obj interface{}, id piazza.Ident) (piazza.Ident, error)
type Trigger ¶
type Trigger struct { TriggerID piazza.Ident `json:"triggerId"` Name string `json:"name" binding:"required"` EventTypeID piazza.Ident `json:"eventTypeId" binding:"required"` Condition map[string]interface{} `json:"condition" binding:"required"` Job JobRequest `json:"job" binding:"required"` PercolationID piazza.Ident `json:"percolationId"` CreatedBy string `json:"createdBy"` CreatedOn piazza.TimeStamp `json:"createdOn"` Enabled bool `json:"enabled"` }
Trigger does something when the and'ed set of Conditions all are true Events are the results of the Conditions queries Job is the JobMessage to submit back to Pz
type TriggerDB ¶
type TriggerDB struct { *ResourceDB // contains filtered or unexported fields }
func NewTriggerDB ¶
func NewTriggerDB(service *Service, esi elasticsearch.IIndex) (*TriggerDB, error)
func (*TriggerDB) DeleteTrigger ¶
func (*TriggerDB) GetTriggersByDslQuery ¶
func (*TriggerDB) GetTriggersByEventTypeID ¶
func (*TriggerDB) PutTrigger ¶
type TriggerUpdate ¶
type TriggerUpdate struct {
Enabled bool `json:"enabled"`
}