Documentation
¶
Overview ¶
Package rosapi provides typed mapping of RouterOS API response sentences to Go structs and implements the Renderable interface for output formatting.
Index ¶
- func MapSentences[T any](sentences []map[string]string) ([]T, error)
- type DHCPLease
- type DHCPLeases
- type DHCPPool
- type DHCPPools
- type DHCPServer
- type DHCPServers
- type DNSSettings
- type DNSSettingsList
- type FirewallRule
- type FirewallRules
- type GenericResult
- type GenericResults
- type IPAddress
- type IPAddresses
- type IPRoute
- type IPRoutes
- type Interface
- type Interfaces
- type SystemIdentities
- type SystemIdentity
- type SystemInfo
- type SystemInfoList
- type SystemResource
- type SystemResources
- type TrafficStats
- type TrafficStatsList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MapSentences ¶
MapSentences converts a slice of RouterOS API response sentences (each a map[string]string) into a slice of typed Go structs. Fields are matched using the `ros:"field_name"` struct tag. Fields without a ros tag are skipped. Missing keys in the sentence map produce zero values.
Types ¶
type DHCPLease ¶
type DHCPLease struct {
ID string `ros:".id"`
Address string `ros:"address"`
MACAddress string `ros:"mac-address"`
HostName string `ros:"host-name"`
Status string `ros:"status"`
Comment string `ros:"comment"`
}
DHCPLease represents the output of /ip/dhcp-server/lease/print.
type DHCPLeases ¶
type DHCPLeases []DHCPLease
DHCPLeases is a slice of DHCPLease that implements Renderable.
func (DHCPLeases) TableHeaders ¶
func (s DHCPLeases) TableHeaders() []string
func (DHCPLeases) TableRows ¶
func (s DHCPLeases) TableRows() [][]string
type DHCPPool ¶
type DHCPPool struct {
ID string `ros:".id"`
Name string `ros:"name"`
Ranges string `ros:"ranges"`
Comment string `ros:"comment"`
}
DHCPPool represents the output of /ip/pool/print.
type DHCPServer ¶
type DHCPServer struct {
ID string `ros:".id"`
Name string `ros:"name"`
Interface string `ros:"interface"`
Disabled string `ros:"disabled"`
AddressPool string `ros:"address-pool"`
LeaseTime string `ros:"lease-time"`
}
DHCPServer represents the output of /ip/dhcp-server/print.
type DHCPServers ¶
type DHCPServers []DHCPServer
func (DHCPServers) TableHeaders ¶
func (s DHCPServers) TableHeaders() []string
func (DHCPServers) TableRows ¶
func (s DHCPServers) TableRows() [][]string
type DNSSettings ¶
type DNSSettings struct {
Servers string `ros:"servers"`
DynamicServers string `ros:"dynamic-servers"`
AllowRemoteRequests string `ros:"allow-remote-requests"`
MaxUDPPacketSize string `ros:"max-udp-packet-size"`
CacheSize string `ros:"cache-size"`
CacheMaxTTL string `ros:"cache-max-ttl"`
CacheUsed string `ros:"cache-used"`
}
DNSSettings represents the output of /ip/dns/print.
type DNSSettingsList ¶
type DNSSettingsList []DNSSettings
func (DNSSettingsList) TableHeaders ¶
func (s DNSSettingsList) TableHeaders() []string
func (DNSSettingsList) TableRows ¶
func (s DNSSettingsList) TableRows() [][]string
type FirewallRule ¶
type FirewallRule struct {
ID string `ros:".id"`
Chain string `ros:"chain"`
Action string `ros:"action"`
Protocol string `ros:"protocol"`
SrcAddress string `ros:"src-address"`
DstAddress string `ros:"dst-address"`
DstPort string `ros:"dst-port"`
Comment string `ros:"comment"`
Disabled string `ros:"disabled"`
}
FirewallRule represents the output of /ip/firewall/filter/print (or nat/mangle).
type FirewallRules ¶
type FirewallRules []FirewallRule
FirewallRules is a slice of FirewallRule that implements Renderable.
func (FirewallRules) TableHeaders ¶
func (s FirewallRules) TableHeaders() []string
func (FirewallRules) TableRows ¶
func (s FirewallRules) TableRows() [][]string
type GenericResult ¶
GenericResult holds an arbitrary RouterOS sentence as a raw key-value map. It is used by the exec command where the response structure is not known ahead of time.
type GenericResults ¶
type GenericResults struct {
Items []GenericResult
// contains filtered or unexported fields
}
GenericResults is a slice of GenericResult that implements Renderable. Headers are auto-detected by collecting all unique keys across every result, sorted alphabetically for stable output. Use SetKeyOrder to override.
func (GenericResults) RawRecords ¶ added in v0.2.0
func (g GenericResults) RawRecords() []map[string]string
RawRecords exposes the underlying RouterOS sentence maps (including .id).
func (*GenericResults) SetKeyOrder ¶
func (g *GenericResults) SetKeyOrder(keys []string)
SetKeyOrder overrides the auto-detected header order.
func (GenericResults) TableHeaders ¶
func (g GenericResults) TableHeaders() []string
func (GenericResults) TableRows ¶
func (g GenericResults) TableRows() [][]string
type IPAddress ¶
type IPAddress struct {
ID string `ros:".id"`
Address string `ros:"address"`
Network string `ros:"network"`
Interface string `ros:"interface"`
Disabled string `ros:"disabled"`
Comment string `ros:"comment"`
}
IPAddress represents the output of /ip/address/print.
type IPAddresses ¶
type IPAddresses []IPAddress
IPAddresses is a slice of IPAddress that implements Renderable.
func (IPAddresses) TableHeaders ¶
func (s IPAddresses) TableHeaders() []string
func (IPAddresses) TableRows ¶
func (s IPAddresses) TableRows() [][]string
type IPRoute ¶
type IPRoute struct {
ID string `ros:".id"`
DstAddress string `ros:"dst-address"`
Gateway string `ros:"gateway"`
Distance string `ros:"distance"`
Routing string `ros:"routing-table"`
Disabled string `ros:"disabled"`
}
IPRoute represents the output of /ip/route/print.
type IPRoutes ¶
type IPRoutes []IPRoute
IPRoutes is a slice of IPRoute that implements Renderable.
func (IPRoutes) TableHeaders ¶
type Interface ¶
type Interface struct {
ID string `ros:".id"`
Name string `ros:"name"`
Type string `ros:"type"`
MTU string `ros:"actual-mtu"`
Running string `ros:"running"`
Disabled string `ros:"disabled"`
Comment string `ros:"comment"`
}
Interface represents the output of /interface/print.
type Interfaces ¶
type Interfaces []Interface
Interfaces is a slice of Interface that implements Renderable.
func (Interfaces) TableHeaders ¶
func (s Interfaces) TableHeaders() []string
func (Interfaces) TableRows ¶
func (s Interfaces) TableRows() [][]string
type SystemIdentities ¶
type SystemIdentities []SystemIdentity
SystemIdentities is a slice of SystemIdentity that implements Renderable.
func (SystemIdentities) TableHeaders ¶
func (s SystemIdentities) TableHeaders() []string
func (SystemIdentities) TableRows ¶
func (s SystemIdentities) TableRows() [][]string
type SystemIdentity ¶
type SystemIdentity struct {
Name string `ros:"name"`
}
SystemIdentity represents the output of /system/identity/print.
type SystemInfo ¶
type SystemInfo struct {
Identity string
Resource SystemResource
}
SystemInfo combines identity and resource data for the system info view.
type SystemInfoList ¶
type SystemInfoList []SystemInfo
SystemInfoList is a slice of SystemInfo that implements Renderable.
func (SystemInfoList) TableHeaders ¶
func (s SystemInfoList) TableHeaders() []string
func (SystemInfoList) TableRows ¶
func (s SystemInfoList) TableRows() [][]string
type SystemResource ¶
type SystemResource struct {
Uptime string `ros:"uptime"`
Version string `ros:"version"`
BuildTime string `ros:"build-time"`
CPUCount string `ros:"cpu-count"`
CPULoad string `ros:"cpu-load"`
FreeMemory string `ros:"free-memory"`
TotalMemory string `ros:"total-memory"`
FreeHDDSpace string `ros:"free-hdd-space"`
TotalHDDSpace string `ros:"total-hdd-space"`
ArchitectureName string `ros:"architecture-name"`
BoardName string `ros:"board-name"`
Platform string `ros:"platform"`
}
SystemResource represents the output of /system/resource/print.
type SystemResources ¶
type SystemResources []SystemResource
SystemResources is a slice of SystemResource that implements Renderable.
func (SystemResources) TableHeaders ¶
func (s SystemResources) TableHeaders() []string
func (SystemResources) TableRows ¶
func (s SystemResources) TableRows() [][]string
type TrafficStats ¶
type TrafficStats struct {
Name string `ros:"name"`
RxByte string `ros:"rx-byte"`
TxByte string `ros:"tx-byte"`
RxPacket string `ros:"rx-packet"`
TxPacket string `ros:"tx-packet"`
}
TrafficStats represents interface traffic counters.
type TrafficStatsList ¶
type TrafficStatsList []TrafficStats
func (TrafficStatsList) TableHeaders ¶
func (s TrafficStatsList) TableHeaders() []string
func (TrafficStatsList) TableRows ¶
func (s TrafficStatsList) TableRows() [][]string