zabbixapi

package
v1.0.0-rc1.0...-e18caea Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotAuthenticated = errors.New("zabbix api: not authenticated")
)

Functions

func NewTestClient

func NewTestClient(fn RoundTripFunc) *http.Client

NewTestClient returns *http.Client with Transport replaced to avoid making real calls

Types

type RoundTripFunc

type RoundTripFunc func(req *http.Request) *http.Response

func (RoundTripFunc) RoundTrip

func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error)

type ZabbixAPI

type ZabbixAPI struct {
	// contains filtered or unexported fields
}

ZabbixAPI is a simple client responsible for making request to Zabbix API

func MockZabbixAPI

func MockZabbixAPI(body string, statusCode int) (*ZabbixAPI, error)

func New

func New(apiURL string, client *http.Client) (*ZabbixAPI, error)

New returns new ZabbixAPI instance initialized with given URL or error.

func (*ZabbixAPI) Authenticate

func (api *ZabbixAPI) Authenticate(ctx context.Context, username string, password string) error

Authenticate performs API authentication and sets authentication token.

func (*ZabbixAPI) AuthenticateWithToken

func (api *ZabbixAPI) AuthenticateWithToken(ctx context.Context, token string) error

AuthenticateWithToken performs authentication with API token.

func (*ZabbixAPI) GetAuth

func (api *ZabbixAPI) GetAuth() string

GetAuth returns API authentication token

func (*ZabbixAPI) GetUrl

func (api *ZabbixAPI) GetUrl() *url.URL

GetUrl gets new API URL

func (*ZabbixAPI) Login

func (api *ZabbixAPI) Login(ctx context.Context, username string, password string) (string, error)

Login performs API authentication and returns authentication token.

func (*ZabbixAPI) LoginDeprecated

func (api *ZabbixAPI) LoginDeprecated(ctx context.Context, username string, password string) (string, error)

Login methid for Zabbix prior to 5.4

func (*ZabbixAPI) Request

func (api *ZabbixAPI) Request(ctx context.Context, method string, params ZabbixAPIParams) (*simplejson.Json, error)

Request performs API request

func (*ZabbixAPI) RequestUnauthenticated

func (api *ZabbixAPI) RequestUnauthenticated(ctx context.Context, method string, params ZabbixAPIParams) (*simplejson.Json, error)

Request performs API request without authentication token

func (*ZabbixAPI) SetAuth

func (api *ZabbixAPI) SetAuth(auth string)

SetAuth sets API authentication token

func (*ZabbixAPI) SetUrl

func (api *ZabbixAPI) SetUrl(api_url string) error

SetUrl sets new API URL

type ZabbixAPIParams

type ZabbixAPIParams = map[string]interface{}

Jump to

Keyboard shortcuts

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