/
host.go
44 lines (40 loc) · 1.08 KB
/
host.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package netskope
import (
"fmt"
)
// Host is a host with its attributes.
type Host struct {
DeviceMake string `json:"device_make,omitempty"`
DeviceModel string `json:"device_model,omitempty"`
Hostname string `json:"hostname,omitempty"`
ManagementID string `json:"managementID,omitempty"`
OperatingSystemName string `json:"os,omitempty"`
OperatingSystemVersion string `json:"os_version,omitempty"`
NsDeviceUID string `json:"nsdeviceuid,omitempty"`
}
func (h *Host) load(m map[string]interface{}) error {
if m == nil {
return nil
}
for k, v := range m {
switch k {
case "device_make":
h.DeviceMake = v.(string)
case "device_model":
h.DeviceModel = v.(string)
case "hostname":
h.Hostname = v.(string)
case "managementID":
h.ManagementID = v.(string)
case "os":
h.OperatingSystemName = v.(string)
case "os_version":
h.OperatingSystemVersion = v.(string)
case "nsdeviceuid":
h.NsDeviceUID = v.(string)
default:
return fmt.Errorf("unsupported attribute: %s, %v", k, v)
}
}
return nil
}