Skip to content

Latest commit

 

History

History
59 lines (46 loc) · 1.33 KB

README.md

File metadata and controls

59 lines (46 loc) · 1.33 KB

gofortiadc

A FortiADC API client enabling Go programs to interact with a Fortiadc server

GoDoc Go Report Card GitHub issues

NOTE

Tested with Fortiadc 5.4 API

Example

package main

import (
	"crypto/tls"
	"log"
	"net/http"
	"net/http/cookiejar"

	"github.com/Ouest-France/gofortiadc"
)

func main() {

	// Construct an http client with cookies
	cookieJar, _ := cookiejar.New(nil)
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{},
	}
	httpClient := &http.Client{
		Jar:       cookieJar,
		Transport: tr,
	}

	// Construct new forti Client instance
	fortiClient := Client{
		Client:   httpClient,
		Address:  "https://myfortiadc.example.com",
		Username: "fortiuser",
		Password: "fortipassword",
	}

	// Send auth request to get authorization token
	err := fortiClient.Login()
	if err != nil {
		log.Fatal(err)
	}

	// Get the list of all virtual servers
	res, err := fortiClient.LoadbalanceGetVirtualServers()
	if err != nil {
		log.Print(err)
	}
}