pattern

package
v0.0.0-...-8cc84bd Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package pattern implements the patterns allowing to select the events to which a rule is applied.

Each file defines the pattern for certain type of values. For example, event.go defines the EventPattern that can be applied to events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlarmFields

type AlarmFields struct {
	ID       StringPattern     `bson:"_id"`
	Time     TimePattern       `bson:"t"`
	EntityID StringPattern     `bson:"d"`
	Value    AlarmValuePattern `bson:"v"`

	// When unmarshalling a BSON document, the fields of this document that are
	// not defined in this struct are added to UnexpectedFields.
	UnexpectedFields map[string]interface{} `bson:",inline"`
}

AlarmFields is a type representing a pattern that can be applied to an alarm

func (AlarmFields) AsMongoQuery

func (p AlarmFields) AsMongoQuery() bson.M

AsMongoQuery returns a mongodb filter from the AlarmFields

type AlarmPattern

type AlarmPattern struct {
	// ShouldNotBeNil is a boolean indicating that the alarm should not be nil,
	// and ShouldBeNil is a boolean indicating that the alarm should be nil.
	// The two booleans are needed to be able to make the difference between
	// the case where no alarm pattern was defined (in which case the alarm can
	// be nil or not), the case where a nil alarm pattern was defined (in which
	// case the alarm should be nil), and the case where a non-nil alarm
	// pattern was defined (in which case the alarm should not be nil).
	ShouldNotBeNil bool
	ShouldBeNil    bool

	AlarmFields
}

AlarmPattern is a type representing a pattern that can be applied to an alarm

func (AlarmPattern) AsMongoQuery

func (p AlarmPattern) AsMongoQuery() bson.M

AsMongoQuery returns a mongodb filter from the AlarmPattern

func (AlarmPattern) Matches

func (p AlarmPattern) Matches(alarm *types.Alarm, matches *AlarmRegexMatches) bool

Matches returns true if an alarm is matched by a pattern. If the pattern contains regular expressions with sub-expressions, the values of the sub-expressions are written in the matches argument.

func (*AlarmPattern) SetBSON

func (p *AlarmPattern) SetBSON(raw bson.Raw) error

SetBSON unmarshals a BSON value into an AlarmPattern.

type AlarmPatternList

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

AlarmPatternList is a type representing a list of alarm patterns. An alarm is matched by an AlarmPatternList if it is matched by one of its AlarmPatterns. The zero value of an AlarmPatternList (i.e. an AlarmPatternList that has not been set) is considered valid, and matches all alarms.

func (AlarmPatternList) AsMongoQuery

func (l AlarmPatternList) AsMongoQuery() bson.M

AsMongoQuery returns a mongodb filter from the AlarmPatternList

func (AlarmPatternList) IsSet

func (l AlarmPatternList) IsSet() bool

IsSet returns true if the AlarmPatternList has been set explicitly.

func (AlarmPatternList) IsValid

func (l AlarmPatternList) IsValid() bool

IsValid returns true if the AlarmPatternList is valid.

func (AlarmPatternList) Matches

func (l AlarmPatternList) Matches(alarm *types.Alarm) bool

Matches returns true if the alarm is matched by the AlarmPatternList.

func (*AlarmPatternList) SetBSON

func (l *AlarmPatternList) SetBSON(raw bson.Raw) error

SetBSON unmarshals a BSON value into a AlarmPatternList. If it cannot be unmarshalled, it is marked as invalid.

type AlarmRegexMatches

type AlarmRegexMatches struct {
	ID       RegexMatches
	EntityID RegexMatches
	Value    AlarmValueRegexMatches
}

AlarmRegexMatches is a type that contains the values of the sub-expressions of regular expressions for each of the fields of an Alarm that contain strings.

func NewAlarmRegexMatches

func NewAlarmRegexMatches() AlarmRegexMatches

NewAlarmRegexMatches creates an AlarmValueRegexMatches, with the Value.Extra field initialized to an empty map.

type AlarmStepFields

type AlarmStepFields struct {
	Type      StringPattern  `bson:"_t"`
	Timestamp TimePattern    `bson:"t"`
	Author    StringPattern  `bson:"a"`
	Message   StringPattern  `bson:"m"`
	Value     IntegerPattern `bson:"val"`

	// When unmarshalling a BSON document, the fields of this document that are
	// not defined in this struct are added to UnexpectedFields.
	UnexpectedFields map[string]interface{} `bson:",inline"`
}

AlarmStepFields is a type representing a pattern that can be applied to an alarm step. The fields are not defined directly in the AlarmStepRefPattern struct to make the unmarshalling easier.

type AlarmStepRefPattern

type AlarmStepRefPattern struct {
	// ShouldNotBeNil is a boolean indicating that the alarm step should not be
	// nil, and ShouldBeNil is a boolean indicating that the alarm step should
	// be nil.
	// The two booleans are needed to be able to make the difference between
	// the case where no pattern was defined (in which case the alarm step can
	// be nil or not), the case where a nil pattern was defined (in which case
	// the alarm step should be nil), and the case where a non-nil pattern was
	// defined (in which case the alarm step should not be nil).
	ShouldNotBeNil bool
	ShouldBeNil    bool

	AlarmStepFields
}

AlarmStepRefPattern is a type representing a pattern that can be applied to a reference to an alarm step.

func (AlarmStepRefPattern) AsMongoQuery

func (p AlarmStepRefPattern) AsMongoQuery(prefix string, query bson.M)

AsMongoQuery returns a mongodb filter corresponding to the AlarmStepRefPattern.

func (AlarmStepRefPattern) Empty

func (p AlarmStepRefPattern) Empty() bool

Empty returns true if the pattern has not been set

func (AlarmStepRefPattern) Matches

func (p AlarmStepRefPattern) Matches(step *types.AlarmStep, matches *AlarmStepRegexMatches) bool

Matches returns true if an alarm step is matched by a pattern. If the pattern contains regular expressions with sub-expressions, the values of the sub-expressions are written in the matches argument.

func (*AlarmStepRefPattern) SetBSON

func (p *AlarmStepRefPattern) SetBSON(raw bson.Raw) error

SetBSON unmarshals a BSON value into an AlarmStepRefPattern.

type AlarmStepRegexMatches

type AlarmStepRegexMatches struct {
	Type    RegexMatches
	Author  RegexMatches
	Message RegexMatches
}

AlarmStepRegexMatches is a type that contains the values of the sub-expressions of regular expressions for each of the fields of an AlarmStep that contain strings.

type AlarmTicketFields

type AlarmTicketFields struct {
	Type      StringPattern `bson:"_t"`
	Timestamp TimePattern   `bson:"t"`
	Author    StringPattern `bson:"a"`
	Message   StringPattern `bson:"m"`
	Value     StringPattern `bson:"val"`

	// When unmarshalling a BSON document, the fields of this document that are
	// not defined in this struct are added to UnexpectedFields.
	UnexpectedFields map[string]interface{} `bson:",inline"`
}

AlarmTicketFields is a type representing a pattern that can be applied to an alarm ticket step. The fields are not defined directly in the AlarmTicketRefPattern struct to make the unmarshalling easier.

type AlarmTicketRefPattern

type AlarmTicketRefPattern struct {
	// ShouldNotBeNil is a boolean indicating that the alarm step should not be
	// nil, and ShouldBeNil is a boolean indicating that the alarm step should
	// be nil.
	// The two booleans are needed to be able to make the difference between
	// the case where no pattern was defined (in which case the alarm step can
	// be nil or not), the case where a nil pattern was defined (in which case
	// the alarm step should be nil), and the case where a non-nil pattern was
	// defined (in which case the alarm step should not be nil).
	ShouldNotBeNil bool
	ShouldBeNil    bool

	AlarmTicketFields
}

AlarmTicketRefPattern is a type representing a pattern that can be applied to a reference to an alarm ticket step.

func (AlarmTicketRefPattern) AsMongoQuery

func (p AlarmTicketRefPattern) AsMongoQuery(prefix string, query bson.M)

AsMongoQuery returns a mongodb filter corresponding to the AlarmTicketRefPattern.

func (AlarmTicketRefPattern) Empty

func (p AlarmTicketRefPattern) Empty() bool

Empty returns true if the pattern has not been set

func (AlarmTicketRefPattern) Matches

Matches returns true if an alarm ticket step is matched by a pattern. If the pattern contains regular expressions with sub-expressions, the values of the sub-expressions are written in the matches argument.

func (*AlarmTicketRefPattern) SetBSON

func (p *AlarmTicketRefPattern) SetBSON(raw bson.Raw) error

SetBSON unmarshals a BSON value into an AlarmTicketRefPattern.

type AlarmTicketRegexMatches

type AlarmTicketRegexMatches struct {
	Type    RegexMatches
	Author  RegexMatches
	Message RegexMatches
	Value   RegexMatches
}

AlarmTicketRegexMatches is a type that contains the values of the sub-expressions of regular expressions for each of the fields of an AlarmTicket that contain strings.

type AlarmValueFields

type AlarmValueFields struct {
	ACK                           AlarmStepRefPattern         `bson:"ack,omitempty"`
	Canceled                      AlarmStepRefPattern         `bson:"canceled,omitempty"`
	Done                          AlarmStepRefPattern         `bson:"done,omitempty"`
	Snooze                        AlarmStepRefPattern         `bson:"snooze,omitempty"`
	State                         AlarmStepRefPattern         `bson:"state,omitempty"`
	Status                        AlarmStepRefPattern         `bson:"status,omitempty"`
	Ticket                        AlarmTicketRefPattern       `bson:"ticket,omitempty"`
	Component                     StringPattern               `bson:"component"`
	Connector                     StringPattern               `bson:"connector"`
	ConnectorName                 StringPattern               `bson:"connector_name"`
	CreationDate                  TimePattern                 `bson:"creation_date"`
	DisplayName                   StringPattern               `bson:"display_name"`
	Extra                         map[string]InterfacePattern `bson:"extra"`
	HardLimit                     IntegerRefPattern           `bson:"hard_limit,omitempty"`
	InitialOutput                 StringPattern               `bson:"initial_output"`
	Output                        StringPattern               `bson:"output"`
	InitialLongOutput             StringPattern               `bson:"initial_long_output"`
	LongOutput                    StringPattern               `bson:"long_output"`
	LastUpdateDate                TimePattern                 `bson:"last_update_date"`
	LastEventDate                 TimePattern                 `bson:"last_event_date"`
	Resource                      StringPattern               `bson:"resource,omitempty"`
	Resolved                      TimeRefPattern              `bson:"resolved,omitempty"`
	StateChangesSinceStatusUpdate IntegerPattern              `bson:"state_changes_since_status_update,omitempty"`
	TotalStateChanges             IntegerPattern              `bson:"total_state_changes,omitempty"`

	// When unmarshalling a BSON document, the fields of this document that are
	// not defined in this struct are added to UnexpectedFields.
	UnexpectedFields map[string]interface{} `bson:",inline"`
}

AlarmValueFields is a type representing a pattern that can be applied to an alarm value. The fields are not defined directly in the AlarmValuePattern struct to make the unmarshalling easier.

func (AlarmValueFields) Empty

func (p AlarmValueFields) Empty() bool

Empty returns true if the pattern has not been set

type AlarmValuePattern

type AlarmValuePattern struct {
	AlarmValueFields
}

AlarmValuePattern is a type representing a pattern that can be applied to an alarm value

func (AlarmValuePattern) AsMongoQuery

func (p AlarmValuePattern) AsMongoQuery(prefix string, query bson.M)

AsMongoQuery returns a mongodb filter from the AlarmValuePattern

func (AlarmValuePattern) Matches

func (p AlarmValuePattern) Matches(value types.AlarmValue, matches *AlarmValueRegexMatches) bool

Matches returns true if an alarm value is matched by a pattern. If the pattern contains regular expressions with sub-expressions, the values of the sub-expressions are written in the matches argument.

func (*AlarmValuePattern) SetBSON

func (p *AlarmValuePattern) SetBSON(raw bson.Raw) error

SetBSON unmarshals a BSON value into an AlarmValuePattern.

type AlarmValueRegexMatches

type AlarmValueRegexMatches struct {
	ACK               AlarmStepRegexMatches
	Canceled          AlarmStepRegexMatches
	Done              AlarmStepRegexMatches
	Snooze            AlarmStepRegexMatches
	State             AlarmStepRegexMatches
	Status            AlarmStepRegexMatches
	Ticket            AlarmTicketRegexMatches
	Component         RegexMatches
	Connector         RegexMatches
	ConnectorName     RegexMatches
	DisplayName       RegexMatches
	Extra             map[string]RegexMatches
	InitialOutput     RegexMatches
	Output            RegexMatches
	InitialLongOutput RegexMatches
	LongOutput        RegexMatches
	Resource          RegexMatches
}

AlarmValueRegexMatches is a type that contains the values of the sub-expressions of regular expressions for each of the fields of an AlarmValue that contain strings.

func NewAlarmValueRegexMatches

func NewAlarmValueRegexMatches() AlarmValueRegexMatches

NewAlarmValueRegexMatches creates an AlarmValueRegexMatches, with the Extra field initialized to an empty map.

type BoolPattern

type BoolPattern struct {
	utils.OptionalBool
}

BoolPattern is a type representing a pattern that can be applied to the value of a field of an event that contains a boolean.

func (BoolPattern) AsMongoQuery

func (p BoolPattern) AsMongoQuery() bson.M

AsMongoQuery returns a mongodb filter from the BoolPattern

func (BoolPattern) Empty

func (p BoolPattern) Empty() bool

Empty returns true if the condition has not been set.

func (BoolPattern) Matches

func (p BoolPattern) Matches(value bool) bool

Matches returns true if the value is matched by the pattern.

type EntityFields

type EntityFields struct {
	ID      StringPattern          `bson:"_id"`
	Name    StringPattern          `bson:"name"`
	Enabled BoolPattern            `bson:"enabled"`
	Infos   map[string]InfoPattern `bson:"infos"`
	Type    StringPattern          `bson:"type"`

	// When unmarshalling a BSON document, the fields of this document that are
	// not defined in this struct are added to UnexpectedFields.
	UnexpectedFields map[string]interface{} `bson:",inline"`
}

EntityFields is a type representing a pattern that can be applied to an entity

func (EntityFields) AsMongoQuery

func (e EntityFields) AsMongoQuery() bson.M

AsMongoQuery returns a mongodb filter from the EntityFields

type EntityPattern

type EntityPattern struct {
	// ShouldNotBeNil is a boolean indicating that the entity should not be
	// nil, and ShouldBeNil is a boolean indicating that the entity should be
	// nil.
	// The two booleans are needed to be able to make the difference between
	// the case where no entity pattern was defined (in which case the entity
	// can be nil or not), the case where a nil entity pattern was defined (in
	// which case the entity should be nil), and the case where a non-nil
	// entity pattern was defined (in which case the entity should not be nil).
	ShouldNotBeNil bool
	ShouldBeNil    bool

	EntityFields
}

EntityPattern is a type representing a pattern that can be applied to an entity

func (EntityPattern) AsMongoQuery

func (e EntityPattern) AsMongoQuery() bson.M

AsMongoQuery returns a mongodb filter from the EntityPattern

func (EntityPattern) Matches

func (p EntityPattern) Matches(entity *types.Entity, matches *EntityRegexMatches) bool

Matches returns true if an entity is matched by a pattern. If the pattern contains regular expressions with sub-expressions, the values of the sub-expressions are written in the matches argument.

func (*EntityPattern) SetBSON

func (p *EntityPattern) SetBSON(raw bson.Raw) error

SetBSON unmarshals a BSON value into an EntityPattern.

type EntityPatternList

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

EntityPatternList is a type representing a list of entity patterns. An entity is matched by an EntityPatternList if it is matched by one of its EntityPatterns. The zero value of an EntityPatternList (i.e. an EntityPatternList that has not been set) is considered valid, and matches all entities.

func (EntityPatternList) AsMongoQuery

func (l EntityPatternList) AsMongoQuery() bson.M

AsMongoQuery returns a mongodb filter from the EntityPatternList

func (EntityPatternList) IsSet

func (l EntityPatternList) IsSet() bool

IsSet returns true if the EntityPatternList has been set explicitly.

func (EntityPatternList) IsValid

func (l EntityPatternList) IsValid() bool

IsValid returns true if the EntityPatternList is valid.

func (EntityPatternList) Matches

func (l EntityPatternList) Matches(entity *types.Entity) bool

Matches returns true if the entity is matched by the EntityPatternList.

func (*EntityPatternList) SetBSON

func (l *EntityPatternList) SetBSON(raw bson.Raw) error

SetBSON unmarshals a BSON value into a EntityPatternList. If it cannot be unmarshalled, it is marked as invalid.

type EntityRegexMatches

type EntityRegexMatches struct {
	ID    RegexMatches
	Name  RegexMatches
	Infos map[string]InfoRegexMatches
	Type  RegexMatches
}

EntityRegexMatches is a type that contains the values of the sub-expressions of regular expressions for each of the fields of an Entity that contain strings.

func NewEntityRegexMatches

func NewEntityRegexMatches() EntityRegexMatches

NewEntityRegexMatches creates an EntityRegexMatches, with the Infos field initialized to an empty map.

type EventPattern

type EventPattern struct {
	ID            StringRefPattern            `bson:"_id"`
	Connector     StringPattern               `bson:"connector"`
	ConnectorName StringPattern               `bson:"connector_name"`
	EventType     StringPattern               `bson:"event_type"`
	Component     StringPattern               `bson:"component"`
	Resource      StringPattern               `bson:"resource"`
	PerfData      StringRefPattern            `bson:"perf_data"`
	Status        IntegerRefPattern           `bson:"status"`
	Timestamp     TimePattern                 `bson:"timestamp"`
	StateType     IntegerRefPattern           `bson:"state_type"`
	SourceType    StringPattern               `bson:"source_type"`
	LongOutput    StringPattern               `bson:"long_output"`
	State         IntegerPattern              `bson:"state"`
	Output        StringPattern               `bson:"output"`
	Entity        EntityPattern               `bson:"current_entity"`
	Author        StringPattern               `bson:"author"`
	RK            StringPattern               `bson:"routing_key"`
	AckResources  BoolPattern                 `bson:"ack_resources"`
	Duration      IntegerRefPattern           `bson:"duration"`
	Ticket        StringPattern               `bson:"ticket"`
	StatName      StringPattern               `bson:"stat_name"`
	Debug         BoolPattern                 `bson:"debug"`
	ExtraInfos    map[string]InterfacePattern `bson:",inline"`
}

EventPattern is a type representing a pattern that can be applied to an event

func (EventPattern) Matches

func (p EventPattern) Matches(event types.Event, matches *EventRegexMatches) bool

Matches returns true if an event is matched by a pattern. If the pattern contains regular expressions with sub-expressions, the values of the sub-expressions are written in the matches argument.

type EventPatternList

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

EventPatternList is a type representing a list of event patterns. An event is matched by an EventPatternList if it is matched by one of its EventPatterns. The zero value of an EventPatternList (i.e. an EventPatternList that has not been set) is considered valid, and matches all events.

func (EventPatternList) IsSet

func (l EventPatternList) IsSet() bool

IsSet returns true if the EventPatternList has been set explicitly.

func (EventPatternList) IsValid

func (l EventPatternList) IsValid() bool

IsValid returns true if the EventPatternList is valid.

func (EventPatternList) Matches

func (l EventPatternList) Matches(event types.Event) bool

Matches returns true if the event is matched by the EventPatternList.

func (*EventPatternList) SetBSON

func (l *EventPatternList) SetBSON(raw bson.Raw) error

SetBSON unmarshals a BSON value into a EventPatternList. If it cannot be unmarshalled, it is marked as invalid.

type EventRegexMatches

type EventRegexMatches struct {
	ID            RegexMatches
	Connector     RegexMatches
	ConnectorName RegexMatches
	EventType     RegexMatches
	Component     RegexMatches
	Resource      RegexMatches
	PerfData      RegexMatches
	SourceType    RegexMatches
	LongOutput    RegexMatches
	Output        RegexMatches
	Entity        EntityRegexMatches
	Author        RegexMatches
	RK            RegexMatches
	Ticket        RegexMatches
	StatName      RegexMatches
	ExtraInfos    map[string]RegexMatches
}

EventRegexMatches is a type that contains the values of the sub-expressions of regular expressions for each of the fields of an Event that contain strings.

func NewEventRegexMatches

func NewEventRegexMatches() EventRegexMatches

NewEventRegexMatches creates an EventRegexMatches, with the Entity field initialized.

type InfoFields

type InfoFields struct {
	Name        StringPattern `bson:"name"`
	Description StringPattern `bson:"description"`
	Value       StringPattern `bson:"value"`

	// When unmarshalling a BSON document, the fields of this document that are
	// not defined in this struct are added to UnexpectedFields.
	UnexpectedFields map[string]interface{} `bson:",inline"`
}

InfoFields is a type representing a pattern that can be applied to a piece of information on an entity. The fields are not defined directly in the Info struct to make the unmarshalling easier.

type InfoPattern

type InfoPattern struct {
	ShouldNotBeSet bool

	InfoFields
}

InfoPattern is a type representing a pattern that can be applied to a piece of information on an entity.

func (InfoPattern) AsMongoQuery

func (p InfoPattern) AsMongoQuery() bson.M

AsMongoQuery returns a mongodb filter from the InfoPattern

func (InfoPattern) Matches

func (p InfoPattern) Matches(info types.Info, isSet bool, matches *InfoRegexMatches) bool

Matches returns true if a piece of information is matched by a pattern. If the pattern contains regular expressions with sub-expressions, the values of the sub-expressions are written in the matches argument.

func (*InfoPattern) SetBSON

func (p *InfoPattern) SetBSON(raw bson.Raw) error

SetBSON unmarshals a BSON value into an InfoPattern.

type InfoRegexMatches

type InfoRegexMatches struct {
	Name        RegexMatches
	Description RegexMatches
	Value       RegexMatches
}

InfoRegexMatches is a type that contains the values of the sub-expressions of regular expressions for each of the fields of an Info that contain strings.

type IntegerConditions

type IntegerConditions struct {
	// If Equal is set, the value of a field has to be equal to the value of
	// Equal to be matched by the pattern.
	Equal utils.OptionalInt64

	// If Gt is set, the value of a field has to be greater than the value
	// of Gt to be matched by the pattern.
	Gt utils.OptionalInt64 `bson:">,omitempty"`

	// If Gte is set, the value of a field has to be greater than the value
	// of Gte to be matched by the pattern.
	Gte utils.OptionalInt64 `bson:">=,omitempty"`

	// If Lt is set, the value of a field has to be greater than the value
	// of Lt to be matched by the pattern.
	Lt utils.OptionalInt64 `bson:"<,omitempty"`

	// If Lte is set, the value of a field has to be greater than the value
	// of Lte to be matched by the pattern.
	Lte utils.OptionalInt64 `bson:"<=,omitempty"`

	// When unmarshalling a BSON document, the fields of this document that are
	// not defined in this struct are added to UnexpectedFields.
	// UnexpectedFields should always be empty.
	UnexpectedFields map[string]interface{} `bson:",inline"`
}

IntegerConditions is a struct representing a pattern that can be applied to the value of a integer field of an event. Each field of a IntegerConditions represents a condition that is applied if the value of this field is not nil. The fields are not defined directly in the IntegerPattern struct to make the unmarshalling easier.

func (IntegerConditions) AsMongoQuery

func (p IntegerConditions) AsMongoQuery() bson.M

AsMongoQuery returns a mongodb filter from the IntegerConditions

func (IntegerConditions) Empty

func (p IntegerConditions) Empty() bool

Empty returns true if the none of the conditions have been set.

func (IntegerConditions) Matches

func (p IntegerConditions) Matches(value types.CpsNumber) bool

Matches returns true if the value satisfies each of the conditions defined in the IntegerConditions.

type IntegerPattern

type IntegerPattern struct {
	IntegerConditions
}

IntegerPattern is a type representing a pattern that can be applied to the value of a field of an event that contains an integer.

func (*IntegerPattern) SetBSON

func (p *IntegerPattern) SetBSON(raw bson.Raw) error

SetBSON unmarshals a BSON value into an IntegerPattern.

type IntegerRefPattern

type IntegerRefPattern struct {
	// If EqualNil is true, the field should be nil or not be set to be matched
	// by the pattern.
	EqualNil bool

	IntegerPattern
}

IntegerRefPattern is a type representing a pattern that can be applied to the value of a field of an event that contains a reference to an integer.

func (IntegerRefPattern) AsMongoQuery

func (p IntegerRefPattern) AsMongoQuery() bson.M

AsMongoQuery returns a mongodb filter from the IntegerRefPattern

func (IntegerRefPattern) Empty

func (p IntegerRefPattern) Empty() bool

Empty returns true if the pattern has not been set

func (IntegerRefPattern) Matches

func (p IntegerRefPattern) Matches(value *types.CpsNumber) bool

Matches returns true if the value is matched by the pattern.

func (*IntegerRefPattern) SetBSON

func (p *IntegerRefPattern) SetBSON(raw bson.Raw) error

SetBSON unmarshals a BSON value into an IntegerRefPattern.

type InterfacePattern

type InterfacePattern struct {
	// If EqualNil is true, the field should be nil or not be set to be matched
	// by the pattern.
	EqualNil bool

	IntegerConditions
	StringConditions
}

InterfacePattern is a type representing a pattern that can be applied to the value of a field of an event that contains an interface{}. It only allows to define patterns on integers and strings.

func (*InterfacePattern) AsMongoQuery

func (p *InterfacePattern) AsMongoQuery() bson.M

AsMongoQuery returns a mongodb filter from the InterfacePattern

func (InterfacePattern) Matches

func (p InterfacePattern) Matches(value interface{}, matches *RegexMatches) bool

Matches returns true if the value is matched by the pattern. If the pattern contains a regular expression with sub-expressions, the values of the sub-expressions are written in the matches argument.

func (*InterfacePattern) SetBSON

func (p *InterfacePattern) SetBSON(raw bson.Raw) error

SetBSON unmarshals a BSON value into an InterfacePattern.

type RegexMatches

type RegexMatches map[string]string

RegexMatches is a type that contains the values of the sub-expressions of a regular expression.

type StringConditions

type StringConditions struct {
	// If Equal is set, the value of a field has to be equal to the value of
	// Equal to be matched by the pattern.
	Equal utils.OptionalString

	// If RegexMatch is set, the value of a field has to be matched by this
	// regular expression to be matched by the pattern.
	RegexMatch utils.OptionalRegexp `bson:"regex_match,omitempty"`

	// When unmarshalling a BSON document, the fields of this document that are
	// not defined in this struct are added to UnexpectedFields.
	// UnexpectedFields should always be empty.
	UnexpectedFields map[string]interface{} `bson:",inline"`
}

StringConditions is a struct representing a pattern that can be applied to the value of a string field of an event. Each field of a StringConditions represents a condition that is applied if the value of this field is not nil. The fields are not defined directly in the StringPattern struct to make the unmarshalling easier.

func (StringConditions) AsMongoQuery

func (p StringConditions) AsMongoQuery() bson.M

AsMongoQuery returns a mongodb filter from the StringConditions

func (StringConditions) Empty

func (p StringConditions) Empty() bool

Empty returns true if the none of the conditions have been set.

func (StringConditions) Matches

func (p StringConditions) Matches(value string, matches *RegexMatches) bool

Matches returns true if the value satisfies each of the conditions defined in the StringConditions. If the pattern contains a regular expression with sub-expressions, the values of the sub-expressions are written in the matches argument.

type StringPattern

type StringPattern struct {
	StringConditions
}

StringPattern is a type representing a pattern that can be applied to the value of a field of an event that contains a string.

func (*StringPattern) SetBSON

func (p *StringPattern) SetBSON(raw bson.Raw) error

SetBSON unmarshals a BSON value into a StringPattern.

type StringRefPattern

type StringRefPattern struct {
	// If EqualNil is true, the field should be nil or not be set to be matched
	// by the pattern.
	EqualNil bool

	StringPattern
}

StringRefPattern is a type representing a pattern that can be applied to the value of a field of an event that contains a reference to a string.

func (StringRefPattern) AsMongoQuery

func (p StringRefPattern) AsMongoQuery() bson.M

AsMongoQuery returns a mongodb filter from the StringRefPattern

func (StringRefPattern) Matches

func (p StringRefPattern) Matches(value *string, matches *RegexMatches) bool

Matches returns true if the value is matched by the pattern. If the pattern contains a regular expression with sub-expressions, the values of the sub-expressions are written in the matches argument.

func (*StringRefPattern) SetBSON

func (p *StringRefPattern) SetBSON(raw bson.Raw) error

SetBSON unmarshals a BSON value into a StringRefPattern.

type TimePattern

type TimePattern struct {
	IntegerPattern
}

TimePattern is a type representing a pattern that can be applied to the value of a field of an event that contains a CpsTime.

func (TimePattern) Matches

func (p TimePattern) Matches(value types.CpsTime) bool

Matches returns true if the value is matched by the pattern.

type TimeRefPattern

type TimeRefPattern struct {
	IntegerRefPattern
}

TimeRefPattern is a type representing a pattern that can be applied to the value of a field of an event that contains a reference to a CpsTime.

func (TimeRefPattern) Matches

func (p TimeRefPattern) Matches(value *types.CpsTime) bool

Matches returns true if the value is matched by the pattern.

Jump to

Keyboard shortcuts

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