NSX-T Data Center REST API
DSL (Domain Specific Language) search API (Experimental)
DSL(Domain Specific Language) Syntax
DSL query comprises of entity type and optional predicate to help filter the given entity type based on its properties.
DSL syntax has the following structure:
EntityType WHERE Predicate
Where Predicate stands for PropertyName RelationalOperator PropertyValue
See example:
LogicalSwitch where admin_state = down
Multiple Predicates can be combined using the Logical Operators.
DSL query is case insensitive.
Entity Type
We can search for any entity type by specifying it in the DSL query.
To find all segments use simple DSL query as:
segment
Predicate
Predicate helps define the search criteria for the specified entity type.
To search rules with action rejected, use DSL query as:
rule where action = reject
To search virtual machine which has power state running, use DSL query as :
VirtualMachine where power_state = "VM_RUNNING"Nested properties can be search for using the "." (dot notation) like "tags.scope".
To search groups with tag scope as production, use DSL query as:
Group where tags.scope = production
Relational Operator
The comparison operators =, !=, <, <=, >, >=, like can be used to match property values.
Operator | Type | Note |
---|---|---|
<, <=, >, >= | Numeric | Operators <, <=, > and >= can be used for numeric properties. |
=, != | Numeric, String, Boolean | Used for numeric, text and boolean properties. |
like | String | Used to find entities where "property_name" contains "value". |
To search for Tier1 Gateways which have display name Test, use DSL query as:
tier1 where display_name = Test
To search for virtual machines which have display name like App-VM, use DSL query as:
VirtualMachine where display_name like App-VM
To search for logical switches which have vni between 65538 and 65553, use DSL query as:
LogicalSwitch where vni > 65538 and vni < 65553
Logical Operator
Logical operator "AND" and "OR" can be use to combine two predicates. We can use parentheses "(" and ")" to define nested logical operations.
To search for Tier0 Gateways where Failover Mode is Non Preemptive or HA Mode is Active-Active and Firewall is disabled, we can use the query:
tier0 where failover mode = non_preemptive or (ha mode = active_active and disable firewall = true)
Searchable types+
Request:
/api/v1/search/dsl