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

add HostTemplate #13

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions host.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Host struct {
// Fields below used only when creating hosts
GroupIds HostGroupIds `json:"groups,omitempty"`
Interfaces HostInterfaces `json:"interfaces,omitempty"`
Templates HostTemplates `json:"templates,omitempty"`
}

type Hosts []Host
Expand Down
7 changes: 7 additions & 0 deletions host_template.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package zabbix

type HostTemplate struct {
TemplateId string `json:"templateid"`
}

type HostTemplates []HostTemplate
5 changes: 4 additions & 1 deletion host_test.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
package zabbix_test

import (
. "."
"fmt"
"math/rand"
"reflect"
"testing"

. "."
)

func CreateHost(group *HostGroup, t *testing.T) *Host {
name := fmt.Sprintf("%s-%d", getHost(), rand.Int())
iface := HostInterface{DNS: name, Port: "42", Type: Agent, UseIP: 0, Main: 1}
template := HostTemplate{TemplateId: "42"}
hosts := Hosts{{
Host: name,
Name: "Name for " + name,
GroupIds: HostGroupIds{{group.GroupId}},
Interfaces: HostInterfaces{iface},
Templates: HostTemplates{template},
}}

err := getAPI(t).HostsCreate(hosts)
Expand Down