types

package
v0.0.0-...-2bc910a Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// ResourceVersion is the current event resource version
	ResourceVersion = "v2"
	// KindEvent is the event resource kind
	KindEvent = "event"
	// EventTypeServer is the server-related event type
	EventTypeServer = "server"
	// EventTypeUser is the user-related event type
	EventTypeUser = "user"
	// EventActionLogin is the event login action
	EventActionLogin = "login"
	// KindHeartbeat is the heartbeat resource kind
	KindHeartbeat = "heartbeat"
	// NotificationUsage is the usage limit notification type
	NotificationUsage = "usage"
	// NotificationTerms is the terms of service violation notification type
	NotificationTerms = "terms"
	// SeverityInfo is info notification severity
	SeverityInfo = "info"
	// SeverityWarning is warning notification severity
	SeverityWarning = "warning"
	// SeverityError is error notification severity
	SeverityError = "error"
)

Variables

This section is empty.

Functions

func MarshalHeartbeat

func MarshalHeartbeat(h Heartbeat) ([]byte, error)

MarshalHeartbeat marshals heartbeat with schema validation

func ToGRPCEvent

func ToGRPCEvent(event Event) (*reporting.GRPCEvent, error)

ToGRPCEvent converts provided event to the format used by gRPC server/client

Types

type Event

type Event interface {
	// GetName returns the event name
	GetName() string
	// GetMetadata returns the event metadata
	GetMetadata() Metadata
	// SetAccountID sets the event account ID
	SetAccountID(string)
}

Event defines an interface all event types should implement

func FromGRPCEvent

func FromGRPCEvent(grpcEvent reporting.GRPCEvent) (Event, error)

FromGRPCEvent converts event from the format used by gRPC server/client

func FromGRPCEvents

func FromGRPCEvents(grpcEvents reporting.GRPCEvents) ([]Event, error)

FromGRPCEvents converts a series of events from the format used by gRPC server/client

type Heartbeat

type Heartbeat struct {
	// Kind is resource kind, for heartbeat it is "heartbeat"
	Kind string `json:"kind"`
	// Version is the heartbeat resource version
	Version string `json:"version"`
	// Metadata is the heartbeat metadata
	Metadata Metadata `json:"metadata"`
	// Spec is the heartbeat spec
	Spec HeartbeatSpec `json:"spec"`
}

Heartbeat represents a heartbeat that is sent from control plane to teleport

func NewHeartbeat

func NewHeartbeat(notifications ...Notification) *Heartbeat

NewHeartbeat returns a new heartbeat

func UnmarshalHeartbeat

func UnmarshalHeartbeat(bytes []byte) (*Heartbeat, error)

UnmarshalHeartbeat unmarshals heartbeat with schema validation

func (*Heartbeat) GetMetadata

func (h *Heartbeat) GetMetadata() Metadata

GetMetadata returns the heartbeat metadata

func (*Heartbeat) GetName

func (h *Heartbeat) GetName() string

GetName returns the resource name

type HeartbeatSpec

type HeartbeatSpec struct {
	// Notifications is a list of notifications sent with the heartbeat
	Notifications []Notification `json:"notifications,omitempty"`
}

HeartbeatSpec is the heartbeat resource spec

type Metadata

type Metadata struct {
	// Name is the event name
	Name string `json:"name"`
	// Created is the event creation timestamp
	Created time.Time `json:"created"`
}

Metadata represents event resource metadata

type Notification

type Notification struct {
	// Type is the notification type
	Type string `json:"type"`
	// Severity is the notification severity: info, warning or error
	Severity string `json:"severity"`
	// Text is the notification plain text
	Text string `json:"text"`
	// HTML is the notification HTML
	HTML string `json:"html"`
}

Notification represents a user notification message

type ServerEvent

type ServerEvent struct {
	// Kind is resource kind, for events it is "event"
	Kind string `json:"kind"`
	// Version is the event resource version
	Version string `json:"version"`
	// Metadata is the event metadata
	Metadata Metadata `json:"metadata"`
	// Spec is the event spec
	Spec ServerEventSpec `json:"spec"`
}

ServerEvent represents server-related event, such as "logged into server"

func NewServerLoginEvent

func NewServerLoginEvent(serverID string) *ServerEvent

NewServerLoginEvent creates an instance of "server login" event

func (*ServerEvent) GetMetadata

func (e *ServerEvent) GetMetadata() Metadata

GetMetadata returns the event metadata

func (*ServerEvent) GetName

func (e *ServerEvent) GetName() string

GetName returns the event name

func (*ServerEvent) SetAccountID

func (e *ServerEvent) SetAccountID(id string)

SetAccountID sets the event account ID

type ServerEventSpec

type ServerEventSpec struct {
	// ID is event ID, may be used for de-duplication
	ID string `json:"id"`
	// Action is event action, such as "login"
	Action string `json:"action"`
	// AccountID is ID of account that triggered the event
	AccountID string `json:"accountID"`
	// ServerID is anonymized ID of server that triggered the event
	ServerID string `json:"serverID"`
}

ServerEventSpec is server event specification

type UserEvent

type UserEvent struct {
	// Kind is resource kind, for events it is "event"
	Kind string `json:"kind"`
	// Version is the event resource version
	Version string `json:"version"`
	// Metadata is the event metadata
	Metadata Metadata `json:"metadata"`
	// Spec is the event spec
	Spec UserEventSpec `json:"spec"`
}

UserEvent represents user-related event, such as "user logged in"

func NewUserLoginEvent

func NewUserLoginEvent(userID string) *UserEvent

NewUserLoginEvent creates an instance of "user login" event

func (*UserEvent) GetMetadata

func (e *UserEvent) GetMetadata() Metadata

GetMetadata returns the event metadata

func (*UserEvent) GetName

func (e *UserEvent) GetName() string

GetName returns the event name

func (*UserEvent) SetAccountID

func (e *UserEvent) SetAccountID(id string)

SetAccountID sets the event account id

type UserEventSpec

type UserEventSpec struct {
	// ID is event ID, may be used for de-duplication
	ID string `json:"id"`
	// Action is event action, such as "login"
	Action string `json:"action"`
	// AccountID is ID of account that triggered the event
	AccountID string `json:"accountID"`
	// UserID is anonymized ID of user that triggered the event
	UserID string `json:"userID"`
}

UserEventSpec is user event specification

Jump to

Keyboard shortcuts

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