Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Higher level api #2

Open
UnAfraid opened this issue Dec 31, 2018 · 2 comments
Open

Higher level api #2

UnAfraid opened this issue Dec 31, 2018 · 2 comments

Comments

@UnAfraid
Copy link

UnAfraid commented Dec 31, 2018

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
Copy link

OJFord commented Feb 3, 2022

@archaron
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants