Expressions and Types
You can think of NQE Checks as queries. Each query is actually an expression. There are many kinds of expressions, which
Numbers
Numbers can be written as normal:
Strings
Construction
Booleans
Boolean values are written as
If Expressions
If expressions allow us to select a value based on a boolean (true or false) value. For example, the expression:
IP Addresses
IP addresses can be written like this: ipAddress("1.2.3.4") for IPv4
IP Subnets
IP subnets can be obtained from the data model or via pattern matching against configuration text (see Section
MAC Addresses
MAC addresses can be written like this224466").
Time
There are three types to represent three aspects of time and various ways to combine with with operators.
Collections
NQE provides three types for working with collections of values.
Sets
A Set is a collection of elements that are unique (i.e. that does not contain duplicates). The only way to create a
Records
Construction
Comparisons
You can compare two values for equality, and order via the typical operators, like ==, !=, ` and >=`.
OneOfs and Enumerations
A variety of enumerated constants are provided within the data model. For example, the OperStatus enumeration has
Missing Values and Null Expressions
Data are sometimes missing in the data model (marked as nullable in the Data Model tab). For example, the mtu of
Snapshot Data
Snapshot data is made available via the network variable, which is always in scope. For example, network.devices
Device Groups
Each device has a field named groupNames that contains the names of the device groups that contain this device. With
User-defined constants and functions
Overview
Comprehensions
Comprehensions provide a powerful way of defining new collections in terms of some other data, and are the primary way
Extracting Data from Configurations via Pattern Matching
The data model exposes device configurations via the config field of the files field of Device objects.
Primary Keys
A primary key defines a uniqueness constraint on a query's output. The key specifies one or more columns whose
Top-level Expression
The top-level expression is the expression that defines the results of the check. The top-level expression must evaluate
Parameterized Queries
Instead of a main query, you can instead mark a function or variable declaration with an annotation that declares that
NQE Types
NQE type literals are used in NQE queries in several places:
Imports
While using NQE, you may find yourself needing the same functionality in multiple queries. Imports allow you to share
CSV Data
NQE queries can access data formatted as comma-seperated values (CSV).
JSON Data
NQE queries can access data formatted as JSON.
Block Patterns
Block patterns enable users to define a multi-command pattern of configuration. Block patterns can be used with NQE
Regular Expressions
NQE provides regular expression support similar to that found in other languages, like Python, Perl, Java, and SQL. In