bepxression

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 8 Imported by: 2

README

Binary Expression Parser for Raito Plugins and Services

Software License Build status Code Coverage


Introduction

A library to parse binary expression within Raito plugins and services.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AggregatorOperatorStrings

func AggregatorOperatorStrings() []string

AggregatorOperatorStrings returns a slice of all String values of the enum

func BinaryExpressionDebugString

func BinaryExpressionDebugString(b *BinaryExpression) (string, error)

func ComparisonOperatorStrings

func ComparisonOperatorStrings() []string

ComparisonOperatorStrings returns a slice of all String values of the enum

func EntityTypeStrings

func EntityTypeStrings() []string

EntityTypeStrings returns a slice of all String values of the enum

func UnaryOperatorStrings

func UnaryOperatorStrings() []string

UnaryOperatorStrings returns a slice of all String values of the enum

func WithComparisonOperatorFn

func WithComparisonOperatorFn(fn func(node ComparisonOperator) error) func(o *traverseOptions)

func WithEnterAggregatorFn

func WithEnterAggregatorFn(fn func(node *Aggregator) error) func(o *traverseOptions)

func WithEnterBinaryExpressionFn

func WithEnterBinaryExpressionFn(fn func(node *BinaryExpression) error) func(o *traverseOptions)

func WithEnterComparisonFn

func WithEnterComparisonFn(fn func(node *BinaryComparison) error) func(o *traverseOptions)

func WithEnterOperandFn

func WithEnterOperandFn(fn func(node *Operand) error) func(o *traverseOptions)

func WithEnterUnaryExpressionFn

func WithEnterUnaryExpressionFn(fn func(node *UnaryExpression) error) func(o *traverseOptions)

func WithLeaveAggregatorFn

func WithLeaveAggregatorFn(fn func(node *Aggregator)) func(o *traverseOptions)

func WithLeaveBinaryExpressionFn

func WithLeaveBinaryExpressionFn(fn func(node *BinaryExpression)) func(o *traverseOptions)

func WithLeaveComparisonFn

func WithLeaveComparisonFn(fn func(node *BinaryComparison)) func(o *traverseOptions)

func WithLeaveOperandFn

func WithLeaveOperandFn(fn func(node *Operand)) func(o *traverseOptions)

func WithLeaveUnaryExpressionFn

func WithLeaveUnaryExpressionFn(fn func(node *UnaryExpression)) func(o *traverseOptions)

func WithLiteralBoolFn

func WithLiteralBoolFn(fn func(value bool) error) func(o *traverseOptions)

func WithLiteralFloatFn

func WithLiteralFloatFn(fn func(value float64) error) func(o *traverseOptions)

func WithLiteralIntFn

func WithLiteralIntFn(fn func(value int) error) func(o *traverseOptions)

func WithLiteralStringFn

func WithLiteralStringFn(fn func(value string) error) func(o *traverseOptions)

func WithLiteralTimestampFn

func WithLiteralTimestampFn(fn func(value time.Time) error) func(o *traverseOptions)

func WithNextAggregatorOperand

func WithNextAggregatorOperand(fn func() error) func(o *traverseOptions)

func WithReferenceFn

func WithReferenceFn(fn func(node *Reference) error) func(o *traverseOptions)

Types

type Aggregator

type Aggregator struct {
	Operator AggregatorOperator `json:"operator" yaml:"operator" gqlgen:"operator"`
	Operands []BinaryExpression `json:"operands" yaml:"operands" gqlgen:"operands"`
}

func (*Aggregator) Validate

func (a *Aggregator) Validate() error

type AggregatorOperator

type AggregatorOperator int
const (
	AggregatorOperatorAnd AggregatorOperator = iota
	AggregatorOperatorOr
)

func AggregatorOperatorString

func AggregatorOperatorString(s string) (AggregatorOperator, error)

AggregatorOperatorString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func AggregatorOperatorValues

func AggregatorOperatorValues() []AggregatorOperator

AggregatorOperatorValues returns all values of the enum

func (AggregatorOperator) IsAAggregatorOperator

func (i AggregatorOperator) IsAAggregatorOperator() bool

IsAAggregatorOperator returns "true" if the value is listed in the enum definition. "false" otherwise

func (AggregatorOperator) MarshalGQL

func (i AggregatorOperator) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface for AggregatorOperator

func (AggregatorOperator) MarshalJSON

func (i AggregatorOperator) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for AggregatorOperator

func (AggregatorOperator) MarshalYAML

func (i AggregatorOperator) MarshalYAML() (interface{}, error)

MarshalYAML implements a YAML Marshaler for AggregatorOperator

func (AggregatorOperator) String

func (i AggregatorOperator) String() string

func (*AggregatorOperator) UnmarshalGQL

func (i *AggregatorOperator) UnmarshalGQL(value interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface for AggregatorOperator

func (*AggregatorOperator) UnmarshalJSON

func (i *AggregatorOperator) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for AggregatorOperator

func (*AggregatorOperator) UnmarshalYAML

func (i *AggregatorOperator) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements a YAML Unmarshaler for AggregatorOperator

func (AggregatorOperator) Values

func (AggregatorOperator) Values() []string

type BinaryComparison

type BinaryComparison struct {
	Operator     ComparisonOperator `json:"operator" yaml:"operator" gqlgen:"operator"`
	LeftOperand  Operand            `json:"leftOperand,omitempty" yaml:"leftOperand,omitempty" gqlgen:"leftOperand"`
	RightOperand Operand            `json:"rightOperand,omitempty" yaml:"rightOperand,omitempty" gqlgen:"rightOperand"`
}

func (*BinaryComparison) Validate

func (b *BinaryComparison) Validate() error

type BinaryExpression

type BinaryExpression struct {
	Literal         *bool             `json:"literal,omitempty" yaml:"literal,omitempty" gqlgen:"literal"`
	Comparison      *BinaryComparison `json:"comparison,omitempty" yaml:"comparison,omitempty" gqlgen:"comparison"`
	Aggregator      *Aggregator       `json:"aggregator,omitempty" yaml:"aggregator,omitempty" gqlgen:"aggregator"`
	UnaryExpression *UnaryExpression  `json:"unaryExpression,omitempty" yaml:"unaryExpression,omitempty" gqlgen:"unaryExpression"`
}

func (*BinaryExpression) ToGql

func (*BinaryExpression) Validate

func (b *BinaryExpression) Validate() error

type BinaryExpressionUnion

type BinaryExpressionUnion interface {
	OperandUnion
	// contains filtered or unexported methods
}

type ComparisonOperator

type ComparisonOperator int
const (
	ComparisonOperatorEqual ComparisonOperator = iota
	ComparisonOperatorNotEqual
	ComparisonOperatorLessThan
	ComparisonOperatorLessThanOrEqual
	ComparisonOperatorGreaterThan
	ComparisonOperatorGreaterThanOrEqual
)

func ComparisonOperatorString

func ComparisonOperatorString(s string) (ComparisonOperator, error)

ComparisonOperatorString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func ComparisonOperatorValues

func ComparisonOperatorValues() []ComparisonOperator

ComparisonOperatorValues returns all values of the enum

func (ComparisonOperator) IsAComparisonOperator

func (i ComparisonOperator) IsAComparisonOperator() bool

IsAComparisonOperator returns "true" if the value is listed in the enum definition. "false" otherwise

func (ComparisonOperator) MarshalGQL

func (i ComparisonOperator) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface for ComparisonOperator

func (ComparisonOperator) MarshalJSON

func (i ComparisonOperator) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for ComparisonOperator

func (ComparisonOperator) MarshalYAML

func (i ComparisonOperator) MarshalYAML() (interface{}, error)

MarshalYAML implements a YAML Marshaler for ComparisonOperator

func (ComparisonOperator) String

func (i ComparisonOperator) String() string

func (*ComparisonOperator) UnmarshalGQL

func (i *ComparisonOperator) UnmarshalGQL(value interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface for ComparisonOperator

func (*ComparisonOperator) UnmarshalJSON

func (i *ComparisonOperator) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for ComparisonOperator

func (*ComparisonOperator) UnmarshalYAML

func (i *ComparisonOperator) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements a YAML Unmarshaler for ComparisonOperator

func (ComparisonOperator) Values

func (ComparisonOperator) Values() []string

type EntityType

type EntityType int
const (
	EntityTypeDataObject EntityType = iota
)

func EntityTypeString

func EntityTypeString(s string) (EntityType, error)

EntityTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func EntityTypeValues

func EntityTypeValues() []EntityType

EntityTypeValues returns all values of the enum

func (EntityType) IsAEntityType

func (i EntityType) IsAEntityType() bool

IsAEntityType returns "true" if the value is listed in the enum definition. "false" otherwise

func (EntityType) MarshalGQL

func (i EntityType) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface for EntityType

func (EntityType) MarshalJSON

func (i EntityType) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for EntityType

func (EntityType) MarshalYAML

func (i EntityType) MarshalYAML() (interface{}, error)

MarshalYAML implements a YAML Marshaler for EntityType

func (EntityType) String

func (i EntityType) String() string

func (*EntityType) UnmarshalGQL

func (i *EntityType) UnmarshalGQL(value interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface for EntityType

func (*EntityType) UnmarshalJSON

func (i *EntityType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for EntityType

func (*EntityType) UnmarshalYAML

func (i *EntityType) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements a YAML Unmarshaler for EntityType

func (EntityType) Values

func (EntityType) Values() []string

type Literal

type Literal struct {
	Bool      *bool      `json:"bool,omitempty" yaml:"bool,omitempty" gqlgen:"bool"`
	Int       *int       `json:"int,omitempty" yaml:"int,omitempty" gqlgen:"int"`
	Float     *float64   `json:"float,omitempty" yaml:"float,omitempty" gqlgen:"float"`
	Str       *string    `json:"string,omitempty" yaml:"string,omitempty" gqlgen:"string"`
	Timestamp *time.Time `json:"timestamp,omitempty" yaml:"timestamp,omitempty" gqlgen:"timestamp"`
}

func (*Literal) ToGql

func (l *Literal) ToGql() (LiteralUnion, error)

func (*Literal) Validate

func (l *Literal) Validate() error

type LiteralBool

type LiteralBool struct {
	Value bool
}

type LiteralFloat

type LiteralFloat struct {
	Value float64
}

type LiteralInt

type LiteralInt struct {
	Value int `json:"value" yaml:"value" gqlgen:"value"`
}

type LiteralString

type LiteralString struct {
	Value string
}

type LiteralTimestamp

type LiteralTimestamp struct {
	Value time.Time
}

type LiteralUnion

type LiteralUnion interface {
	OperandUnion
	// contains filtered or unexported methods
}

type Operand

type Operand struct {
	Reference *Reference `json:"reference,omitempty" yaml:"reference,omitempty" gqlgen:"reference"`
	Literal   *Literal   `json:"literal,omitempty" yaml:"literal,omitempty" gqlgen:"literal"`
}

func (*Operand) ToGql

func (o *Operand) ToGql() (OperandUnion, error)

func (*Operand) Validate

func (o *Operand) Validate() error

type OperandUnion

type OperandUnion interface {
	// contains filtered or unexported methods
}

type Reference

type Reference struct {
	EntityType EntityType `json:"entityType,omitempty" yaml:"entityType,omitempty" gqlgen:"entityType"`
	EntityId   string     `json:"entityId,omitempty" yaml:"entityId,omitempty" gqlgen:"entityId"`
}

func (*Reference) Validate

func (r *Reference) Validate() error

type ReferenceItem

type ReferenceItem interface{}

type Traverser

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

func NewTraverser

func NewTraverser(opts ...func(*traverseOptions)) *Traverser

func (*Traverser) TraverseAggregator

func (t *Traverser) TraverseAggregator(aggregator *Aggregator) error

func (*Traverser) TraverseBinaryExpression

func (t *Traverser) TraverseBinaryExpression(node *BinaryExpression) error

func (*Traverser) TraverseComparison

func (t *Traverser) TraverseComparison(node *BinaryComparison) error

func (*Traverser) TraverseLiteral

func (t *Traverser) TraverseLiteral(literal *Literal) error

func (*Traverser) TraverseLiteralBool

func (t *Traverser) TraverseLiteralBool(value bool) error

func (*Traverser) TraverseOperand

func (t *Traverser) TraverseOperand(node *Operand) error

func (*Traverser) TraverseReference

func (t *Traverser) TraverseReference(reference *Reference) error

func (*Traverser) TraverseUnaryExpression

func (t *Traverser) TraverseUnaryExpression(unaryExpression *UnaryExpression) error

type UnaryExpression

type UnaryExpression struct {
	Operator UnaryOperator    `json:"operator" yaml:"operator" gqlgen:"operator"`
	Operand  BinaryExpression `json:"expression" yaml:"expression" gqlgen:"expression"`
}

func (*UnaryExpression) Validate

func (n *UnaryExpression) Validate() error

type UnaryOperator

type UnaryOperator int
const (
	UnaryOperatorNot UnaryOperator = iota
)

func UnaryOperatorString

func UnaryOperatorString(s string) (UnaryOperator, error)

UnaryOperatorString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func UnaryOperatorValues

func UnaryOperatorValues() []UnaryOperator

UnaryOperatorValues returns all values of the enum

func (UnaryOperator) IsAUnaryOperator

func (i UnaryOperator) IsAUnaryOperator() bool

IsAUnaryOperator returns "true" if the value is listed in the enum definition. "false" otherwise

func (UnaryOperator) MarshalGQL

func (i UnaryOperator) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface for UnaryOperator

func (UnaryOperator) MarshalJSON

func (i UnaryOperator) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for UnaryOperator

func (UnaryOperator) MarshalYAML

func (i UnaryOperator) MarshalYAML() (interface{}, error)

MarshalYAML implements a YAML Marshaler for UnaryOperator

func (UnaryOperator) String

func (i UnaryOperator) String() string

func (*UnaryOperator) UnmarshalGQL

func (i *UnaryOperator) UnmarshalGQL(value interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface for UnaryOperator

func (*UnaryOperator) UnmarshalJSON

func (i *UnaryOperator) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for UnaryOperator

func (*UnaryOperator) UnmarshalYAML

func (i *UnaryOperator) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements a YAML Unmarshaler for UnaryOperator

func (UnaryOperator) Values

func (UnaryOperator) Values() []string

Jump to

Keyboard shortcuts

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