Filters

The $filter system query option allows clients to filter a collection of resources that are addressed by a request URL. The expression that is specified with $filter is evaluated for each resource in the collection. 
nfa1000
The $filter system query option allows clients to filter a collection of resources that are addressed by a request URL. The expression that is specified with $filter is evaluated for each resource in the collection. 
The items for which the expression is set are included in the response and the responses are omitted when:
  • The resources for which the expression is set to false or to null.
  • The reference properties are unavailable due to permissions.
Note:
 The operators 
Equal (eq)
 and 
Not Equal (ne)
 support only 
numeric
 values. When you need to filter based on 
string
 values use the 
contains
 operator.
The list of valid filter operators are as follows:
 
Comparison Operator
 
Operator
Description
Example
eq
Equal 
InSpeed eq 100
ne
Not equal 
InSpeed ne 100
gt
Greater than
InSpeed gt 100
ge
Greater than or equal 
InSpeed ge 100
lt
Less than 
InSpeed lt 100
le
 Less than or equal 
InSpeed le 100
 
Logical operators
 
Operator
Description
Example
and
Logical AND
InSpeed gt 100 and OutSpeed lt 1000
or
 Logical OR
InSpeed gt 100 or OutSpeed lt 1000
not
Logical negation
not InSpeed gt 100
 
Arithmetic Operators
 
Operator
Description
Example
add
Addition
 Price add 5 gt 10
sub
Subtraction 
Price sub 5 gt 10
mul
Multiplication 
Price mul 2 gt 2000
div
Division 
Price div 2 gt 4
mod
Modulo 
Price mod 2 eq 0
 
Grouping Operators
 
Operator
Description
Example
( ) 
Precedence grouping 
(InSpeed lt 100 InSpeed le 100) ge 100
 
Arithmetic Operators
 
Operator
Example
contains
contains(CompanyName,'freds')
endswith
endswith(deviceName,'1')
startswith
startswith(AgentType,'Alfr')
length
length(PersistentIfIndex) eq 19
indexof
indexof(CompanyName,'lfreds') eq 1
substring
substring(CompanyName,1) eq 'lfreds Futterkiste'
tolower
tolower(AgentType) eq 'virtual'
toupper
toupper(AgentType) eq 'VIRTUAL'
concat
concat('AgentType', RouterAddress) eq 'AgentType, RouterAddress'
 
Math Function
 
Operator
Example
round
round(Freight) eq 32
floor 
floor(Freight) eq 32
ceiling
ceiling(Freight) eq 33
 
Resource URL
 
http://<
nfa odata host
>:<
nfa odata port
>/odata/api/<
EntityType Name
>?$filter=<
Property Name
><
space
><
Filter Operator
><
space
><
Property Name
>(<
ProperyRef Name value
>)
 
Method
 
GET
 
Parameters
 
The following table includes the mandatory parameter.
Parameters
Description
EntityType Name
Specifies the name of the entity type.
Property Name
Indicates the property type of an Entity.
Filter Operator.
Specifies the valid list of filter operator.
Property Name
Indicates the Property type.
ProperyRef Name value
Specifies the value of property reference.
 
Sample Request
 
This example uses the eq filter option to display the router Id 150002
.
 
http://127.0.0.1:8981/odata/api/routers?$filter=ID eq (1500002)
 
Sample Response
 
{ "@odata.context": "$metadata#routers", "value": [ { "ID": 1500002, "routerAddress": "127.0.0.1", "sysDescr": "127.0.0.1", "sysName": "", "deviceName": "127.0.0.1", "deviceAlias": "127.0.0.1", "sysUptime": 0, "lastData": 0, "lastReboot": 0, "lastRefresh": 0, "lastDiscovery": 0, "lastHarvesterUpdate": 0, "firstPollError": 0, "nextPollRetry": 0, "harvesterID": 2, "profileId": 0, "snmpVersion": 2, "snmpPort": 161, "snmpTimeout": 3, "snmpRetry": 3, "snmpMaxRows": 10, "ifNumber": 0, "interfaceCount": 10, "agentCount": 10, "dnsLastLookupTime": 1535948950, "dnsExpireTime": 1536553750, "syncUpdateTime": 0, "routerName": null, "routerUpdatedOn": 1526876265, "templateId": 1, "snmpProxyAddress": "127.0.0.1", "dnsProxyAddress": "127.0.0.1", "tenantId": 8, "domainID": 1 } ] }