https://github.com/netascode/go-catalystcenter
A Go client library for Cisco Catalyst Center.
https://github.com/netascode/go-catalystcenter
catalyst catalyst-center center cisco dna-center dnac go golang
Last synced: 4 months ago
JSON representation
A Go client library for Cisco Catalyst Center.
- Host: GitHub
- URL: https://github.com/netascode/go-catalystcenter
- Owner: netascode
- License: mpl-2.0
- Created: 2023-10-30T13:57:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-13T19:28:42.000Z (4 months ago)
- Last Synced: 2025-01-13T20:28:06.978Z (4 months ago)
- Topics: catalyst, catalyst-center, center, cisco, dna-center, dnac, go, golang
- Language: Go
- Homepage:
- Size: 51.8 KB
- Stars: 1
- Watchers: 1
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/netascode/go-catalystcenter/actions/workflows/test.yml)
# go-catalystcenter
`go-catalystcenter` is a Go client library for Cisco Catalyst Center. 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-catalystcenter`, install Go and `go get`:
`$ go get -u github.com/netascode/go-catalystcenter`
### Basic Usage
```go
package mainimport "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
```#### Result manipulation
`cc.Result` uses GJSON to simplify handling JSON results. See the [GJSON](https://github.com/tidwall/gjson) documentation for more detail.
```go
res, _ := client.Get("/dna/intent/api/v2/site")for _, site := range res.Get("response").Array() {
println(site.Get("@pretty").String()) // pretty print sites
}
```#### POST data creation
`cc.Body` is a wrapper for [SJSON](https://github.com/tidwall/sjson). SJSON supports a path syntax simplifying JSON creation.
```go
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)
```## Documentation
See the [documentation](https://godoc.org/github.com/netascode/go-catalystcenter) for more details.