Skip to content
This repository has been archived by the owner on Apr 11, 2019. It is now read-only.

Commit

Permalink
Fix hosts deletion on Zabbix 2.4.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekSi committed Dec 29, 2015
1 parent 0e342a0 commit 021bc5e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion host.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,20 @@ func (api *API) HostsDelete(hosts Hosts) (err error) {
return
}

// Wrapper for host.delete: https://www.zabbxix.com/documentation/2.2/manual/appendix/api/host/delete
// Wrapper for host.delete: https://www.zabbix.com/documentation/2.2/manual/appendix/api/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)
if err != nil {
// Zabbix 2.4 uses new syntax only
if e, ok := err.(*Error); ok && e.Code == -32500 {
response, err = api.CallWithError("host.delete", ids)
}
}
if err != nil {
return
}
Expand Down

0 comments on commit 021bc5e

Please sign in to comment.