Skip to content

venkat-iblox/b1ddi-go-client

 
 

Repository files navigation

Overview

This library enables the management of BloxOne DDI resources.

The following BloxOne DDI APIs are supported:

Installation

To install b1ddi-go-client use go get command:

go get github.com/infobloxopen/b1ddi-go-client

Usage Guide

Examples

The following program will print the subnet mask of each subnet in the BloxOne DDI environment:

package main

import (
	"fmt"
	"os"

	httptransport "github.com/go-openapi/runtime/client"
	"github.com/go-openapi/strfmt"
	b1cli "github.com/infobloxopen/b1ddi-go-client/client"
)

func main() {
	// Create new go-swagger runtime client
	transport := httptransport.New(
		os.Getenv("B1DDI_HOST"), "api/ddi/v1", nil,
	)

	// Create default auth header for all API requests
	tokenAuth := b1cli.B1DDIAPIKey(os.Getenv("B1DDI_API_KEY"))
	transport.DefaultAuthentication = tokenAuth

	// Create the BloxOne API client
	client := b1cli.NewClient(transport, strfmt.Default)

	// List all subnets using IPAM API client
	subnetList, err := client.IPAddressManagementAPI.Subnet.SubnetList(nil, nil)
	if err != nil {
		panic(err)
	}

	// Print subnet mask for each subnet
	for _, subnet := range subnetList.Payload.Results {
		fmt.Printf("%s/%d\n", *subnet.Address, subnet.Cidr)
	}
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%