-
Notifications
You must be signed in to change notification settings - Fork 10
/
operator.go
205 lines (154 loc) · 5.59 KB
/
operator.go
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
package ast
import (
"github.com/cedar-policy/cedar-go/types"
"github.com/cedar-policy/cedar-go/x/exp/ast"
)
// ____ _
// / ___|___ _ __ ___ _ __ __ _ _ __(_)___ ___ _ __
// | | / _ \| '_ ` _ \| '_ \ / _` | '__| / __|/ _ \| '_ \
// | |__| (_) | | | | | | |_) | (_| | | | \__ \ (_) | | | |
// \____\___/|_| |_| |_| .__/ \__,_|_| |_|___/\___/|_| |_|
// |_|
func (lhs Node) Equal(rhs Node) Node {
return wrapNode(lhs.Node.Equal(rhs.Node))
}
func (lhs Node) NotEqual(rhs Node) Node {
return wrapNode(lhs.Node.NotEqual(rhs.Node))
}
func (lhs Node) LessThan(rhs Node) Node {
return wrapNode(lhs.Node.LessThan(rhs.Node))
}
func (lhs Node) LessThanOrEqual(rhs Node) Node {
return wrapNode(lhs.Node.LessThanOrEqual(rhs.Node))
}
func (lhs Node) GreaterThan(rhs Node) Node {
return wrapNode(lhs.Node.GreaterThan(rhs.Node))
}
func (lhs Node) GreaterThanOrEqual(rhs Node) Node {
return wrapNode(lhs.Node.GreaterThanOrEqual(rhs.Node))
}
func (lhs Node) DecimalLessThan(rhs Node) Node {
return wrapNode(lhs.Node.DecimalLessThan(rhs.Node))
}
func (lhs Node) DecimalLessThanOrEqual(rhs Node) Node {
return wrapNode(lhs.Node.DecimalLessThanOrEqual(rhs.Node))
}
func (lhs Node) DecimalGreaterThan(rhs Node) Node {
return wrapNode(lhs.Node.DecimalGreaterThan(rhs.Node))
}
func (lhs Node) DecimalGreaterThanOrEqual(rhs Node) Node {
return wrapNode(lhs.Node.DecimalGreaterThanOrEqual(rhs.Node))
}
func (lhs Node) Like(pattern types.Pattern) Node {
return wrapNode(lhs.Node.Like(pattern))
}
// _ _ _
// | | ___ __ _(_) ___ __ _| |
// | | / _ \ / _` | |/ __/ _` | |
// | |__| (_) | (_| | | (_| (_| | |
// |_____\___/ \__, |_|\___\__,_|_|
// |___/
func (lhs Node) And(rhs Node) Node {
return wrapNode(lhs.Node.And(rhs.Node))
}
func (lhs Node) Or(rhs Node) Node {
return wrapNode(lhs.Node.Or(rhs.Node))
}
func Not(rhs Node) Node {
return wrapNode(ast.Not(rhs.Node))
}
func IfThenElse(condition Node, thenNode Node, elseNode Node) Node {
return wrapNode(ast.IfThenElse(condition.Node, thenNode.Node, elseNode.Node))
}
// _ _ _ _ _ _
// / \ _ __(_) |_| |__ _ __ ___ ___| |_(_) ___
// / _ \ | '__| | __| '_ \| '_ ` _ \ / _ \ __| |/ __|
// / ___ \| | | | |_| | | | | | | | | __/ |_| | (__
// /_/ \_\_| |_|\__|_| |_|_| |_| |_|\___|\__|_|\___|
func (lhs Node) Add(rhs Node) Node {
return wrapNode(lhs.Node.Add(rhs.Node))
}
func (lhs Node) Subtract(rhs Node) Node {
return wrapNode(lhs.Node.Subtract(rhs.Node))
}
func (lhs Node) Multiply(rhs Node) Node {
return wrapNode(lhs.Node.Multiply(rhs.Node))
}
func Negate(rhs Node) Node {
return wrapNode(ast.Negate(rhs.Node))
}
// _ _ _ _
// | | | (_) ___ _ __ __ _ _ __ ___| |__ _ _
// | |_| | |/ _ \ '__/ _` | '__/ __| '_ \| | | |
// | _ | | __/ | | (_| | | | (__| | | | |_| |
// |_| |_|_|\___|_| \__,_|_| \___|_| |_|\__, |
// |___/
func (lhs Node) In(rhs Node) Node {
return wrapNode(lhs.Node.In(rhs.Node))
}
func (lhs Node) Is(entityType types.EntityType) Node {
return wrapNode(lhs.Node.Is(entityType))
}
func (lhs Node) IsIn(entityType types.EntityType, rhs Node) Node {
return wrapNode(lhs.Node.IsIn(entityType, rhs.Node))
}
func (lhs Node) Contains(rhs Node) Node {
return wrapNode(lhs.Node.Contains(rhs.Node))
}
func (lhs Node) ContainsAll(rhs Node) Node {
return wrapNode(lhs.Node.ContainsAll(rhs.Node))
}
func (lhs Node) ContainsAny(rhs Node) Node {
return wrapNode(lhs.Node.ContainsAny(rhs.Node))
}
func (lhs Node) Access(attr types.String) Node {
return wrapNode(lhs.Node.Access(attr))
}
func (lhs Node) Has(attr types.String) Node {
return wrapNode(lhs.Node.Has(attr))
}
func (lhs Node) GetTag(rhs Node) Node {
return wrapNode(lhs.Node.GetTag(rhs.Node))
}
func (lhs Node) HasTag(rhs Node) Node {
return wrapNode(lhs.Node.HasTag(rhs.Node))
}
// ___ ____ _ _ _
// |_ _| _ \ / \ __| | __| |_ __ ___ ___ ___
// | || |_) / _ \ / _` |/ _` | '__/ _ \/ __/ __|
// | || __/ ___ \ (_| | (_| | | | __/\__ \__ \
// |___|_| /_/ \_\__,_|\__,_|_| \___||___/___/
func (lhs Node) IsIpv4() Node {
return wrapNode(lhs.Node.IsIpv4())
}
func (lhs Node) IsIpv6() Node {
return wrapNode(lhs.Node.IsIpv6())
}
func (lhs Node) IsMulticast() Node {
return wrapNode(lhs.Node.IsMulticast())
}
func (lhs Node) IsLoopback() Node {
return wrapNode(lhs.Node.IsLoopback())
}
func (lhs Node) IsInRange(rhs Node) Node {
return wrapNode(lhs.Node.IsInRange(rhs.Node))
}
// ____ _ _ _
// | _ \ __ _| |_ ___| |_(_)_ __ ___ ___
// | | | |/ _` | __/ _ \ __| | '_ ` _ \ / _ \
// | |_| | (_| | || __/ |_| | | | | | | __/
// |____/ \__,_|\__\___|\__|_|_| |_| |_|\___|
func (lhs Node) Offset(rhs Node) Node { return wrapNode(lhs.Node.Offset(rhs.Node)) }
func (lhs Node) DurationSince(rhs Node) Node { return wrapNode(lhs.Node.DurationSince(rhs.Node)) }
func (lhs Node) ToDate() Node { return wrapNode(lhs.Node.ToDate()) }
func (lhs Node) ToTime() Node { return wrapNode(lhs.Node.ToTime()) }
// ____ _ _
// | _ \ _ _ _ __ __ _| |_(_) ___ _ __
// | | | | | | | '__/ _` | __| |/ _ \| '_ \
// | |_| | |_| | | | (_| | |_| | (_) | | | |
// |____/ \__,_|_| \__,_|\__|_|\___/|_| |_|
func (lhs Node) ToDays() Node { return wrapNode(lhs.Node.ToDays()) }
func (lhs Node) ToHours() Node { return wrapNode(lhs.Node.ToHours()) }
func (lhs Node) ToMinutes() Node { return wrapNode(lhs.Node.ToMinutes()) }
func (lhs Node) ToSeconds() Node { return wrapNode(lhs.Node.ToSeconds()) }
func (lhs Node) ToMilliseconds() Node { return wrapNode(lhs.Node.ToMilliseconds()) }