File: operator.go

package info (click to toggle)
incus 6.0.5-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,092 kB
  • sloc: sh: 16,313; ansic: 3,121; python: 457; makefile: 337; ruby: 51; sql: 50; lisp: 6
file content (34 lines) | stat: -rw-r--r-- 833 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package filter

// OperatorSet is represents the types of operators and symbols that a filter can support.
type OperatorSet struct {
	And       string
	Or        string
	Equals    string
	NotEquals string

	GreaterThan  string
	LessThan     string
	GreaterEqual string
	LessEqual    string

	Negate string
	Quote  []string
}

// isValid ensures the OperatorSet has valid fields for the minimum supported operators.
func (o *OperatorSet) isValid() bool {
	return o.And != "" && o.Or != "" && o.Equals != "" && o.NotEquals != "" && o.Negate != "" && len(o.Quote) > 0
}

// QueryOperatorSet returns the default operator set for REST API queries.
func QueryOperatorSet() OperatorSet {
	return OperatorSet{
		And:       "and",
		Or:        "or",
		Equals:    "eq",
		NotEquals: "ne",
		Negate:    "not",
		Quote:     []string{"\""},
	}
}