withInfoStatus
withInfoStatus(value: T, infoStatus : InfoStatus) : T, where T is one of the following types:
- String
- Number
- Float
- Bool
- IpAddress
- IpSubnet
- MacAddress
- Date
- Timestamp
- Duration
Returns a new value that is identical to the provided value, but which is labelled with the given informational status.
The informational status have the following labels :
- OK
- WARNING
- ERROR
The withInfoStatus function is useful to call out certain
information in an NQE report. For example, consider the
following query, that shows devices and their support dates:
foreach device in network.devices
let platform = device.platform
let osSupport = platform.osSupport
where isPresent(osSupport) && isPresent(device.snapshotInfo.collectionTime)
let collectionDate = date(device.snapshotInfo.collectionTime)
select {
Device: device.name,
Vendor: platform.vendor,
Model: platform.model,
OS: platform.os,
"OS Version": platform.osVersion,
"Collection Date": collectionDate,
"End of OS support": osSupport.lastSupportDate
}
To highlight the problem when the support date is past the current time, we can conditionally label the support date with an appropriate information label:
foreach device in network.devices
let platform = device.platform
let osSupport = platform.osSupport
where isPresent(osSupport) && isPresent(device.snapshotInfo.collectionTime)
let collectionDate = date(device.snapshotInfo.collectionTime)
select {
Device: device.name,
Vendor: platform.vendor,
Model: platform.model,
OS: platform.os,
"OS Version": platform.osVersion,
"Collection Date": collectionDate,
"End of OS support": withInfoStatus(osSupport.lastSupportDate,
if osSupport.lastSupportDate < collectionDate
then InfoStatus.ERROR
else InfoStatus.OK)
}