Files
ubiquiti-clients/pkg/edgeos/types.go

107 lines
3.5 KiB
Go

package edgeos
// EdgeOS combines all device information into one response.
type EdgeOS struct {
AuthInfo *AuthResponse `json:"authInfo,omitempty"`
Config *ConfigData `json:"config,omitempty"`
}
// AuthResponse represents the authentication response from login2 endpoint.
type AuthResponse struct {
Username string `json:"username"`
PoE bool `json:"poe"`
StatsURL string `json:"statsUrl"`
Features Features `json:"features"`
Level string `json:"level"`
Authenticated bool `json:"authenticated"`
Model string `json:"model"`
IsLicenseAccepted bool `json:"isLicenseAccepted"`
ModelName string `json:"model_name"`
Ports int `json:"ports"`
}
// Features contains device feature information.
type Features struct {
Model string `json:"model"`
PoECap map[string]string `json:"poe_cap"`
Switch SwitchFeatures `json:"switch"`
SwitchIsVLANCapable bool `json:"switchIsVLANCapable"`
PoE bool `json:"poe"`
Ports int `json:"ports"`
}
// SwitchFeatures contains switch-specific features.
type SwitchFeatures struct {
Ports []string `json:"ports"`
}
// ConfigResponse represents the response from /api/edge/get.json.
type ConfigResponse struct {
SessionID string `json:"SESSION_ID"`
GET ConfigData `json:"GET"`
Success bool `json:"success"`
}
// ConfigData contains the full device configuration.
type ConfigData struct {
Interfaces InterfacesConfig `json:"interfaces"`
System SystemConfig `json:"system"`
}
// InterfacesConfig represents the interfaces configuration.
type InterfacesConfig struct {
Ethernet map[string]EthernetConfig `json:"ethernet,omitempty"`
Switch map[string]SwitchConfig `json:"switch,omitempty"`
}
// EthernetConfig represents an ethernet interface configuration.
type EthernetConfig struct {
Description string `json:"description,omitempty"`
Duplex string `json:"duplex,omitempty"`
Speed string `json:"speed,omitempty"`
PoE *PoEState `json:"poe,omitempty"`
}
// PoEState represents PoE output state.
type PoEState struct {
Output string `json:"output,omitempty"`
}
// SwitchConfig represents a switch interface configuration.
type SwitchConfig struct {
Address []string `json:"address,omitempty"`
MTU string `json:"mtu,omitempty"`
SwitchPort *SwitchPortConfig `json:"switch-port,omitempty"`
VIF map[string]VIFConfig `json:"vif,omitempty"`
}
// SwitchPortConfig represents switch port configuration with VLAN awareness.
type SwitchPortConfig struct {
Interface map[string]InterfaceVLAN `json:"interface,omitempty"`
VLANAware string `json:"vlan-aware,omitempty"`
}
// InterfaceVLAN represents VLAN configuration for an interface.
type InterfaceVLAN struct {
VLAN VLANConfig `json:"vlan,omitempty"`
}
// VLANConfig represents VLAN ID configuration.
type VLANConfig struct {
PVID string `json:"pvid,omitempty"`
VID []string `json:"vid,omitempty"`
}
// VIFConfig represents a virtual interface (VLAN) configuration.
type VIFConfig struct {
Address []string `json:"address,omitempty"`
Description string `json:"description,omitempty"`
MTU string `json:"mtu,omitempty"`
}
// SystemConfig contains system configuration.
type SystemConfig struct {
HostName string `json:"host-name,omitempty"`
DomainName string `json:"domain-name,omitempty"`
}