package unipede import ( "net/http" ) type ( SwitchData struct { Chassis string `json:"chassis_model" bson:"chassis_model"` CoreId int `json:"core_id" bson:"core_id"` Created string `json:"created" bson:"created"` DC string `json:"dc" bson:"dc"` Depth int `json:"depth" bson:"depth"` Errors []Error `json:"errors" bson:"errors"` HostName string `json:"hostname" bson:"hostname"` Id int `json:"id" bson:"id"` Links map[string]Links `json:"links" bson:"links"` ManagementIP string `json:"management_ip" bson:"management_ip"` Role string `json:"role" bson:"role"` Service string `json:"service" bson:"service"` OSVersion string `json:"os_version" bson:"os_version"` PathNorth string `json:"path_north" bson:"path_north"` Updated string `json:"updated" bson:"updated"` ZenossState string `json:"zenoss_state" bson:"zenoss_state"` ZenossUid string `json:"zenoss_uid" bson:"zenoss_uid"` ZenossUuid string `json:"zenoss_uuid" bson:"zenoss_uuid"` } ) //Return base data for a switch func (u *Client) SwitchData(sw string, options ...*UnipedeOptions) (*SwitchData, error) { o := processOptions(nil, nil, options...) req, err := u.newRequest(unipedeURL+"devices/"+sw, http.MethodGet, o, nil) if err != nil { return nil, err } swData := new(SwitchData) _, err = u.do(req, o, swData) return swData, err } func (d *SwitchData) GetLink(item string) string { if val, ok := d.Links[item]; ok { return *val.Href } return "" } // function retained for bw compat func (s *SwitchData) IPString() string { return s.ManagementIP }