go-catalystcenter
is a Go client library for Cisco Catalyst Center. It is based on Nathan's excellent goaci module and features a simple, extensible API and advanced JSON manipulation.
To start using go-catalystcenter
, install Go and go get
:
$ go get -u github.com/netascode/go-catalystcenter
package main
import "github.com/netascode/go-catalystcenter"
func main() {
client, _ := cc.NewClient("https://1.1.1.1", "user", "pwd")
res, _ := client.Get("/dna/intent/api/v2/site")
println(res.Get("response.0.name").String())
}
This will print something like:
Site1
cc.Result
uses GJSON to simplify handling JSON results. See the GJSON documentation for more detail.
res, _ := client.Get("/dna/intent/api/v2/site")
for _, site := range res.Get("response").Array() {
println(site.Get("@pretty").String()) // pretty print sites
}
cc.Body
is a wrapper for SJSON. SJSON supports a path syntax simplifying JSON creation.
body := cc.Body{}.
Set("type", "area").
Set("site.area.name", "Area1").
Set("site.area.parentName", "Global")
client.Post("/dna/intent/api/v1/site", body.Str)
See the documentation for more details.