go-fmc
is a Go client library for Cisco Secure FMC (Firewall Management Center). It is based on Nathan's excellent goaci module and features a simple, extensible API and advanced JSON manipulation.
To start using go-fmc
, install Go and go get
:
$ go get -u github.com/netascode/go-fmc
package main
import "github.com/netascode/go-fmc"
func main() {
client, _ := fmc.NewClient("https://1.1.1.1", "user", "pwd")
res, _ := client.Get("/api/fmc_config/v1/domain/{DOMAIN_UUID}/object/networks")
println(res.Get("items.0.name").String())
}
This will print something like:
any-ipv4
fmc.Result
uses GJSON to simplify handling JSON results. See the GJSON documentation for more detail.
res, _ := client.Get("/api/fmc_config/v1/domain/{DOMAIN_UUID}/object/networks")
for _, obj := range res.Get("items").Array() {
println(obj.Get("@pretty").String()) // pretty print network objects
}
fmc.Body
is a wrapper for SJSON. SJSON supports a path syntax simplifying JSON creation.
body := fmc.Body{}.
Set("name", "net1").
Set("value", "1.5.4.0/24")
client.Post("/api/fmc_config/v1/domain/{DOMAIN_UUID}/object/networks", body.Str)
See the documentation for more details.