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+
ALGTypeServiceEntry |
ALGTypeServiceEntry
|
BfdConfiguration |
BgpNeighborConfig |
BgpRoutingConfig |
BridgeEndpointProfile |
certificate_ca
|
certificate_self_signed |
certificate_signed
|
ClusterNodeConfig |
CommunityList |
ComputeManager |
crl
|
DfwFirewallConfiguration |
DhcpServerConfig |
DnsSecurityProfile
|
DOMAIN |
EdgeCluster |
EdgeHighAvailabilityProfile |
EdgeNode |
EndpointPolicy
|
EndpointRule
|
EnforcementPoint |
EtherTypeServiceEntry
|
FloodProtectionProfileBindingMap
|
ForwardingPolicy |
ForwardingRule |
GatewayFloodProtectionProfile
|
GatewayPolicy |
GatewayQosProfile |
GenericPolicyRealizedResource |
GlobalConfig |
Group |
HostNode |
ICMPTypeServiceEntry |
IdsConfig |
IdsProfile |
IdsRule
|
IdsSecurityPolicy
|
IdsSettings |
IdsSignature |
IdsSignatureVersion |
IGMPTypeServiceEntry |
IpAddressBlock |
IpAddressPool |
IpAddressPoolBlockSubnet |
IpAddressPoolStaticSubnet |
IPDiscoveryProfile |
IPFIXDFWCollectorProfile |
IPFIXDFWProfile |
IPProtocolServiceEntry |
IPSecVpnDpdProfile |
IPSecVpnIkeProfile |
IPSecVpnLocalEndpoint |
IPSecVpnRule |
IPSecVpnService |
IPSecVpnTunnelInterface |
IPSecVpnTunnelProfile |
Ipv6DadProfile |
Ipv6NdraProfile |
L2BridgeEndpointProfile |
L2VPNService |
L2VPNSession |
L4PortSetServiceEntry |
LBClientSslProfile |
LBCookiePersistenceProfile |
LBFastTcpProfile |
LBFastUdpProfile |
LBGenericPersistenceProfile |
LBHttpMonitorProfile |
LBHttpProfile |
LBHttpsMonitorProfile |
LBIcmpMonitorProfile |
LBPassiveMonitorProfile |
LBPool |
LBServerSslProfile |
LBService |
LBSourceIpPersistenceProfile |
LBTcpMonitorProfile |
LBUdpMonitorProfile
|
LBVirtualServer |
LocaleServices |
MacDiscoveryProfile |
MetadataProxyConfig |
PolicyBasedIPSecVpnSession |
PolicyContextProfile |
PolicyDnsForwarder |
PolicyDnsForwarderZone |
PolicyDraft |
PolicyEdgeCluster |
PolicyEdgeNode |
PolicyExcludeList |
PolicyFirewallSessionTimerProfile
|
PolicyIgmpConfig |
PolicyMulticastConfig |
PolicyNat |
PolicyNatRule |
PolicyPimConfig |
PolicyServiceChain
|
PolicyServiceProfile
|
PolicyTransportZone |
PrefixList |
RealizedVirtualMachine
|
RedirectionPolicy |
RedirectionRule |
RouteBasedIPSecVpnSession |
Rule |
SecurityPolicy |
Segment |
SegmentPort |
SegmentSecurityProfile |
Service |
ServiceReference
|
ServiceSegment
|
SessionTimerProfileBindingMap
|
Site |
SpoofGuardProfile |
StandaloneHostIdfwConfiguration |
StaticRouteBfdPeer |
StaticRoutes |
Tier0 |
Tier0Interface |
Tier0RouteMap |
Tier1 |
Tier1Interface |
TlsCertificate
|
TlsCrl
|
TraceflowConfig
|
TransportNode |
TransportZone |
UplinkHostSwitchProfile |
VniPoolConfig |
AdvertisementConfig |
AdvertiseRuleList |
BGPCommunityList |
BgpConfig |
BgpNeighbor |
BridgeEndpointProfile |
BridgeHighAvailabilityClusterProfile |
certificate_ca
|
certificate_self_signed |
certificate_signed
|
ClusterNodeConfig |
ComputeCollection |
ComputeManager |
crl
|
DhcpIpPool |
DhcpProfile |
DhcpRelayProfile |
DhcpRelayService |
DirectoryAdDomain
|
DirectoryGroup
|
DirectoryLdapServer
|
DiscoveredNode |
DnsForwarder |
EdgeCluster |
EdgeHighAvailabilityProfile |
EdgeNode |
ExcludeList |
ExtraConfigHostSwitchProfile |
FirewallRule |
FirewallSection |
GiConfigDashboardInfo |
GiServiceProfile
|
HostHealthAggregateStatus |
HostNode |
IDSSignatureDetail |
IpBlock |
IpDiscoverySwitchingProfile |
IpfixCollectorConfig |
IpfixDfwConfig |
IpfixObsPointConfig |
IpPool |
IPPrefixList |
IPSecVPNLocalEndpoint |
IPSecVPNPeerEndpoint |
IPSecVPNService |
IPSecVPNTunnelProfile |
IPSet |
L2VpnService |
L2VpnSession |
LbClientSslProfile |
LbCookiePersistenceProfile |
LbFastTcpProfile |
LbFastUdpProfile |
LbGenericPersistenceProfile |
LbHttpMonitor |
LbHttpProfile |
LbHttpsMonitor |
LbIcmpMonitor |
LbPassiveMonitor |
LbPool |
LbServerSslProfile |
LbService |
LbSourceIpPersistenceProfile |
LbTcpMonitor |
LbUdpMonitor
|
LbVirtualServer |
LldpHostSwitchProfile |
LogicalDhcpServer |
LogicalPort |
LogicalRouter |
LogicalRouterCentralizedServicePort |
LogicalRouterDownLinkPort |
LogicalRouterIPTunnelPort |
LogicalRouterLinkPortOnTIER0 |
LogicalRouterLinkPortOnTIER1 |
LogicalRouterUpLinkPort |
LogicalSwitch |
MacManagementSwitchingProfile |
MACSet |
MetadataProxy |
NatRule |
NiocProfile |
NSGroup |
NSProfile |
NSService |
NSServiceGroup |
PolicyBasedIPSecVPNSession |
PortMirroringSwitchingProfile |
PrincipalIdentity |
QosSwitchingProfile |
RedistributionConfig |
RedistributionRuleList |
RouteBasedIPSecVPNSession |
RouteMap |
RoutingConfig |
ServiceDefinition
|
ServiceInsertionRule |
ServiceInsertionSection |
ServiceInsertionServiceProfile
|
ServiceProfileNSGroups
|
SIExcludeList |
SpoofGuardSwitchingProfile |
StaticHopBfdPeer |
StaticRoute |
SwitchSecuritySwitchingProfile |
TransportNode |
TransportZone |
UplinkHostSwitchProfile |
VendorTemplate
|
VirtualMachine |
VirtualNetworkInterface |
VmHealthAggregateStatus |
VniPool |
Request:
URI Path(s):
/api/v1/search/dsl
Query Parameters:
SearchQueryRequest+
cursor |
Opaque cursor to be used for getting next page of records (supplied by current result page) |
string |
|
included_fields |
Comma separated list of fields that should be included in query result |
string |
|
page_size |
Maximum number of results to return in this page (server may return fewer) |
integer |
Minimum: 0 Maximum: 1000 Default: "1000" |
query |
Search query
The syntax of query is described in Search API documentation. |
string |
Required |
sort_ascending |
|
boolean |
|
sort_by |
Field by which records are sorted |
string |
|
Example Request:
GET https://<nsx-mgr>/api/v1/search/dsl?query=group%20where%20tags%20scope%20%3D%20%27prod%27
GET https://<nsx-mgr>/policy/api/v1/search/dsl?query=group%20where%20tags%20scope%20%3D%20%27prod%27
GET https://<nsx-mgr>/global-manager/api/v1/search/dsl?query=group%20where%20tags%20scope%20%3D%20%27prod%27
Successful Response:
Response Headers:
Content-type: application/json
Response Body:
SearchResponse+
_links |
References related to this resource
The server will populate this field when returing the resource. Ignored on PUT and POST. |
array of ResourceLink |
Readonly |
_schema |
Schema for this resource |
string |
Readonly |
_self |
Link to this resource |
SelfResourceLink |
Readonly |
cursor |
Opaque cursor to be used for getting next page of records (supplied by current result page) |
string |
Readonly |
result_count |
Count of results found (across all pages), set only on first page |
integer |
Readonly |
results |
Search results
List of records matching the search query. |
array of object |
Readonly |
sort_ascending |
If true, results are sorted in ascending order |
boolean |
Readonly |
sort_by |
Field by which records are sorted |
string |
Readonly |
Example Response:
{
"results": [
{
"_last_modified_user": "admin",
"_revision": 4,
"_system_owned": false,
"resource_type": "Group",
"description": "Prod Env Group",
"_protection": "NOT_PROTECTED",
"_last_modified_time": 1561700732921,
"display_name": "ProdEnvGroup",
"_create_user": "admin",
"tags": [
{
"scope": "Prod",
"tag": "Group"
}
],
"_create_time": 1561614698915,
"path": "/infra/domains/default/groups/4fc8c310-989f-11e9-baf3-930b233a84c6",
"marked_for_delete": false,
"parent_path": "/infra/domains/default",
"id": "4fc8c310-989f-11e9-baf3-930b233a84c6",
"relative_path": "4fc8c310-989f-11e9-baf3-930b233a84c6",
"status": {
"consolidated_status_per_enforcement_point": [
{
"consolidated_status": {
"consolidated_status": "SUCCESS"
},
"enforcement_point_id": "default"
}
],
"consolidated_status": {
"consolidated_status": "SUCCESS"
},
"intent_path": "/infra/domains/default/groups/4fc8c310-989f-11e9-baf3-930b233a84c6"
}
}
],
"result_count": 1,
"cursor": "1"
}
Required Permissions:
read
Feature:
search
Additional Errors: