zabbix-graphql-api/schema/mutations.graphql
Andreas Hilbig ad104acde2 feat: add GroundValueChecker and WeatherSensorDevice with public API integration
This commit introduces two new device types, GroundValueChecker and WeatherSensorDevice, which leverage public APIs (BORIS NRW and Open-Meteo) for real-time data collection. It also includes several API enhancements and fixes to support these new integrations.

Detailed changes:
- **New Device Types**:
  - Added GroundValueChecker schema and integration with BORIS NRW WMS via Zabbix Script items.
  - Added WeatherSensorDevice schema and integration with Open-Meteo via Zabbix HTTP Agent items.
- **API Enhancements**:
  - Added error field to ZabbixItem for item-level error reporting.
  - Updated CreateTemplateItem mutation input to support params (for Script items) and timeout.
  - Registered missing scalar resolvers: JSONObject, DateTime, and Time.
- **Performance & Reliability**:
  - Implemented batch fetching for item preprocessing in both host and template queries to reduce Zabbix API calls and ensure data visibility.
  - Updated template_importer.ts to correctly handle Script item parameters.
- **Documentation**:
  - Consolidated public API device recipes in docs/howtos/cookbook.md.
  - Added guidance on analyzing data update frequency and setting reasonable update intervals (e.g., 1h for weather, 1d for ground values).
- **Testing**:
  - Added new regression test REG-ITEM-META to verify item metadata (units, description, error, preprocessing) and JSONObject scalar support.
  - Enhanced RegressionTestExecutor with more detailed host-item relationship verification.
2026-02-01 21:07:21 +01:00

777 lines
16 KiB
GraphQL

type Mutation {
"""
Creates a single host in Zabbix.
Authentication: Requires `zbx_session` cookie or `zabbix-auth-token` header.
"""
createHost(
"""Hostname of the new host."""
host: String!,
"""List of host group IDs to assign the host to."""
hostgroupids:[Int!]!,
"""List of template IDs to link to the host."""
templateids: [Int],
"""List of template names to link to the host."""
templateNames: [String],
"""Optional location information for the host inventory."""
location: LocationInput
): CreateHostResponse
"""
(Mass) Import Zabbix host groups and assign them to the corresponding hosts by groupid or groupName.
Return value: If no error occurs, a groupid is returned for each created group; otherwise, the return object contains an error message.
Authentication: Requires `zbx_session` cookie or `zabbix-auth-token` header.
"""
importHostGroups(
"""List of host groups to import."""
hostGroups: [CreateHostGroup!]!
):[CreateHostGroupResponse!]
"""
(Mass) Import hosts and assign them to host groups by groupid or groupName.
Return value: If no error occurs, a hostid is returned for each created host; otherwise, the return object contains an error message.
Authentication: Requires `zbx_session` cookie or `zabbix-auth-token` header.
"""
importHosts(
"""List of hosts to import."""
hosts: [CreateHost!]!
):[ImportHostResponse!]
"""
Import user rights (roles and groups) into Zabbix.
Authentication: Requires `zbx_session` cookie or `zabbix-auth-token` header.
"""
importUserRights(
"""User rights configuration to import."""
input: UserRightsInput!,
"""If true, only validates the input without applying changes."""
dryRun: Boolean! = true
): ImportUserRightsResult
"""
(Mass) Import template groups and assign them by groupid or name.
Return value: If no error occurs, a groupid is returned for each created group; otherwise, the return object contains an error message.
Authentication: Requires `zbx_session` cookie or `zabbix-auth-token` header.
"""
importTemplateGroups(
"""List of template groups to import."""
templateGroups: [CreateTemplateGroup!]!
):[CreateTemplateGroupResponse!]
"""
(Mass) Import templates.
Return value: If no error occurs, a templateid is returned for each created template; otherwise, the return object contains an error message.
Authentication: Requires `zbx_session` cookie or `zabbix-auth-token` header.
"""
importTemplates(
"""List of templates to import."""
templates: [CreateTemplate!]!
):[ImportTemplateResponse!]
"""
Delete templates by their IDs or by a name pattern.
Authentication: Requires `zbx_session` cookie or `zabbix-auth-token` header.
"""
deleteTemplates(
"""List of template IDs to delete."""
templateids: [Int!],
"""Wildcard name pattern for templates to delete (e.g. 'Template%')."""
name_pattern: String
): [DeleteResponse!]
"""
Delete template groups by their IDs or by a name pattern.
Authentication: Requires `zbx_session` cookie or `zabbix-auth-token` header.
"""
deleteTemplateGroups(
"""List of template group IDs to delete."""
groupids: [Int!],
"""Wildcard name pattern for template groups to delete."""
name_pattern: String
): [DeleteResponse!]
"""
Delete hosts by their IDs or by a name pattern.
Authentication: Requires `zbx_session` cookie or `zabbix-auth-token` header.
"""
deleteHosts(
"""List of host IDs to delete."""
hostids: [Int!],
"""Wildcard name pattern for hosts to delete."""
name_pattern: String
): [DeleteResponse!]
"""
Delete host groups by their IDs or by a name pattern.
Authentication: Requires `zbx_session` cookie or `zabbix-auth-token` header.
"""
deleteHostGroups(
"""List of host group IDs to delete."""
groupids: [Int!],
"""Wildcard name pattern for host groups to delete."""
name_pattern: String
): [DeleteResponse!]
"""
Runs a smoketest: creates a template, links a host, verifies it, and cleans up.
"""
runSmoketest(
"""Technical name for the smoketest host."""
hostName: String!,
"""Technical name for the smoketest template."""
templateName: String!,
"""Technical name for the smoketest host group."""
groupName: String!
): SmoketestResponse!
"""
Runs all regression tests.
"""
runAllRegressionTests(
"""Technical name for the test host."""
hostName: String!,
"""Technical name for the test host group."""
groupName: String!
): SmoketestResponse!
}
"""
Response object for the smoketest operation.
"""
type SmoketestResponse {
"""
True if all steps of the smoketest succeeded.
"""
success: Boolean!
"""
Overall status message.
"""
message: String
"""
Detailed results for each step.
"""
steps: [SmoketestStep!]!
}
"""
Results for a single step in the smoketest.
"""
type SmoketestStep {
"""
Name of the step (e.g. 'Create Template').
"""
name: String!
"""
True if the step succeeded.
"""
success: Boolean!
"""
Status message or error message for the step.
"""
message: String
}
####################################################################
# Input types used for importXXX - and storeXXX - Mutations
####################################################################
"""
Response object for delete operations.
"""
type DeleteResponse {
"""
ID of the deleted entity.
"""
id: Int!
"""
Status message for the delete operation.
"""
message: String
"""
Error information if the deletion failed.
"""
error: ApiError
}
"""
Input for creating or identifying a template group.
"""
input CreateTemplateGroup {
"""
Name of the template group.
"""
groupName: String!
"""
Internally used unique id (will be assigned by Zabbix if empty).
"""
uuid: String
}
"""
Input for creating or updating a template.
"""
input CreateTemplate {
"""
Technical name of the template.
"""
host: String!
"""
Visible name of the template.
"""
name: String
"""
List of template group names to assign the template to.
"""
groupNames: [String!]!
"""
Optionally, internal group IDs can be provided instead of group names.
"""
groupids: [Int]
"""
Internally used unique id (will be assigned by Zabbix if empty).
"""
uuid: String
"""
List of items to create within the template.
"""
items: [CreateTemplateItem!]
"""
List of other templates to link to this template.
"""
templates: [CreateLinkedTemplate!]
"""
Tags to assign to the template.
"""
tags: [CreateTag!]
"""
User macros to assign to the template.
"""
macros: [CreateMacro!]
}
"""
Input for creating an item within a template.
"""
input CreateTemplateItem {
"""
Internally used unique id.
"""
uuid: String
"""
Name of the item.
"""
name: String!
"""
Zabbix item type (e.g. 0 for Zabbix Agent, 18 for Dependent).
"""
type: Int
"""
Zabbix item status (0 for Enabled, 1 for Disabled).
"""
status: Int
"""
Technical key of the item.
"""
key: String!
"""
Type of information (e.g. 0 for Float, 3 for Int, 4 for Text).
"""
value_type: Int
"""
History storage period (e.g. '2d', '90d').
"""
history: String
"""
Units of the value.
"""
units: String
"""
Update interval.
"""
delay: String
"""
Description of the item.
"""
description: String
"""
URL for HTTP Agent items.
"""
url: String
"""
JavaScript code for Script items or other parameters.
"""
params: String
"""
Timeout for item data collection.
"""
timeout: String
"""
Preprocessing steps for the item values.
"""
preprocessing: [CreateItemPreprocessing!]
"""
Tags to assign to the item.
"""
tags: [CreateTag!]
"""
Reference to a master item if this is a dependent item.
"""
master_item: CreateMasterItem
}
"""
Reference to a master item for dependent items.
"""
input CreateMasterItem {
"""
The technical key of the master item.
"""
key: String!
}
"""
Input for an item preprocessing step.
"""
input CreateItemPreprocessing {
"""
Type of preprocessing step (e.g. 12 for JSONPath, 21 for JavaScript).
"""
type: Int!
"""
Parameters for the preprocessing step.
"""
params: [String!]!
"""
Error handling behavior.
"""
error_handler: Int
"""
Error handling parameters.
"""
error_handler_params: String
}
"""
Reference to a template to be linked.
"""
input CreateLinkedTemplate {
"""
The technical name of the template to link.
"""
name: String!
}
"""
Input for a tag.
"""
input CreateTag {
"""
Tag name.
"""
tag: String!
"""
Tag value.
"""
value: String
}
"""
Input for creating a user macro.
"""
input CreateMacro {
"""
Macro name (e.g. '{$LAT}').
"""
macro: String!
"""
Macro value.
"""
value: String!
}
"""
Response for a template import operation.
"""
type ImportTemplateResponse {
"""
The technical name of the imported template.
"""
host: String!
"""
The Zabbix template ID assigned to the template.
"""
templateid: String
"""
Status message for the import.
"""
message: String
"""
Error information if the import failed.
"""
error: ApiError
}
"""
Response for a template group import operation.
"""
type CreateTemplateGroupResponse {
"""
Name of the imported template group.
"""
groupName: String!
"""
The Zabbix group ID assigned to the group.
"""
groupid: Int
"""
Status message for the import.
"""
message: String
"""
Error information if the import failed.
"""
error: ApiError
}
"""
Input for creating or identifying a host group.
"""
input CreateHostGroup {
"""
Name of the host group.
"""
groupName: String!
"""
Internally used unique id (will be assigned by Zabbix if empty).
"""
uuid: String
}
"""
Response for a host import operation.
"""
type ImportHostResponse {
"""
The device key (technical name) of the imported host.
"""
deviceKey: String!
"""
The Zabbix host ID assigned to the host.
"""
hostid: String
"""
Status message for the import.
"""
message: String
"""
Error information if the import failed.
"""
error: ApiError
}
"""
Response for a host group import operation.
"""
type CreateHostGroupResponse {
"""
Name of the imported host group.
"""
groupName: String!
"""
The Zabbix group ID assigned to the group.
"""
groupid: Int
"""
Status message for the import.
"""
message: String
"""
Error information if the import failed.
"""
error: ApiError
}
"""
Input for creating a new host.
"""
input CreateHost {
"""
Technical name of the host/device.
"""
deviceKey: String!
"""
Optional display name of the device (must be unique if provided - default is to set display name to deviceKey).
"""
name: String
"""
Classification or category of the device.
"""
deviceType: String!
"""
List of host group names to assign the host to.
"""
groupNames: [String!]!
"""
Optionally, internal group IDs can be provided instead of group names.
"""
groupids: [Int]
"""
List of template IDs to link to the host.
"""
templateids: [Int]
"""
List of template names to link to the host.
"""
templateNames: [String]
"""
Location information for the host.
"""
location: LocationInput
"""
User macros to assign to the host.
"""
macros: [CreateMacro!]
}
"""
Response for a single host creation operation.
"""
type CreateHostResponse {
"""
List of created host IDs.
"""
hostids: [Int]
"""
List of created item IDs.
"""
itemids: [Int]
"""
Error information if the creation failed.
"""
error: ApiError
}
"""
Input for host location information.
"""
input LocationInput {
"""
Name of the location.
"""
name: String
"""
Latitude coordinate.
"""
location_lat: String
"""
Longitude coordinate.
"""
location_lon: String
}
"""
Input for importing user rights.
"""
input UserRightsInput {
"""
List of user roles to import.
"""
userRoles: [UserRoleInput!]
"""
List of user groups to import.
"""
userGroups: [UserGroupInput!]
}
"""
Input for a user role.
"""
input UserRoleInput {
"""
Name of the role.
"""
name: String
"""
Type of role (e.g. 1 for User, 2 for Admin, 3 for Super Admin).
"""
type: Int
"""
Whether the role is read-only (1) or not (0).
"""
readonly: Int
"""
Specific rules for the role.
"""
rules: UserRoleRulesInput
}
"""
Input for user role rules.
"""
input UserRoleRulesInput {
"""
UI access rules.
"""
ui: [UserRoleRuleInput!]
"""
Default access for UI elements.
"""
ui_default_access: Int
"""
Module access rules.
"""
modules:[UserRoleModuleInput!]
"""
Default access for modules.
"""
modules_default_access: Int
"""
Whether API access is enabled (1) or not (0).
"""
api_access: Int
"""
API mode (e.g. 0 for white-list, 1 for black-list).
"""
api_mode: Int
"""
List of API methods allowed/denied.
"""
api: [String!]
"""
Action rules.
"""
actions: [UserRoleRuleInput!]
"""
Default access for actions.
"""
actions_default_access: Int
}
"""
Input for a single user role rule.
"""
input UserRoleRuleInput {
"""
Name of the rule/element.
"""
name: String
"""
Status (e.g. 1 for enabled, 0 for disabled).
"""
status: Int
}
"""
Input for user role module access.
"""
input UserRoleModuleInput {
"""
The internal Zabbix module ID.
"""
moduleid: String
"""
Status of the module.
"""
status: Int
"""
Technical ID of the module.
"""
id: String
}
"""
Input for a user group.
"""
input UserGroupInput {
"""
Name of the user group.
"""
name: String!
"""
Frontend access level.
"""
gui_access: Int
"""
Status of the users in the group.
"""
users_status: Int
"""
Permissions for host groups.
"""
hostgroup_rights: [ZabbixGroupRightInput!]
"""
Permissions for template groups.
"""
templategroup_rights: [ZabbixGroupRightInput!]
}
"""
Input for a Zabbix group permission right.
"""
input ZabbixGroupRightInput {
"""
The unique ID of the group.
"""
uuid: String
"""
Name may optionally be specified for documentation purpose,
but the master for setting the user right is the uuid.
"""
name: String
"""
The permission level to assign.
"""
permission: Permission
}
"""
Result of a user rights import operation.
"""
type ImportUserRightsResult {
"""
Results for the imported user roles.
"""
userRoles: [ImportUserRightResult!]
"""
Results for the imported user groups.
"""
userGroups: [ImportUserRightResult!]
}
"""
Result of a single user right (role or group) import.
"""
type ImportUserRightResult {
"""
The ID of the imported/updated entity.
"""
id: String
"""
The name of the entity.
"""
name: String
"""
Status message for the import.
"""
message: String
"""
List of errors encountered during import.
"""
errors: [ApiError!]
}