Valkyrian Labs logo

Queries

VDOMs, filters, field selection and paging with fortiapi::Query.

Queries

Every endpoint call takes an optional fortiapi::Query. Values are URL-encoded for you.

1using fortiapi::Query;2 3auto enabled = firewall::Policies::list(Query().filter("status==enable"));4auto names = firewall::Addresses::list(Query().format({"name", "subnet"}));5auto page = firewall::Addresses::list(Query().start(100).count(50));6auto dmz = firewall::Policies::list(Query().vdom("dmz"));

Query methods

MethodParameterUse
vdom(name)vdomTarget a VDOM (overrides Config::vdom)
filter(expression)filterFortiOS filter expression; repeated calls are combined with AND
format({fields...})formatReturn only these attributes (name|subnet)
start(n), count(n)start, countPaging
datasource()datasourceInclude datasource details
with_meta()with_metaInclude object metadata
skip()skipSkip attributes not applicable to the object
action(name)actionEndpoint actions such as schema or default
set(key, value)anyAny other parameter

Filter expressions

Filter expressions use FortiOS syntax, for example name==web, name=@web (contains) or status!=disable; separate alternatives with a comma inside one expression for OR.

ExpressionMeaning
name==webequals
status!=disabledoes not equal
name=@webcontains
name==web,name==maileither alternative (OR), within one expression
filter(...) called twiceboth expressions must match (AND)

Object keys

Object keys are always URL-encoded, so names with spaces or slashes work as-is:

1auto subnet = firewall::Addresses::get("LAN 10.0.0.0/24");

Each key is exactly one path segment. Dots inside a key stay readable (10.0.0.0%2F24), but a key that is exactly . or .. is sent as %2E or %2E%2E.

Why dot keys are encoded

Left literal, a key of . or .. would be a dot segment and address the table itself or its parent, so Addresses::del("..") could reach far more than one object. The transport sends paths exactly as built (libcurl never removes dot segments). Build paths for Client calls with fortiapi::path(base, keys...) to get the same encoding.