b1ddi-go-client

module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2022 License: Apache-2.0

README

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)
	}
}

Directories

Path Synopsis
Package client provides useful primitives for working with BloxOne DDI APIs
Package client provides useful primitives for working with BloxOne DDI APIs
acl
asm
Package runtime contains BloxOne DDI API helper runtime abstractions for internal client use.
Package runtime contains BloxOne DDI API helper runtime abstractions for internal client use.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳