go-routeros / routeros

Go library for accessing Mikrotik devices using the RouterOS API
MIT License
196 stars 51 forks source link

Higher level api #2

Open UnAfraid opened 5 years ago

UnAfraid commented 5 years ago

Hello,

Any chance of making a bit higher level API as well?

like

// Create new mikrotik api client
client := mikrotik.NewClientApi("192.168.88.1:8728")
if err := client.Connect("admin", ""); err != nil {
    log.Fatalf("Failed to connect: %s", err.Error())
}
defer client.Close()

// Obtain system information
system, err := client.System()
check(err)

// Obtain system resource information
resources, err := system.Resources();
check(err)

// Print some system resources
log.Printf("Uptime: %s", resources.Uptime)
log.Printf("Version: %s", resources.Version)
log.Printf("Build-time: %s", resources.BuildTime)
// ..

// Obtain information about interfaces
iface,  err := client.Interface()
check(err)

// Print basic info about each interface
for idx, iface := range iface.ToArray() {
    log.Printf("Interface: #%d %s Type: %s Mac: %s", idx, iface.Name, iface.Type, iface.MacAddress)
}
OJFord commented 2 years ago

https://github.com/GNewbury1/terraform-provider-routeros/tree/main/client

archaron commented 5 months ago

Interesting idea. But maybe as side project, or as extension. For now, primary focus is on direct api usage to be polished.