Skip to content

Commit

Permalink
Fix HostsDeleteByIds request due to documentation (#11)
Browse files Browse the repository at this point in the history
* 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 <artem.kravchenko@exness.com>
  • Loading branch information
scytem and Artem Kravchenko authored Sep 28, 2022
1 parent 6da9204 commit 6f429ab
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions host.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6f429ab

Please sign in to comment.