https://github.com/netascode/go-nd
A Go client library for Cisco Nexus Dashboard.
https://github.com/netascode/go-nd
cisco go golang nexus nexus-dashboard
Last synced: 3 months ago
JSON representation
A Go client library for Cisco Nexus Dashboard.
- Host: GitHub
- URL: https://github.com/netascode/go-nd
- Owner: netascode
- License: mpl-2.0
- Created: 2023-08-18T11:48:40.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-13T19:27:16.000Z (4 months ago)
- Last Synced: 2025-01-13T20:27:50.323Z (4 months ago)
- Topics: cisco, go, golang, nexus, nexus-dashboard
- Language: Go
- Homepage:
- Size: 33.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/netascode/go-nd/actions/workflows/test.yml)
# go-nd
`go-nd` is a Go client library for Cisco Nexus Dashboard. It is based on Nathan's excellent [goaci](https://github.com/brightpuddle/goaci) module and features a simple, extensible API and [advanced JSON manipulation](#result-manipulation).
## Getting Started
### Installing
To start using `go-nd`, install Go and `go get`:
`$ go get -u github.com/netascode/go-nd`
### Basic Usage
```go
package mainimport "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
```#### Result manipulation
`nd.Result` uses GJSON to simplify handling JSON results. See the [GJSON](https://github.com/tidwall/gjson) documentation for more detail.
```go
res, _ := client.Get("/lan-fabric/rest/control/fabrics")for _, group := range res.Array() {
println(group.Get("@pretty").String()) // pretty print fabrics
}
```#### POST data creation
`nd.Body` is a wrapper for [SJSON](https://github.com/tidwall/sjson). SJSON supports a path syntax simplifying JSON creation.
```go
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)
```## Documentation
See the [documentation](https://godoc.org/github.com/netascode/go-nd) for more details.