chore: add default filters for host and host group queries

- Introduced `HOST_TYPE_FILTER_DEFAULT` and `HOST_GROUP_FILTER_DEFAULT` constants in the `Config` class.
- Updated resolvers to use these defaults when `tag_hostType` or `search_name` arguments are not provided.
- Added corresponding tests to verify default behavior in host and host group queries.
- Added documentation on overriding 'HOST_GROUP_FILTER_DEFAULT' by explicitly setting the 'search_name' argument in the 'allHostGroups' query.
- Explained the usage of the '*' wildcard in 'search_name' with a concrete example for subgroup matching.
This commit is contained in:
Andreas Hilbig 2026-01-27 18:44:44 +01:00
parent 2a8ff989f3
commit 5e41aa5cc4
5 changed files with 107 additions and 16 deletions

View file

@ -97,7 +97,9 @@ export function createResolvers(): Resolvers {
zabbixAuthToken,
cookie, dataSources
}: any) => {
args.tag_hostType ??= [ZABBIX_EDGE_DEVICE_BASE_GROUP];
if (Config.HOST_TYPE_FILTER_DEFAULT) {
args.tag_hostType ??= [Config.HOST_TYPE_FILTER_DEFAULT];
}
return await new ZabbixQueryHostsRequestWithItemsAndInventory(zabbixAuthToken, cookie)
.executeRequestThrowError(
dataSources.zabbixAPI, new ParsedArgs(args)
@ -107,8 +109,9 @@ export function createResolvers(): Resolvers {
zabbixAuthToken,
cookie, dataSources
}: any) => {
args.tag_hostType ??= [ZABBIX_EDGE_DEVICE_BASE_GROUP];
if (Config.HOST_TYPE_FILTER_DEFAULT) {
args.tag_hostType ??= [Config.HOST_TYPE_FILTER_DEFAULT];
}
return await new ZabbixQueryDevices(zabbixAuthToken, cookie)
.executeRequestThrowError(
dataSources.zabbixAPI, new ZabbixQueryDevicesArgs(args)
@ -118,8 +121,8 @@ export function createResolvers(): Resolvers {
zabbixAuthToken,
cookie
}: any) => {
if (!args.search_name) {
args.search_name = ZABBIX_EDGE_DEVICE_BASE_GROUP + "/*"
if (!args.search_name && Config.HOST_GROUP_FILTER_DEFAULT) {
args.search_name = Config.HOST_GROUP_FILTER_DEFAULT
}
return await new ZabbixQueryHostgroupsRequest(zabbixAuthToken, cookie).executeRequestThrowError(
zabbixAPI, new ZabbixQueryHostgroupsParams(args)