Skip to content

About

A Go client library for Cisco Crosswork.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Tests

go-crosswork

go-crosswork is a Go client library for Cisco Crosswork Network Controller. It features a simple, extensible API and advanced JSON manipulation.

Getting Started

Installing

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

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

Basic Usage

package main

import "github.com/netascode/go-crosswork"

func main() {
    client, _ := crosswork.NewClient("https://1.1.1.1:30603", "user", "pwd")

    res, _ := client.Get("/crosswork/inventory/v1/nodes/count")
    println(res.Get("number_of_nodes").String())
}

This will print something like:

33

Result manipulation

crosswork.Res uses GJSON to simplify handling JSON results. See the GJSON documentation for more detail.

res, _ := client.Post("/crosswork/inventory/v1/nodes/query", `{"limit":10}`)

for _, node := range res.Get("data").Array() {
    println(node.Get("host_name").String())
}

POST data creation

crosswork.Body is a wrapper for SJSON. SJSON supports a path syntax simplifying JSON creation.

body := crosswork.Body{}.
    Set("data.0.profile", "example").
    Set("data.0.user_pass.0.user_name", "admin").
    Set("data.0.user_pass.0.password", "secret").
    Set("data.0.user_pass.0.type", "ROBOT_USERPASS_SSH")
client.Post("/crosswork/inventory/v1/credentials", body.Str, crosswork.NoLogPayload)

Documentation

See the documentation for more details.

About

A Go client library for Cisco Crosswork.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages