package api import ( "time" ) // Neighbours type Neighbours []*Neighbour type Neighbour struct { Id string `json:"id"` // Mandatory fields Address string `json:"address"` Asn int `json:"asn"` State string `json:"state"` Description string `json:"description"` RoutesReceived int `json:"routes_received"` RoutesFiltered int `json:"routes_filtered"` RoutesExported int `json:"routes_exported"` RoutesPreferred int `json:"routes_preferred"` RoutesAccepted int `json:"routes_accepted"` RoutesPipeFiltered int `json:"routes_pipe_filtered"` Uptime time.Duration `json:"uptime"` LastError string `json:"last_error"` // Original response Details map[string]interface{} `json:"details"` } // Implement sorting interface for routes func (neighbours Neighbours) Len() int { return len(neighbours) } func (neighbours Neighbours) Less(i, j int) bool { return neighbours[i].Asn < neighbours[j].Asn } func (neighbours Neighbours) Swap(i, j int) { neighbours[i], neighbours[j] = neighbours[j], neighbours[i] } type NeighboursResponse struct { Api ApiStatus `json:"api"` Neighbours Neighbours `json:"neighbours"` } // Neighbours response is cacheable func (self *NeighboursResponse) CacheTtl() time.Duration { now := time.Now().UTC() return self.Api.Ttl.Sub(now) } type NeighboursLookupResults map[string]Neighbours