From 6f429ab92d328040e8af8ccec632c69706046c6d Mon Sep 17 00:00:00 2001 From: Artyom Kravchenko Date: Wed, 28 Sep 2022 12:38:50 +0300 Subject: [PATCH] Fix HostsDeleteByIds request due to documentation (#11) * Update host requests due to documentation Fix request body to delete hosts by IDs. https://www.zabbix.com/documentation/6.0/en/manual/api/reference/host/delete#:~:text=Examples-,Deleting%20multiple%20hosts,-Delete%20two%20hosts Here we don't need hostids key. So it's just converted to list of ids. * refactor hostids Co-authored-by: Artem Kravchenko --- host.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/host.go b/host.go index 37916eb..95e4757 100644 --- a/host.go +++ b/host.go @@ -145,12 +145,7 @@ func (api *API) HostsDelete(hosts Hosts) (err error) { // HostsDeleteByIds Wrapper for host.delete // https://www.zabbix.com/documentation/3.2/manual/api/reference/host/delete func (api *API) HostsDeleteByIds(ids []string) (err error) { - hostIds := make([]map[string]string, len(ids)) - for i, id := range ids { - hostIds[i] = map[string]string{"hostid": id} - } - - response, err := api.CallWithError("host.delete", hostIds) + response, err := api.CallWithError("host.delete", ids) if err != nil { // Zabbix 2.4 uses new syntax only if e, ok := err.(*Error); ok && e.Code == -32500 {