Specifying a query filter to send to the target system
When the probe sends requests to the target system for resynchronizations or subscriptions, you can specify a query filter to limit the scope of the events that are returned.
Query scoping filters
You can filter the results of an API query by appending one or more condition statements to the request URI using the following format:
URI?condition1[&condition2[&...]]
Where URI
is
the request string specified in the following transport properties:
- resyncRequestURI: For filtering resynchronization events.
- subscribeRequestURI: For filtering new events.
condition1
and condition2
are
conditions in the query filter expression.Composing query filter expressions by applying logical operators and values
Query filter expressions can be specified
by appending a query-target-filter
parameter to the
request URI.
The query-target-filter
parameter
takes the following format:
query-target-filter=filter-expression
Where filter-expression
consists
of an expression comprising logical operators and values. The following
table shows the logical operators that you can include in filter-expression
.
Operator |
Description |
---|---|
eq |
Equal to |
ne |
Not equal to |
lt |
Less than |
gt |
Greater than |
le |
Less than or equal to |
ge |
Greater than or equal to |
bw |
Between |
not |
Logical inverse |
and |
Logical AND |
or |
Logical OR |
xor |
Logical exclusive OR |
true |
Boolean true |
false |
Boolean false |
anybit |
TRUE if at least one bit is set |
allbits |
TRUE if all bits are set |
wcard |
Wildcard |
pholder |
Property holder |
passive |
Passive holder |
Example query filters
A basic equality or inequality filter uses the following format:
query-target-filter=[eq|ne](attribute,value)
More complex expressions can be created by combining operators and conditions using parentheses and commas using the following format:
query-target-filter=[and|or]([eq|ne](attribute,value),[eq|ne](attribute,value),...)
Example 1
The following filter resynchronizes with only those alarms
that were last updated after 2015-04-06
.
resyncRequestURI=/api/class/faultInst.json?query-target-filter=gt(faultInst.lastTransition,"2015-04-06T00:00:00.000+00:00")
Example 2
The following filter receives only those new alarms that
have fault codes F96976
and F100264
.
subscribeRequestURI=/api/class/faultInst.json?query-target-filter=and(eq(faultInst.code,"F96976"),eq(faultInst.code,"F100264"))&subscription=yes
For more information, refer to the Cisco APIC REST API User Guide: Filtering API Query Results available from the Cisco Website.