go_fortigate_client

package module
v0.0.0-...-eeb705b Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

go-fortigate-client

Fortigate GO API client. Supports operations on "firewall", "certificate" and "vpn" for now.

How to use:

import "github.com/Nexinto/go-fortigate-client/fortigate"

c := fortigate.NewWebClient(fortigate.WebClient{
	URL: os.Getenv("FORTIGATE_URL"),
	ApiKey: os.Getenv("FORTIGATE_API_KEY")})

vip := &fortigate.VIP{
		Name:            "myvip",
		Type:            fortigate.VIPTypeServerLoadBalance,
		LdbMethod:       fortigate.VIPLdbMethodRoundRobin,
		PortmappingType: fortigate.VIPPortmappingType1To1,
		Extintf:         "any",
		ServerType:      fortigate.VIPServerTypeTcp,
		Comment:         "my service",
		Extip:           "10.90.250.1",
		Extport:         "80",
		Realservers: []fortigate.VIPRealservers{
			{Ip: "10.90.251.1", Port: 80},
			{Ip: "10.90.251.2", Port: 80},
			{Ip: "10.90.251.3", Port: 80},
			{Ip: "10.90.251.4", Port: 80},
		},
	}
	
id, err := c.CreateVIP(vip)

...

err = c.UpdateVIP(vip)

...

err := c.DeleteVIP(id)

See fgcmd.go for more examples.

Create a Fake client for testing:


c := fortigate.NewFakeClient()

Documentation

Index

Constants

View Source
const (
	CsrfToken       = "ccsrftoken"
	CsrfTokenHeader = "X-Csrftoken"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	HTTPMethod string `json:"http_method,omitempty"`
	Revision   string `json:"revision,omitempty"`
	Status     string `json:"status,omitempty"`
	HTTPStatus int    `json:"http_status,omitempty"`
	Vdom       string `json:"vdom,omitempty"`
	Path       string `json:"path,omitempty"`
	Name       string `json:"name,omitempty"`
	Serial     string `json:"serial,omitempty"`
	Version    string `json:"version,omitempty"`
	Build      int    `json:"build,omitempty"`
	Action     string `json:"action,omitempty"`
}

type WebClient

type WebClient struct {
	URL      string
	User     string
	Password string
	ApiKey   string
	Log      bool
	// contains filtered or unexported fields
}

func NewWebClient

func NewWebClient(clientConfig WebClient) (c *WebClient, err error)

func (*WebClient) Do

func (c *WebClient) Do(method string, path string, p *url.Values, payload interface{}, result2 interface{}) (resp *napping.Response, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL