sift_client.util.cel_utils
¶
CEL (Common Expression Language) utilities for generating CEL expressions.
This module provides helper functions to generate CEL expressions for building filters commonly used in Sift.
| FUNCTION | DESCRIPTION |
|---|---|
and_ |
Generates a CEL expression that joins all clauses with an AND operator. |
contains |
Generates a CEL expression that checks whether a string field contains a given value. |
equals |
Generates a CEL expression that checks for equality. |
equals_all |
Generates a CEL expression that checks for equality of all key-value pairs. |
equals_any |
Generates a CEL expression that checks for equality of any key-value pairs. |
equals_double |
Generates a CEL expression that checks for equality with a double value. |
equals_null |
Generates a CEL expression that checks for equality with null. |
greater_than |
Generates a CEL expression that checks whether a numeric or datetime field is greater than a given value. |
in_ |
Generates a CEL expression that checks for |
less_than |
Generates a CEL expression that checks whether a numeric or datetime field is less than a given value. |
match |
Generates a CEL expression that checks for a match on the specified field. |
not_ |
Generates a CEL expression that negates the given clause. |
or_ |
Generates a CEL expression that joins all clauses with an OR operator. |
parens |
Wraps the given expression in parentheses. |
and_
¶
Generates a CEL expression that joins all clauses with an AND operator.
| PARAMETER | DESCRIPTION |
|---|---|
*clauses
|
Variable number of CEL expression strings
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A CEL expression string with all clauses joined by AND |
contains
¶
Generates a CEL expression that checks whether a string field contains a given value.
| PARAMETER | DESCRIPTION |
|---|---|
field
|
The field name
TYPE:
|
value
|
The substring to check for
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A CEL expression string |
equals
¶
Generates a CEL expression that checks for equality.
| PARAMETER | DESCRIPTION |
|---|---|
key
|
The field name
TYPE:
|
value
|
The value to compare against
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A CEL expression string |
equals_all
¶
Generates a CEL expression that checks for equality of all key-value pairs.
| PARAMETER | DESCRIPTION |
|---|---|
values
|
Dictionary of field names and values to check for equality
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A CEL expression string with all equality checks joined by AND |
equals_any
¶
Generates a CEL expression that checks for equality of any key-value pairs.
| PARAMETER | DESCRIPTION |
|---|---|
values
|
Dictionary of field names and values to check for equality
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A CEL expression string with all equality checks joined by OR |
equals_double
¶
Generates a CEL expression that checks for equality with a double value.
| PARAMETER | DESCRIPTION |
|---|---|
key
|
The field name
TYPE:
|
value
|
The value to compare against as a double
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A CEL expression string |
equals_null
¶
Generates a CEL expression that checks for equality with null.
| PARAMETER | DESCRIPTION |
|---|---|
key
|
The field name
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A CEL expression string |
greater_than
¶
Generates a CEL expression that checks whether a numeric or datetime field is greater than a given value.
| PARAMETER | DESCRIPTION |
|---|---|
field
|
The field name
TYPE:
|
value
|
The value to compare against
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A CEL expression string |
in_
¶
Generates a CEL expression that checks for field membership in vals.
| PARAMETER | DESCRIPTION |
|---|---|
field
|
The field name to check
TYPE:
|
vals
|
List of string values to check membership against
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A CEL expression string or empty string if vals is empty |
less_than
¶
Generates a CEL expression that checks whether a numeric or datetime field is less than a given value.
| PARAMETER | DESCRIPTION |
|---|---|
field
|
The field name
TYPE:
|
value
|
The value to compare against
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A CEL expression string |
match
¶
Generates a CEL expression that checks for a match on the specified field.
| PARAMETER | DESCRIPTION |
|---|---|
field
|
The field name
TYPE:
|
query
|
The regex pattern to match against
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A CEL expression string |
not_
¶
Generates a CEL expression that negates the given clause.
| PARAMETER | DESCRIPTION |
|---|---|
clause
|
The CEL expression to negate
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A negated CEL expression string |
or_
¶
Generates a CEL expression that joins all clauses with an OR operator.
| PARAMETER | DESCRIPTION |
|---|---|
*clauses
|
Variable number of CEL expression strings
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A CEL expression string with all clauses joined by OR |
parens
¶
Wraps the given expression in parentheses.
| PARAMETER | DESCRIPTION |
|---|---|
expr
|
The expression to wrap in parentheses
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A CEL expression string with parentheses |