From 2b849a03bdd2cfd70d4a03542ed6b785d35ce1d3 Mon Sep 17 00:00:00 2001 From: Tom Morelly Date: Wed, 5 Apr 2023 16:54:23 +0200 Subject: [PATCH 1/2] feat(hosts): support host macros --- host.go | 1 + macro.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/host.go b/host.go index d5bfd41..850288c 100644 --- a/host.go +++ b/host.go @@ -38,6 +38,7 @@ type Host struct { // Fields below used only when creating hosts GroupIds HostGroupIDs `json:"groups,omitempty"` + UserMacros Macros `json:"macros,omitempty"` Interfaces HostInterfaces `json:"interfaces,omitempty"` TemplateIDs TemplateIDs `json:"templates,omitempty"` } diff --git a/macro.go b/macro.go index 5964155..39b4416 100644 --- a/macro.go +++ b/macro.go @@ -4,7 +4,7 @@ package zabbix // https://www.zabbix.com/documentation/3.2/manual/api/reference/usermacro/object type Macro struct { MacroID string `json:"hostmacroids,omitempty"` - HostID string `json:"hostid"` + HostID string `json:"hostid,omitemptry"` MacroName string `json:"macro"` Value string `json:"value"` } From 2a46457c908cd46258bc1b7ddc4c0f442ce6f392 Mon Sep 17 00:00:00 2001 From: Tom Morelly Date: Wed, 5 Apr 2023 16:54:59 +0200 Subject: [PATCH 2/2] gofumpt --- host.go | 2 +- item.go | 4 ++-- lld_rule.go | 2 +- macro.go | 2 +- trigger.go | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/host.go b/host.go index 850288c..ffaf397 100644 --- a/host.go +++ b/host.go @@ -38,7 +38,7 @@ type Host struct { // Fields below used only when creating hosts GroupIds HostGroupIDs `json:"groups,omitempty"` - UserMacros Macros `json:"macros,omitempty"` + UserMacros Macros `json:"macros,omitempty"` Interfaces HostInterfaces `json:"interfaces,omitempty"` TemplateIDs TemplateIDs `json:"templates,omitempty"` } diff --git a/item.go b/item.go index 5bb0ed9..73685be 100644 --- a/item.go +++ b/item.go @@ -44,7 +44,7 @@ const ( ExternalCheck ItemType = 10 // DatabaseMonitor type DatabaseMonitor ItemType = 11 - //IPMIAgent type + // IPMIAgent type IPMIAgent ItemType = 12 // SSHAgent type SSHAgent ItemType = 13 @@ -58,7 +58,7 @@ const ( SNMPTrap ItemType = 17 // DependentItem type (new in 3.4) DependentItem ItemType = 18 - //HTTPAgent type (new in 4.0) + // HTTPAgent type (new in 4.0) HTTPAgent ItemType = 19 ) diff --git a/lld_rule.go b/lld_rule.go index 393336d..45736e8 100644 --- a/lld_rule.go +++ b/lld_rule.go @@ -34,7 +34,7 @@ type LLDRule struct { AuthType string `json:"authtype,omitempty"` DelayFlex string `json:"delay_flex,omitempty"` Description string `json:"description,omitempty"` - Error string `json:"error,omitempty"` //Readonly + Error string `json:"error,omitempty"` // Readonly IpmiSensor string `json:"ipmi_sensor,omitempty"` LifeTime string `json:"lifetime,omitempty"` Params string `json:"params,omitempty"` diff --git a/macro.go b/macro.go index 39b4416..55747e3 100644 --- a/macro.go +++ b/macro.go @@ -63,7 +63,7 @@ func (api *API) MacrosUpdate(macros Macros) (err error) { // MacrosDeleteByIDs Wrapper for usermacro.delete // Cleans MacroId in all macro elements if call succeed. -//https://www.zabbix.com/documentation/3.2/manual/api/reference/usermacro/delete +// https://www.zabbix.com/documentation/3.2/manual/api/reference/usermacro/delete func (api *API) MacrosDeleteByIDs(ids []string) (err error) { response, err := api.CallWithError("usermacro.delete", ids) diff --git a/trigger.go b/trigger.go index 15676a0..526a40d 100644 --- a/trigger.go +++ b/trigger.go @@ -57,8 +57,8 @@ type Trigger struct { Description string `json:"description"` Expression string `json:"expression"` Comments string `json:"comments"` - //TemplateId string `json:"templateid"` - //Value ValueType `json:""` + // TemplateId string `json:"templateid"` + // Value ValueType `json:""` Priority SeverityType `json:"priority,string"` Status StatusType `json:"status,string"`