-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Skyinfoblox is the GoLang API wrapper for Infoblox. The wrapper uses the REST API interface provided by Infoblox. Skyinfoblox currently supports v2.6.1 of the Infoblox API. There is also a 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/
make test
make all
This will give you skyinfoblox-cli file which you can use to interact with InfoBlox API.
Note: starting from release 0.1.0, a new API has been provided. The new API supports CRUD operations on all object types. Starting from release 0.2.0 the old API has been officially dismissed and is not any more supported.
The Server WAPI version can be configured at client creation time (it defaults anyhow to v2.6.1). Support for older versions schemes is driven by the Infoblox WAPI server itself (query your server schema to find out the list of supported versions).
import(
"github.com/sky-uk/skyinfoblox"
"github.com/sky-uk/skyinfoblox/api/common/v261" // only if you want to use (a limited set of) v261 objects as defined structs
)
In order to get an API client object first set a list of connnection parameters and pass it to the Connect() function:
params := Params{
WapiVersion: "v2.6.1", // this is anyhow the default...
URL: server,
User: username,
Password: password,
IgnoreSSL: true,
Debug: true,
}
client := Connect(params)
You can create any object you like setting object profile in a map:
adminRole := make(map[string]interface{})
adminRole["name"] = "a role name"
adminRole["comment"] = "An initial comment"
refObj, err := client.Create("adminrole", adminRole)
Or, for a limited selection of objects we directly support, you can use our provided structs:
disable := true
superUser := false
adminGroup := model.IBXAdminGroup{
AccessMethod: []string{"API"},
Comment: "API Access only",
Disable: &disable,
EmailAddresses: []string{"[email protected]"},
Name: "test",
Roles: []string{"test-role"},
SuperUser: &superUser,
}
refObj, err := client.Create("admingroup", adminGroup)
refObj, err = client.Delete(refObj)
The Delete() function returns the deleted object reference or an error otherwise
obj := make(map[string]interface{})
err = client.Read(objRef, []string{<list of attrs you want back>}, &obj)
updatedRefObj, err := client.Update(refObj, newObjectProfileAsMap)
This function can come handy if you like to get anyhow the created
object back instead of only its reference.
It returns the created object as map[string]interface{}
:
adminRole := make(map[string]interface{})
adminRole["name"] = "a role name"
adminRole["comment"] = "An initial comment"
myObj, err := client.CreateAndRead("adminrole", adminRole)
Again this can be handy to get the updated object back
updatedObj, err := client.UpdateAndRead(refObj, newObjectProfileAsMap)
The CLI may be built by running make
in the root of the repo. Make will build the skyinfoblox binary.
$ make
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"
General help
$ ./skyinfoblox-cli -h
Help for a sub-command. E.g. zone-create
$ ./skyinfoblox-cli sub-command -h