Go package for netpalm API
I maintain a community on the networktocode slack channel
#netpalmgo on networktocode.slack.com
package main
import (
"context"
"go.bnck.me/netpalm"
"go.bnck.me/netpalm/models"
)
func main() {
nc := netpalmgo.New("https://netapi.mynet.net", "<apikey>")
m := models.GetConfigRequest{
Library: models.LibraryNetmiko,
ConnectionArgs: models.ConnectionArgs{
DeviceType: "cisco_ios",
Host: "10.10.10.1",
Username: "admin",
Password: "abc123",
},
QueueStrategy: models.QueueStrategyFIFO,
Command: []string{"show ip bgp sum"},
}
// send task
d, err := nc.GetConfig().WithRequest(context.Background(), m)
if err != nil {
panic(err)
}
// wait blocking for task to finish
d, err = nc.WaitForResult(context.Background(), d)
if err != nil {
panic(err)
}
}
package main
import (
"context"
"go.bnck.me/netpalm"
"go.bnck.me/netpalm/models"
)
func main() {
nc := netpalmgo.New("https://netapi.mynet.net", "<apikey>")
m := models.SetConfigRequest{
Library: models.LibraryNetmiko,
ConnectionArgs: models.ConnectionArgs{
DeviceType: "cisco_ios",
Host: "10.10.10.1",
Username: "admin",
Password: "abc123",
},
QueueStrategy: models.QueueStrategyFIFO,
Config: []string{
"set int tunnel tun0 remote-ip 192.168.2.1",
},
}
// send set task
d, err := nc.SetConfig().Set(context.Background(), false, m)
if err != nil {
panic(err)
}
// wait blocking for task to finish
d, err = nc.WaitForResult(context.Background(), d)
if err != nil {
panic(err)
}
}