pattern

package
v0.0.0-...-d841f61 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFieldBsonName

func GetFieldBsonName(str interface{}, fieldName string, defaultBsonName string) (string, error)

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) AsMongoDriverQuery

func (p AlarmFields) AsMongoDriverQuery() bson.M

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) AsMongoDriverQuery

func (p AlarmPattern) AsMongoDriverQuery() bson.M

func (AlarmPattern) MarshalBSONValue

func (p AlarmPattern) MarshalBSONValue() (bsontype.Type, []byte, error)

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) UnmarshalBSONValue

func (p *AlarmPattern) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

type AlarmPatternList

type AlarmPatternList struct {
	Patterns []AlarmPattern

	// isSet is a boolean indicating whether the AlarmPatternList has been set
	// explicitly or not.
	Set bool

	// isValid is a boolean indicating whether the event patterns or valid or
	// not.
	// isValid is also false if the AlarmPatternList has not been set.
	Valid bool
}

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 NewAlarmPatternList

func NewAlarmPatternList(p []AlarmPattern) AlarmPatternList

func (*AlarmPatternList) AsInterface

func (l *AlarmPatternList) AsInterface() (interface{}, error)

func (AlarmPatternList) AsMongoDriverQuery

func (l AlarmPatternList) AsMongoDriverQuery() bson.M

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) MarshalBSONValue

func (l AlarmPatternList) MarshalBSONValue() (bsontype.Type, []byte, error)

func (AlarmPatternList) MarshalJSON

func (l AlarmPatternList) MarshalJSON() ([]byte, error)

func (AlarmPatternList) Matches

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

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

func (*AlarmPatternList) UnmarshalBSONValue

func (l *AlarmPatternList) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

func (*AlarmPatternList) UnmarshalJSON

func (l *AlarmPatternList) UnmarshalJSON(b []byte) error

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"`
	Initiator StringPattern  `bson:"initiator"`

	// 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.

func (AlarmStepFields) IsSet

func (f AlarmStepFields) IsSet() bool

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) AsMongoDriverQuery

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

AsMongoDriverQuery 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) IsSet

func (p AlarmStepRefPattern) IsSet() bool

func (AlarmStepRefPattern) MarshalBSONValue

func (p AlarmStepRefPattern) MarshalBSONValue() (bsontype.Type, []byte, error)

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) UnmarshalBSONValue

func (p *AlarmStepRefPattern) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

type AlarmStepRegexMatches

type AlarmStepRegexMatches struct {
	Type      RegexMatches
	Author    RegexMatches
	Message   RegexMatches
	Initiator 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"`
	Data      map[string]StringPattern `bson:"data"`

	// 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.

func (AlarmTicketFields) IsSet

func (f AlarmTicketFields) IsSet() bool

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) AsMongoDriverQuery

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

func (AlarmTicketRefPattern) Empty

func (p AlarmTicketRefPattern) Empty() bool

Empty returns true if the pattern has not been set

func (AlarmTicketRefPattern) IsSet

func (p AlarmTicketRefPattern) IsSet() bool

func (AlarmTicketRefPattern) MarshalBSONValue

func (p AlarmTicketRefPattern) MarshalBSONValue() (bsontype.Type, []byte, error)

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) UnmarshalBSONValue

func (p *AlarmTicketRefPattern) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

type AlarmTicketRegexMatches

type AlarmTicketRegexMatches struct {
	Type    RegexMatches
	Author  RegexMatches
	Message RegexMatches
	Value   RegexMatches
	Data    map[string]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.

func NewAlarmTicketRegexMatches

func NewAlarmTicketRegexMatches() AlarmTicketRegexMatches

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"`
	ActivationDate                TimeRefPattern              `bson:"activation_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) AsMongoDriverQuery

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

func (AlarmValuePattern) IsSet

func (p AlarmValuePattern) IsSet() bool

func (AlarmValuePattern) MarshalBSONValue

func (p AlarmValuePattern) MarshalBSONValue() (bsontype.Type, []byte, error)

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) UnmarshalBSONValue

func (p *AlarmValuePattern) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

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) AsMongoDriverQuery

func (p BoolPattern) AsMongoDriverQuery() bson.M

AsMongoDriverQuery returns a mongodb filter from the BoolPattern for mongo-driver

func (BoolPattern) Empty

func (p BoolPattern) Empty() bool

Empty returns true if the condition has not been set.

func (BoolPattern) IsSet

func (p BoolPattern) IsSet() bool

func (BoolPattern) MarshalBSONValue

func (p BoolPattern) MarshalBSONValue() (bsontype.Type, []byte, error)

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"`
	ComponentInfos map[string]InfoPattern `bson:"component_infos"`
	Type           StringPattern          `bson:"type"`
	Component      StringPattern          `bson:"component"`

	// 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) AsMongoDriverQuery

func (e EntityFields) AsMongoDriverQuery() bson.M

AsMongoDriverQuery returns a mongodb filter from the EntityFields for mongo-driver.

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) AsMongoDriverQuery

func (e EntityPattern) AsMongoDriverQuery() bson.M

AsMongoDriverQuery returns a mongodb filter from the EntityPattern for mongo-driver

func (EntityPattern) IsSet

func (e EntityPattern) IsSet() bool

func (EntityPattern) MarshalBSONValue

func (e EntityPattern) MarshalBSONValue() (bsontype.Type, []byte, error)

func (EntityPattern) Matches

func (e 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) UnmarshalBSONValue

func (e *EntityPattern) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

type EntityPatternList

type EntityPatternList struct {
	Patterns []EntityPattern

	// Set is a boolean indicating whether the EntityPatternList has been set
	// explicitly or not.
	Set bool

	// Valid is a boolean indicating whether the event patterns or valid or
	// not.
	// Valid is also false if the EntityPatternList has not been set.
	Valid bool
}

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) AsInterface

func (l *EntityPatternList) AsInterface() (interface{}, error)

func (EntityPatternList) AsMongoDriverQuery

func (l EntityPatternList) AsMongoDriverQuery() bson.M

func (EntityPatternList) AsNegativeMongoDriverQuery

func (l EntityPatternList) AsNegativeMongoDriverQuery() bson.M

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) MarshalBSONValue

func (l EntityPatternList) MarshalBSONValue() (bsontype.Type, []byte, error)

func (EntityPatternList) MarshalJSON

func (l EntityPatternList) MarshalJSON() ([]byte, error)

func (EntityPatternList) Matches

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

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

func (*EntityPatternList) UnmarshalBSONValue

func (l *EntityPatternList) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

func (*EntityPatternList) UnmarshalJSON

func (l *EntityPatternList) UnmarshalJSON(b []byte) error

type EntityRegexMatches

type EntityRegexMatches struct {
	ID             RegexMatches
	Name           RegexMatches
	Component      RegexMatches
	Infos          map[string]InfoRegexMatches
	ComponentInfos 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) MarshalBSONValue

func (p EventPattern) MarshalBSONValue() (bsontype.Type, []byte, error)

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 {
	Patterns []EventPattern

	// Set is a boolean indicating whether the EventPatternList has been set
	// explicitly or not.
	Set bool

	// Valid is a boolean indicating whether the event patterns or valid or
	// not.
	// Valid is also false if the EventPatternList has not been set.
	Valid bool
}

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) GetRegexMatches

func (l EventPatternList) GetRegexMatches(event types.Event) (EventRegexMatches, bool)

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) MarshalBSONValue

func (l EventPatternList) MarshalBSONValue() (bsontype.Type, []byte, error)

func (EventPatternList) MarshalJSON

func (l EventPatternList) MarshalJSON() ([]byte, error)

func (EventPatternList) Matches

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

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

func (*EventPatternList) UnmarshalBSONValue

func (l *EventPatternList) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

func (*EventPatternList) UnmarshalJSON

func (l *EventPatternList) UnmarshalJSON(b []byte) error

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) AsMongoDriverQuery

func (p InfoPattern) AsMongoDriverQuery() bson.M

AsMongoDriverQuery returns a mongodb filter from the InfoPattern for mongo-driver.

func (InfoPattern) MarshalBSONValue

func (p InfoPattern) MarshalBSONValue() (bsontype.Type, []byte, error)

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) UnmarshalBSONValue

func (p *InfoPattern) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

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) AsMongoDriverQuery

func (p IntegerConditions) AsMongoDriverQuery() bson.M

AsMongoDriverQuery returns a mongodb filter from the IntegerConditions for mongo-driver

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) IsSet

func (p IntegerPattern) IsSet() bool

func (IntegerPattern) MarshalBSONValue

func (p IntegerPattern) MarshalBSONValue() (bsontype.Type, []byte, error)

func (*IntegerPattern) UnmarshalBSONValue

func (p *IntegerPattern) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

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) AsMongoDriverQuery

func (p IntegerRefPattern) AsMongoDriverQuery() bson.M

AsMongoDriverQuery returns a mongodb filter from the IntegerRefPattern for mongo-driver

func (IntegerRefPattern) Empty

func (p IntegerRefPattern) Empty() bool

Empty returns true if the pattern has not been set

func (IntegerRefPattern) IsSet

func (p IntegerRefPattern) IsSet() bool

func (IntegerRefPattern) MarshalBSONValue

func (p IntegerRefPattern) MarshalBSONValue() (bsontype.Type, []byte, error)

func (IntegerRefPattern) Matches

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

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

func (*IntegerRefPattern) UnmarshalBSONValue

func (p *IntegerRefPattern) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

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
	StringArrayConditions
}

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) AsMongoDriverQuery

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

func (InterfacePattern) MarshalBSONValue

func (p InterfacePattern) MarshalBSONValue() (bsontype.Type, []byte, error)

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) UnmarshalBSONValue

func (p *InterfacePattern) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

type RegexMatches

type RegexMatches map[string]string

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

type StringArrayConditions

type StringArrayConditions struct {
	HasEvery         utils.OptionalStringArray `bson:"has_every,omitempty"`
	HasOneOf         utils.OptionalStringArray `bson:"has_one_of,omitempty"`
	HasNot           utils.OptionalStringArray `bson:"has_not,omitempty"`
	UnexpectedFields map[string]interface{}    `bson:",inline"`
}

func (StringArrayConditions) AsMongoDriverQuery

func (p StringArrayConditions) AsMongoDriverQuery() bson.M

func (StringArrayConditions) Empty

func (p StringArrayConditions) Empty() bool

func (StringArrayConditions) Matches

func (p StringArrayConditions) Matches(value []string) bool

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

func (StringArrayConditions) OnlyHasNotCondition

func (p StringArrayConditions) OnlyHasNotCondition() bool

type StringArrayPattern

type StringArrayPattern struct {
	StringArrayConditions
}

func (StringArrayPattern) MarshalBSONValue

func (p StringArrayPattern) MarshalBSONValue() (bsontype.Type, []byte, error)

func (*StringArrayPattern) UnmarshalBSONValue

func (p *StringArrayPattern) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

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) AsMongoDriverQuery

func (p StringConditions) AsMongoDriverQuery() bson.M

AsMongoDriverQuery returns a mongodb filter from the StringConditions from mongo-driver

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) IsSet

func (p StringPattern) IsSet() bool

func (StringPattern) MarshalBSONValue

func (p StringPattern) MarshalBSONValue() (bsontype.Type, []byte, error)

func (*StringPattern) UnmarshalBSONValue

func (p *StringPattern) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

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) AsMongoDriverQuery

func (p StringRefPattern) AsMongoDriverQuery() bson.M

AsMongoDriverQuery returns a mongodb filter from the StringRefPattern for mongo-driver.

func (StringRefPattern) IsSet

func (p StringRefPattern) IsSet() bool

func (StringRefPattern) MarshalBSONValue

func (p StringRefPattern) MarshalBSONValue() (bsontype.Type, []byte, error)

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) UnmarshalBSONValue

func (p *StringRefPattern) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

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.

type UnexpectedFieldsError

type UnexpectedFieldsError struct {
	Err error
}

func (UnexpectedFieldsError) Error

func (e UnexpectedFieldsError) Error() string

Jump to

Keyboard shortcuts

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