iapi

package
Version: v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2020 License: MPL-2.0 Imports: 7 Imported by: 38

Documentation

Overview

Package iapi provides a client for interacting with an Icinga2 Server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResult

type APIResult struct {
	Error       float64 `json:"error"`
	ErrorString string
	Status      string      `json:"Status"`
	Code        int         `json:"Code"`
	Results     interface{} `json:"results"`
}

APIResult Stores the results from NewApiRequest

type APIStatus

type APIStatus struct {
	Results []struct {
		Name     string   `json:"name"`
		Perfdata []string `json:"perfdata"`
		Status   struct {
			API struct {
				ConnEndpoints       []interface{} `json:"conn_endpoints"`
				Identity            string        `json:"identity"`
				NotConnEndpoints    []interface{} `json:"not_conn_endpoints"`
				NumConnEndpoints    int           `json:"num_conn_endpoints"`
				NumEndpoints        int           `json:"num_endpoints"`
				NumNotConnEndpoints int           `json:"num_not_conn_endpoints"`
				Zones               struct {
					Master struct {
						ClientLogLag int      `json:"client_log_lag"`
						Connected    bool     `json:"connected"`
						Endpoints    []string `json:"endpoints"`
						ParentZone   string   `json:"parent_zone"`
					} `json:"master"`
				} `json:"zones"`
			} `json:"api"`
		} `json:"status"`
	} `json:"results"`
}

APIStatus stores the results of an Icinga2 API Status Call

type CheckcommandAttrs

type CheckcommandAttrs struct {
	Arguments interface{} `json:"arguments"`
	Command   []string    `json:"command"`
	Templates []string    `json:"templates"`
}

type CheckcommandStruct

type CheckcommandStruct struct {
	Name  string            `json:"name"`
	Type  string            `json:"type"`
	Attrs CheckcommandAttrs `json:"attrs"`
	Joins struct{}          `json:"joins"`
	Meta  struct{}          `json:"meta"`
}

CheckcommandStruct is a struct used to store results from an Icinga2 Checkcommand API call.

type HostAttrs

type HostAttrs struct {
	ActionURL    string      `json:"action_url"`
	Address      string      `json:"address"`
	Address6     string      `json:"address6"`
	CheckCommand string      `json:"check_command"`
	DisplayName  string      `json:"display_name"`
	Groups       []string    `json:"groups"`
	Notes        string      `json:"notes"`
	NotesURL     string      `json:"notes_url"`
	Templates    []string    `json:"templates"`
	Vars         interface{} `json:"vars"`
}

HostAttrs This is struct lists the attributes that can be set during a CreateHost call. The contents of the struct is converted into JSON

type HostStruct

type HostStruct struct {
	Name  string    `json:"name"`
	Type  string    `json:"type"`
	Attrs HostAttrs `json:"attrs"`
	Meta  struct{}  `json:"meta"`
	Joins struct{}  `json:"stuct"`
}

HostStruct is a struct used to store results from an Icinga2 Host API Call. The content are also used to generate the JSON for the CreateHost call

type HostgroupAttrs

type HostgroupAttrs struct {
	ActionURL   string   `json:"action_url"`
	DisplayName string   `json:"display_name"`
	Groups      []string `json:"groups"`
	Notes       string   `json:"notes"`
	NotesURL    string   `json:"notes_url"`
	Templates   []string `json:"templates"`
}

HostgroupAttrs ...

type HostgroupParams added in v0.5.2

type HostgroupParams struct {
	DisplayName string
}

HostgroupParams defines all available options related to updating a HostGroup.

type HostgroupStruct

type HostgroupStruct struct {
	Name  string         `json:"name"`
	Type  string         `json:"type"`
	Attrs HostgroupAttrs `json:"attrs"`
	Meta  struct{}       `json:"meta"`
	Joins struct{}       `json:"stuct"`
}

HostgroupStruct is a struct used to store results from an Icinga2 HostGroup API Call. The content are also used to generate the JSON for the CreateHost call

type NotificationAttrs added in v0.3.0

type NotificationAttrs struct {
	Command     string      `json:"command"`
	Users       []string    `json:"users"`
	Servicename string      `json:"service_name"`
	Interval    int         `json:"interval"`
	Vars        interface{} `json:"vars"`
	Templates   []string    `json:"templates"`
}

type NotificationStruct added in v0.3.0

type NotificationStruct struct {
	Attrs NotificationAttrs `json:"attrs"`
	Joins struct{}          `json:"joins"`
	Name  string            `json:"name"`
	Type  string            `json:"type"`
}

NotificationStruct stores notification results

type Server

type Server struct {
	Username           string
	Password           string
	BaseURL            string
	AllowUnverifiedSSL bool
	// contains filtered or unexported fields
}

Server ... Use to be ClientConfig

func New

func New(username, password, url string, allowUnverifiedSSL bool) (*Server, error)

func (*Server) Config

func (server *Server) Config(username, password, url string, allowUnverifiedSSL bool) (*Server, error)

func (*Server) Connect

func (server *Server) Connect() error

func (*Server) CreateCheckcommand

func (server *Server) CreateCheckcommand(name, command string, commandArguments map[string]string) ([]CheckcommandStruct, error)

CreateCheckcommand ...

func (*Server) CreateHost

func (server *Server) CreateHost(hostname, address, checkCommand string, variables map[string]string, templates []string, groups []string) ([]HostStruct, error)

CreateHost ...

func (*Server) CreateHostgroup

func (server *Server) CreateHostgroup(name, displayName string) ([]HostgroupStruct, error)

CreateHostgroup creates a new HostGroup with its name and display name.

func (*Server) CreateNotification added in v0.3.0

func (server *Server) CreateNotification(name, hostname, command, servicename string, interval int, users []string, vars map[string]string, templates []string) ([]NotificationStruct, error)

CreateNotification ...

func (*Server) CreateService

func (server *Server) CreateService(servicename, hostname, checkCommand string, variables map[string]string, templates []string) ([]ServiceStruct, error)

CreateService ...

func (*Server) CreateUser added in v0.3.0

func (server *Server) CreateUser(name, email string) ([]UserStruct, error)

CreateUser ...

func (*Server) DeleteCheckcommand

func (server *Server) DeleteCheckcommand(name string) error

DeleteCheckcommand ...

func (*Server) DeleteHost

func (server *Server) DeleteHost(hostname string) error

DeleteHost ...

func (*Server) DeleteHostgroup

func (server *Server) DeleteHostgroup(name string) error

DeleteHostgroup deletes a HostGroup by its name.

func (*Server) DeleteNotification added in v0.3.0

func (server *Server) DeleteNotification(name string) error

DeleteNotification ...

func (*Server) DeleteService

func (server *Server) DeleteService(servicename, hostname string) error

DeleteService ...

func (*Server) DeleteUser added in v0.3.0

func (server *Server) DeleteUser(name string) error

DeleteUser ...

func (*Server) GetCheckcommand

func (server *Server) GetCheckcommand(name string) ([]CheckcommandStruct, error)

GetCheckcommand ...

func (*Server) GetHost

func (server *Server) GetHost(hostname string) ([]HostStruct, error)

GetHost ...

func (*Server) GetHostgroup

func (server *Server) GetHostgroup(name string) ([]HostgroupStruct, error)

GetHostgroup fetches a HostGroup by its name.

func (*Server) GetNotification added in v0.3.0

func (server *Server) GetNotification(name string) ([]NotificationStruct, error)

GetNotification ...

func (*Server) GetService

func (server *Server) GetService(servicename, hostname string) ([]ServiceStruct, error)

GetService ...

func (*Server) GetUser added in v0.3.0

func (server *Server) GetUser(name string) ([]UserStruct, error)

GetUser ...

func (*Server) NewAPIRequest

func (server *Server) NewAPIRequest(method, APICall string, jsonString []byte) (*APIResult, error)

NewAPIRequest ...

func (*Server) UpdateHostgroup added in v0.5.2

func (server *Server) UpdateHostgroup(name string, params *HostgroupParams) ([]HostgroupStruct, error)

UpdateHostgroup updates a HostGroup with its params.

type ServiceAttrs

type ServiceAttrs struct {
	CheckCommand string      `json:"check_command"`
	Templates    []string    `json:"templates"`
	Vars         interface{} `json:"vars"`
}

type ServiceStruct

type ServiceStruct struct {
	Attrs ServiceAttrs `json:"attrs"`
	Joins struct{}     `json:"joins"`
	//	Meta  struct{}     `json:"meta"`
	Name string `json:"name"`
	Type string `json:"type"`
}

ServiceStruct stores service results

type UserAttrs added in v0.3.0

type UserAttrs struct {
	Email string `json:"email"`
}

UserAttrs This is struct lists the attributes that can be set during a CreateUser call. The contents of the struct is converted into JSON

type UserStruct added in v0.3.0

type UserStruct struct {
	Name  string    `json:"name"`
	Type  string    `json:"type"`
	Attrs UserAttrs `json:"attrs"`
	Meta  struct{}  `json:"meta"`
	Joins struct{}  `json:"stuct"`
}

UserStruct is a struct used to store results from an Icinga2 User API Call. The content are also used to generate the JSON for the CreateUser call

Jump to

Keyboard shortcuts

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