go-sdwan
is a Go client library for Cisco SDWAN. It is based on Nathan's excellent goaci module and features a simple, extensible API and advanced JSON manipulation.
To start using go-sdwan
, install Go and go get
:
$ go get -u github.com/netascode/go-sdwan
package main
import "github.com/netascode/go-sdwan"
func main() {
client, _ := sdwan.NewClient("1.1.1.1", "user", "pwd", true)
res, _ := client.Get("/admin/resourcegroup")
println(res.Get("0.id").String())
}
This will print something like:
0:RESOURCE_GROUPNode:1626378545017:2
sdwan.Result
uses GJSON to simplify handling JSON results. See the GJSON documentation for more detail.
res, _ := client.Get("/admin/resourcegroup")
for _, group := range res.Array() {
println(group.Get("@pretty").String()) // pretty print resource groups
}
sdwan.Body
is a wrapper for SJSON. SJSON supports a path syntax simplifying JSON creation.
body := sdwan.Body{}.
Set("name", "test").
Set("desc", "API Test")
client.Post("/admin/resourcegroup", body.Str)
See the documentation for more details.