Package netbox provides an API client for DigitalOcean's NetBox IPAM and DCIM service.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
scripts Include simple examples. Mar 7, 2018
.travis.yml device_face is an integer enum, not boolean Mar 9, 2018
AUTHORS *: initial commit Jun 29, 2016 *: initial commit Jun 29, 2016
Makefile Helper functions for most common configurations. Mar 15, 2018
copyright_header.txt Add the copyright header back to all the files. Feb 28, 2018
swagger.json Update to netbox@master with connected-devices added Mar 16, 2018

netbox GoDoc Build Status Report Card

Package netbox provides an API 2.0 client for DigitalOcean's NetBox IPAM and DCIM service.

This package assumes you are using NetBox 2.0, as the NetBox 1.0 API no longer exists.

Using the client

The package has some convenience functions for creating clients with the most common configurations you are likely to need while connecting to NetBox. NewNetboxAt allows you to specify a hostname (including port, if you need it), and NewNetboxWithAPIKey allows you to specify both a hostname:port and API token.

import (
    c := netbox.NewNetboxAt("")
    // OR
    c := netbox.NewNetboxWithAPIKey("", "your_netbox_token")

If you specify the API key, you do not need to pass an additional authInfo to operations that need authentication, and can pass nil:

    c.Dcim.DcimDeviceTypesCreate(createRequest, nil)

More complex client configuration

The client is generated using go-swagger. This means the generated client makes use of If you need a more complex configuration, it is probably possible with a combination of this generated client and the runtime options.

The godocs for the go-openapi/runtime/client module explain the client options in detail, including different authentication and debugging options. One thing I want to flag because it is so useful: setting the DEBUG environment variable will dump all requests to standard out.

Regenerating the client

To regenerate the client with a new or different swagger schema, first clean the existing client, then replace swagger.json and finally re-generate:

make clean
cp new_swagger_file.json swagger.json
make generate