modulepackage
0.0.0-20241121100336-de2a2fe14e68
Repository: https://github.com/netascode/go-fmc.git
Documentation: pkg.go.dev
# README
go-fmc
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.
Getting Started
Installing
To start using go-fmc
, install Go and go get
:
$ go get -u github.com/netascode/go-fmc
Basic Usage
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
Result manipulation
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
}
POST data creation
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)
Documentation
See the documentation for more details.
# Functions
BackoffDelayFactor modifies the backoff delay factor from the default of 3.
BackoffMaxDelay modifies the maximum delay between two retries from the default of 60.
BackoffMinDelay modifies the minimum delay between two retries from the default of 2.
Replace the default HTTP client with a custom one.
DomainName modifies the domain to be used for the request.
Insecure determines if insecure https connections are allowed.
MaxRetries modifies the maximum number of retries from the default of 3.
NewClient creates a new FMC HTTP client.
NoLogPayload prevents logging of payloads.
RequestTimeout modifies the HTTP request timeout from the default of 60 seconds.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Type aliases
Res is an API response returned by client requests.