Expressions can be built using two types of elements: an expression element (sometimes called a 'leaf') and an expression tree object (called a 'node'):
You should be aware that:
Available operators depend on whether you're dealing with an expression element or expression tree object.
Expression element (leaf)
The available operators are essentially SQL operators.
You can use following the operators:
Operator |
---|
Like |
== (equality) |
!= (inequality) |
> |
< |
>= |
<= |
Not all operators work with all data types. |
Expression tree object (node)
The only available logical operators are AND, OR and NOT.
NOT is a unary operator and can only have one operand. |
{ "Attribute": "", "Operator": "", "Value": "", "DataType": "" } |
The DataType property can be omitted in data sent to the API. It's designed for use by client code to validate the value set for given element.
Supported data types
Handling boolean values
Boolean values can only be used with the equality operator comparing against words 'false' and 'true'.
{ "Operator": "", "Operands": [] } |
Operator - defines the logical operator applied to the operands, it can be AND, OR and NOT
Expression - tree object follows normal logic operator rules, for example a tree object with an 'AND' will only return true if all expressions inside it are true while an object with 'OR' will return true if at least one expressions inside it is true.
'NOT' operator is a unary operator which negates whatever its sole operand evaluates to.
Operands - is an array of Expression elements defined above.
An expression that limits a string element called OsType to a value of Windows.
{ "Attribute": "OsType", "Operator": "==", "Value": "Windows" } |
An expression tree consisting of three expression objects.
{ "Operator": "AND", "Operands": [ { "Attribute": "OsType", "Operator": "==", "Value": "Windows" }, { "Attribute": "OsVer", "Operator": "==", "Value": "7" }, { "Attribute": "DeviceType", "Operator": "==", "Value": "Desktop" } ] } |
An expression tree with multiple levels.
This expression can be used to find computers running Windows OS and are either a desktop or laptop.
The outer level of this tree has two elements - the first limits the OsType to Windows, the other contains the inner expression, which itself limits DeviceType to either desktop or laptop.
{ "Operator": "AND", "Operands": [ { "Attribute": "OsType", "Operator": "==", "Value": "Windows" }, { "Operator": "OR", "Operands": [{ "Attribute": "DeviceType", "Operator": "==", "Value": "Laptop" }, { "Attribute": "DeviceType", "Operator": "==", "Value": "Desktop" }] }] } |
Negating an expression.
To get only devices which are not Windows desktops you can write an expression selecting Windows desktops and then negate it.
{ "Operator": "NOT", "Operands": [{ "Operator": "AND", "Operands": [{ "Attribute": "OsType", "Operator": "==", "Value": "Windows" }, { "Attribute": "DeviceType", "Operator": "==", "Value": "Desktop" }] }] } |