Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
ppwarwick edited this page Aug 25, 2017 · 37 revisions

skyinfoblox - Go library for the Infoblox appliance

Skyinfoblox is the GoLang API wrapper for Infoblox. The wrapper uses the REST API interface provided by Infoblox. Skyinfoblox currently supports v2.3.1 of the Infoblox API. There is also command line interface which can be built by running make in the root of this repo.

The Infoblox API documentation may be accessed by appending /wapidoc/ to the Infoblox server URL. E.g https://example-infoblox.example.com/wapidoc/

Using the CLI

Building the CLI

The CLI may be built by running make in the root of the repo. Make will build the skyinfoblox binary.

$ make

Shell environment variables for the CLI

The Infoblox server credentials may either be passed as options to skyinfoblox on the command line or by setting environment variables.

Passing credentials as options

./skyinfoblox -username example-user -password examplePassword -server https://example-infoblox.example.com ....

Setting credentials through environment variables

$ export IBX_USERNAME="example-user"
$ export IBX_PASSWORD="examplePassword"
$ export IBX_SERVER="https://example-infoblox.example.com"

CLI help

General help

$ ./skyinfoblox-cli -h

Help for a sub-command. E.g. zone-create

$ ./skyinfoblox-cli sub-command -h

CLI options

The CLI has sub-commands for each Infoblox object type. Please see the links under Infoblox Objects for specific examples.

Using the library

Import

import(
    "github.com/sky-uk/skyinfoblox"
)

Create a client object

client := skyinfoblox.NewInfobloxClient(
        infobloxServer, // e.g. https://example-infoblox.example.com
        infobloxUsername,
        infobloxPassword,
        allowUnverifiedSSL, // ignore certificate errors (boolean)
        debug, // enable debugging (boolean)
    )

    // create a new client
    client := skyinfoblox.NewInfobloxClient(infobloxServer, infobloxUsername, infobloxPassword, true, true)

Perform a request

This is an example of how to perform a request. More detailed examples may be found under Infoblox Objects below.

E.g. admingroup

// Prepare a request...

    // returnFields is specific to each object type and determines which attributes are returned from the Infoblox API.
    returnFields := []string{"name", "comment", "disable", "roles", "email_addresses", "superuser", "access_method"}
    adminGroupName := "example-group"
    getAdminGroupAPI := admingroup.NewGet(adminGroupName, returnFields)

// Perform the request...
    err := client.Do(getAdminGroupAPI)
    if err != nil {
        // handle errors....
    }

Working with the response object

E.g. returned response object is an interface and we need to cast it as an *admingroup.IBXAdminGroup.

    response := *adminGroupShowAPI.ResponseObject().(*admingroup.IBXAdminGroup)
    
    adminGroupName := response.Name

Finding the response HTTP status

httpStatus := getAdminGroupAPI.StatusCode()

Infoblox Objects

The following Infoblox Objects may be managed through these bindings:

Run Unit tests

$ make test
Clone this wiki locally