5 // Host represents a Host object. To create a Host, the Name and CheckCommand
9 Address string `json:"address"`
10 Address6 string `json:"address6"`
11 Groups []string `json:"groups,omitempty"`
12 State HostState `json:"state,omitempty"`
13 StateType StateType `json:"state_type,omitempty"`
14 CheckCommand string `json:"check_command"`
15 DisplayName string `json:"display_name,omitempty"`
16 Acknowledgement bool `json:",omitempty"`
19 type HostGroup struct {
20 Name string `json:"-"`
21 DisplayName string `json:"display_name"`
27 HostUp HostState = 0 + iota
32 func (state HostState) String() string {
39 return "HostUnreachable"
42 func (h Host) name() string {
46 func (h Host) path() string {
47 return "/objects/hosts/" + h.Name
50 func (hg HostGroup) name() string {
54 func (hg HostGroup) path() string {
55 return "/objects/hostgroups/" + hg.Name
58 // UnmarhsalJSON unmarshals host attributes into more meaningful Host field types.
59 func (h *Host) UnmarshalJSON(data []byte) error {
67 if err := json.Unmarshal(data, &aux); err != nil {
70 if aux.Acknowledgement != 0 {
71 h.Acknowledgement = true