initial commit
This commit is contained in:
40
model/ap_info.go
Normal file
40
model/ap_info.go
Normal file
@ -0,0 +1,40 @@
|
||||
package model
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type ApInfo struct {
|
||||
Type string `json:"type"`
|
||||
MacAddress string `json:"mac"`
|
||||
Name string `json:"name"`
|
||||
IP string `json:"ip"`
|
||||
IPv6 []string `json:"ipv6List"`
|
||||
WlanGroupID string `json:"wlanId"`
|
||||
WirelessUplinkInfo *ApWirelessUplinkInfo `json:"wirelessUplink"`
|
||||
Model string `json:"model"`
|
||||
FirmwareVersion string `json:"firmwareVersion"`
|
||||
CpuUtil int `json:"cpuUtil"`
|
||||
MemUtil int `json:"memoryUtil"`
|
||||
UptimeSeconds int `json:"uptimeLong"`
|
||||
}
|
||||
|
||||
func (i ApInfo) String() string {
|
||||
data, _ := json.MarshalIndent(i, "", "\t")
|
||||
return string(data)
|
||||
}
|
||||
|
||||
type ApWirelessUplinkInfo struct {
|
||||
UplinkMacAddress string `json:"uplinkMac"`
|
||||
Name string `json:"name"`
|
||||
Channel int `json:"channel"`
|
||||
SignalStrengh int `json:"rssi"`
|
||||
SignalNoiseRatio int `json:"snr"`
|
||||
TransferRate string `json:"txRate"`
|
||||
TransferRateMbps int `json:"txRateInt"`
|
||||
ReceiveRate string `json:"rxRate"`
|
||||
ReceiveRateMbps int `json:"rxRateInt"`
|
||||
UpBytes int `json:"upBytes"`
|
||||
DownBytes int `json:"downBytes"`
|
||||
UpPackets int `json:"upPackets"`
|
||||
DownPackets int `json:"downPackets"`
|
||||
Activity int `json:"activity"`
|
||||
}
|
209
model/client.go
Normal file
209
model/client.go
Normal file
@ -0,0 +1,209 @@
|
||||
package model
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type Client struct {
|
||||
ID string `json:"id"`
|
||||
MacAddress string `json:"mac"`
|
||||
Name string `json:"name"`
|
||||
Hostname string `json:"hostName"`
|
||||
Vendor string `json:"vendor"`
|
||||
DeviceType string `json:"deviceType"`
|
||||
DeviceCategory string `json:"deviceCategory"`
|
||||
OsName string `json:"osName"`
|
||||
IP string `json:"ip"`
|
||||
IPv6List []string `json:"ipv6List"`
|
||||
ConnectionType ConnectionType `json:"connectType"`
|
||||
ConnectionDevType ConnectionDeviceType `json:"connectDevType"`
|
||||
ConnectedToWirelessRouter bool `json:"connectedToWirelessRouter"`
|
||||
Wireless bool `json:"wireless"`
|
||||
SSID string `json:"ssid"`
|
||||
SignalLevel int `json:"signalLevel"`
|
||||
HealthScore int `json:"healthScore"`
|
||||
SignalRank int `json:"signalRank"`
|
||||
WifiMode WifiMode `json:"wifiMode"`
|
||||
ApName string `json:"apName"`
|
||||
ApMac string `json:"apMac"`
|
||||
RadioID RadioID `json:"radioId"`
|
||||
Channel int `json:"channel"`
|
||||
ReceiveRateKbits int `json:"rxRate"`
|
||||
TransferRateKbits int `json:"txRate"`
|
||||
PowerSave bool `json:"powerSave"`
|
||||
SignalStrengh int `json:"rssi"`
|
||||
SignalNoiseRatio int `json:"snr"`
|
||||
SwitchMac string `json:"switchMac"`
|
||||
SwitchName string `json:"switchName"`
|
||||
GatewayMac string `json:"gatewayMac"`
|
||||
GatewayName string `json:"gatewayName"`
|
||||
VLanID int `json:"vid"`
|
||||
NetworkName string `json:"networkName"`
|
||||
Dot1xIdentity string `json:"dot1xIdentity"`
|
||||
Dot1xVlan int `json:"dot1xVlan"`
|
||||
Port int `json:"port"`
|
||||
LagID int `json:"lagId"`
|
||||
Activity int `json:"activity"`
|
||||
TrafficDownBytes int `json:"trafficDown"`
|
||||
TrafficUpBytes int `json:"trafficUp"`
|
||||
UptimeSeconds int `json:"uptime"`
|
||||
LastSeen int `json:"lastSeen"`
|
||||
AuthStatus AuthStatus `json:"authStatus"`
|
||||
Blocked bool `json:"blocked"`
|
||||
Guest bool `json:"guest"`
|
||||
Active bool `json:"active"`
|
||||
Manager bool `json:"manager"`
|
||||
IpSetting *ClientIpSetting `json:"ipSetting"`
|
||||
DownPacket int `json:"downPacket"`
|
||||
UpPacket int `json:"upPacket"`
|
||||
RateLimit *ClientRateLimit `json:"rateLimit"`
|
||||
ClientLockToApSetting *ClientLockToApSetting `json:"clientLockToApSetting"`
|
||||
MultiLink []*ClientMultiFrequencyInfo `json:"multiLink"`
|
||||
Unit int `json:"unit"`
|
||||
StandardPort string `json:"standardPort"`
|
||||
BlockDisable bool `json:"blockDisable"`
|
||||
DhcpLeaseTimeSeconds int `json:"dhcpLeaseTime"`
|
||||
SystemName string `json:"systemName"`
|
||||
Description string `json:"description"`
|
||||
Capabilities []string `json:"capabilities"`
|
||||
ClientStat *ClientStat `json:"clientStat"`
|
||||
}
|
||||
|
||||
func (c Client) String() string {
|
||||
data, _ := json.MarshalIndent(c, "", "\t")
|
||||
return string(data)
|
||||
}
|
||||
|
||||
type ConnectionType int
|
||||
|
||||
const (
|
||||
ConnectionTypeWirelessGuest ConnectionType = iota
|
||||
ConnectionTypeWirelessUser
|
||||
ConnectionTypeWiredUser
|
||||
)
|
||||
|
||||
type ConnectionDeviceType string
|
||||
|
||||
const (
|
||||
ConnectionDeviceTypeAP ConnectionDeviceType = "ap"
|
||||
ConnectionDeviceTypeSwitch ConnectionDeviceType = "switch"
|
||||
ConnectionDeviceTypeGateway ConnectionDeviceType = "gateway"
|
||||
)
|
||||
|
||||
type WifiMode int
|
||||
|
||||
const (
|
||||
WifiMode11a WifiMode = iota
|
||||
WifiMode11b
|
||||
WifiMode11g
|
||||
WifiMode11na
|
||||
WifiMode11ng
|
||||
WifiMode11ac
|
||||
WifiMode11axa
|
||||
WifiMode11axg
|
||||
WifiMode11beg
|
||||
WifiMode11bea
|
||||
)
|
||||
|
||||
type RadioID int
|
||||
|
||||
const (
|
||||
RadioID_2_4G RadioID = iota
|
||||
RadioID_5G RadioID = iota
|
||||
RadioID_5G2 RadioID = iota
|
||||
RadioID_6G RadioID = iota
|
||||
)
|
||||
|
||||
type AuthStatus int
|
||||
|
||||
const (
|
||||
AuthStatusConnected AuthStatus = iota
|
||||
AuthStatusPending
|
||||
AuthStatusAuthorized
|
||||
AuthStatusAuthFree
|
||||
)
|
||||
|
||||
type ClientIpSetting struct {
|
||||
UseFixedAddr bool `json:"useFixedAddr"`
|
||||
NetID string `json:"netId"`
|
||||
IP string `json:"ip"`
|
||||
}
|
||||
|
||||
type ClientRateLimit struct {
|
||||
Mode RateLimitMode `json:"mode"`
|
||||
RateLimitProfileID string `json:"rateLimitProfileId"`
|
||||
CustomRateLimit *CustomRateLimit `json:"customRateLimit"`
|
||||
}
|
||||
|
||||
type RateLimitMode int
|
||||
|
||||
const (
|
||||
RateLimitModeCustom RateLimitMode = iota
|
||||
RateLimitModeProfile
|
||||
)
|
||||
|
||||
type CustomRateLimit struct {
|
||||
UpEnable bool `json:"upEnable"`
|
||||
UpUnit SpeedUnit `json:"upUnit"`
|
||||
UpLimit int `json:"upLimit"`
|
||||
DownEnable bool `json:"downEnable"`
|
||||
DownUnit SpeedUnit `json:"downUnit"`
|
||||
DownLimit int `json:"downLimit"`
|
||||
}
|
||||
|
||||
type SpeedUnit int
|
||||
|
||||
const (
|
||||
SpeedUnitKbps SpeedUnit = iota
|
||||
SpeedUnitMbps
|
||||
)
|
||||
|
||||
type ClientLockToApSetting struct {
|
||||
Enable bool `json:"enable"`
|
||||
APs []*ApBriefInfo `json:"aps"`
|
||||
}
|
||||
|
||||
type ApBriefInfo struct {
|
||||
Name string `json:"name"`
|
||||
MacAddress string `json:"mac"`
|
||||
}
|
||||
|
||||
type ClientMultiFrequencyInfo struct {
|
||||
RadioID int `json:"radioId"`
|
||||
WifiMode WifiMode `json:"wifiMode"`
|
||||
Channel int `json:"channel"`
|
||||
ReceiveRateKbits int `json:"rxRate"`
|
||||
TransferRateKbits int `json:"txRate"`
|
||||
PowerSave bool `json:"powerSave"`
|
||||
SignalStrengh int `json:"rssi"`
|
||||
SignalNoiseRatio int `json:"snr"`
|
||||
SignalLevel int `json:"signalLevel"`
|
||||
SignalRank int `json:"signalRank"`
|
||||
UpPacket int `json:"upPacket"`
|
||||
DownPacket int `json:"downPacket"`
|
||||
TrafficDownBytes int `json:"trafficDown"`
|
||||
TrafficUpBytes int `json:"trafficUp"`
|
||||
Activity int `json:"activity"`
|
||||
SignalLevelAndRank int `json:"signalLevelAndRank"`
|
||||
}
|
||||
|
||||
type ClientStat struct {
|
||||
Total int `json:"total"`
|
||||
Wireless int `json:"wireless"`
|
||||
Wired int `json:"wired"`
|
||||
Num2G int `json:"num2g"`
|
||||
Num5G int `json:"num5g"`
|
||||
Num6G int `json:"num6g"`
|
||||
NumUser int `json:"numUser"`
|
||||
NumGuest int `json:"numGuest"`
|
||||
NumWirelessUser int `json:"numWirelessUser"`
|
||||
NumWirelessGuest int `json:"numWirelessGuest"`
|
||||
Num2gUser int `json:"num2gUser"`
|
||||
Num5gUser int `json:"num5gUser"`
|
||||
Num6gUser int `json:"num6gUser"`
|
||||
Num2gGuest int `json:"num2gGuest"`
|
||||
Num5gGuest int `json:"num5gGuest"`
|
||||
Num6gGuest int `json:"num6gGuest"`
|
||||
Poor int `json:"poor"`
|
||||
Fair int `json:"fair"`
|
||||
NoData int `json:"noData"`
|
||||
Good int `json:"good"`
|
||||
}
|
45
model/device.go
Normal file
45
model/device.go
Normal file
@ -0,0 +1,45 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type Device struct {
|
||||
MacAddress string `json:"mac"`
|
||||
Name string `json:"name"`
|
||||
Type DeviceType `json:"type"`
|
||||
Subtype string `json:"subtype"`
|
||||
DeviceSeriesType int `json:"deviceSeriesType"`
|
||||
Model string `json:"model"`
|
||||
IP string `json:"ip"`
|
||||
IPv6 []string `json:"ipv6"`
|
||||
Uptime string `json:"uptime"`
|
||||
Status DeviceStatus `json:"status"`
|
||||
LastSeen int `json:"lastSeen"`
|
||||
CpuUtil int `json:"cpuUtil"`
|
||||
MemUtil int `json:"memUtil"`
|
||||
SerialNumber string `json:"sn"`
|
||||
LicenseStatus int `json:"licenseStatus"`
|
||||
TagName string `json:"tagName"`
|
||||
}
|
||||
|
||||
func (d Device) String() string {
|
||||
data, _ := json.MarshalIndent(d, "", "\t")
|
||||
return string(data)
|
||||
}
|
||||
|
||||
type DeviceStatus int
|
||||
|
||||
const (
|
||||
DeviceStatusDisconnected DeviceStatus = iota
|
||||
DeviceStatusConnected
|
||||
DeviceStatusPending
|
||||
DeviceStatusHeartbeatMissed
|
||||
DeviceStatusIsolated
|
||||
)
|
||||
|
||||
type DeviceType string
|
||||
|
||||
const (
|
||||
DeviceTypeAP DeviceType = "ap"
|
||||
)
|
26
model/login.go
Normal file
26
model/login.go
Normal file
@ -0,0 +1,26 @@
|
||||
package model
|
||||
|
||||
type LoginRequest struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type LoginResponse Response[LoginResponseResult]
|
||||
type LoginResponseResult struct {
|
||||
CsrfToken string `json:"csrfToken"`
|
||||
SessionID string `json:"sessionId"`
|
||||
}
|
||||
|
||||
type AuthCodeResponse struct {
|
||||
ErrorCode int `json:"errorCode"`
|
||||
Message string `json:"msg"`
|
||||
Result *string `json:"result"`
|
||||
}
|
||||
|
||||
type AuthTokenResponse Response[AuthTokenResponseResult]
|
||||
type AuthTokenResponseResult struct {
|
||||
AccessToken string `json:"accessToken"`
|
||||
TokenType string `json:"tokenType"`
|
||||
ExpiresIn int `json:"expiresIn"`
|
||||
RefreshToken string `json:"refreshToken"`
|
||||
}
|
15
model/response.go
Normal file
15
model/response.go
Normal file
@ -0,0 +1,15 @@
|
||||
package model
|
||||
|
||||
type Response[T any] struct {
|
||||
ErrorCode int `json:"errorCode"`
|
||||
Message string `json:"msg"`
|
||||
Result T `json:"result"`
|
||||
}
|
||||
|
||||
type PagedResponse[T any] Response[PagedResponseResult[T]]
|
||||
type PagedResponseResult[T any] struct {
|
||||
TotalRows int `json:"totalRows"`
|
||||
CurrentPage int `json:"currentPage"`
|
||||
CurrentSize int `json:"currentSize"`
|
||||
Data []T `json:"data"`
|
||||
}
|
22
model/site.go
Normal file
22
model/site.go
Normal file
@ -0,0 +1,22 @@
|
||||
package model
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type SiteID string
|
||||
type Site struct {
|
||||
ID SiteID `json:"siteId"`
|
||||
Name string `json:"name"`
|
||||
TagIDs []string `json:"tagIds"`
|
||||
Region string `json:"region"`
|
||||
TimeZone string `json:"timeZone"`
|
||||
Scenario string `json:"scenario"`
|
||||
Longitude float64 `json:"longitude"`
|
||||
Latitude float64 `json:"latitude"`
|
||||
Address string `json:"address"`
|
||||
Type int `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
func (s Site) String() string {
|
||||
data, _ := json.MarshalIndent(s, "", "\t")
|
||||
return string(data)
|
||||
}
|
Reference in New Issue
Block a user