Skip to content

netascode/go-catalystcenter

Tests

go-catalystcenter

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.

Getting Started

Installing

To start using go-catalystcenter, install Go and go get:

$ go get -u github.com/netascode/go-catalystcenter

Basic Usage

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

Result manipulation

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
}

POST data creation

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)

Documentation

See the documentation for more details.