go-nd
is a Go client library for Cisco Nexus Dashboard. It is based on Nathan's excellent goaci module and features a simple, extensible API and advanced JSON manipulation.
To start using go-nd
, install Go and go get
:
$ go get -u github.com/netascode/go-nd
package main
import "github.com/netascode/go-nd"
func main() {
client, _ := nd.NewClient("1.1.1.1", "/appcenter/cisco/ndfc/api/v1", "user", "pwd", "", true)
res, _ := client.Get("/lan-fabric/rest/control/fabrics")
println(res.Get("0.id").String())
}
This will print something like:
3
nd.Result
uses GJSON to simplify handling JSON results. See the GJSON documentation for more detail.
res, _ := client.Get("/lan-fabric/rest/control/fabrics")
for _, group := range res.Array() {
println(group.Get("@pretty").String()) // pretty print fabrics
}
nd.Body
is a wrapper for SJSON. SJSON supports a path syntax simplifying JSON creation.
body := nd.Body{}.
Set("templatename", "test").
Set("content", "##template properties \nname= test;\ndescription= ;\ntags= ;\nsupportedPlatforms= All;\ntemplateType= POLICY;\ntemplateSubType= VLAN;\ncontentType= TEMPLATE_CLI;##template variables\r\n##\r\n##template content\r\n##")
client.Post("/configtemplate/rest/config/templates/template", body.Str)
See the documentation for more details.