Documentation
¶
Overview ¶
Package icinga provides a client for using the Icinga2 API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.
Types ¶
type BasicAuthTransport ¶
type BasicAuthTransport struct { Username string // Icinga2 API username Password string // Icinga2 API password // Transport is the underlying HTTP transport to use when making requests. // It will default to http.DefaultTransport if nil. Transport http.RoundTripper }
BasicAuthTransport is an http.RoundTripper that authenticates all requests using HTTP Basic Authentication with the provided username and password.
func (*BasicAuthTransport) Client ¶
func (t *BasicAuthTransport) Client() *http.Client
Client returns an *http.Client that makes requests that are authenticated using HTTP Basic Authentication.
type Client ¶
type Client struct { // Base URL for API requests. // BaseURL should always be specified with a trailing slash. BaseURL *url.URL // User agent used when communicating Icinga2 API. UserAgent string // Services used for talking to different parts of the Icinga2 API. Hosts *HostsService // contains filtered or unexported fields }
Client manages communication with the Icinga2 API
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.
func (*Client) NewRequest ¶
NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
type ErrorResponse ¶
type ErrorResponse struct { Response *http.Response // HTTP response that caused this error Code json.Number `json:"error"` // error code Status string `json:"status"` // error message }
An ErrorResponse reports one or more errors caused by an API request.
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type Host ¶
type Host struct { Name string `json:"__name,omitempty" icinga:"create"` Acknowledgement json.Number `json:"acknowledgement,omitempty" icinga:""` AcknowledgementExpiry json.Number `json:"acknowledgement_expiry,omitempty" icinga:""` ActionURL string `json:"action_url,omitempty" icinga:""` Address string `json:"address,omitempty" icinga:"create"` Address6 string `json:"address6,omitempty" icinga:""` CheckAttempt json.Number `json:"check_attempt,omitempty" icinga:""` CheckCommand string `json:"check_command,omitempty" icinga:"create"` CheckInterval json.Number `json:"check_interval,omitempty" icinga:""` CheckPeriod string `json:"check_period,omitempty" icinga:""` CheckTimeout interface{} `json:"check_timeout,omitempty" icinga:""` CommandEndpoint string `json:"command_endpoint,omitempty" icinga:""` DisplayName string `json:"display_name,omitempty" icinga:""` DowntimeDepth json.Number `json:"downtime_depth,omitempty" icinga:""` EventCommand string `json:"event_command,omitempty" icinga:""` FlappingLastChange float64 `json:"flapping_last_change,omitempty" icinga:""` FlappingNegative json.Number `json:"flapping_negative,omitempty" icinga:""` FlappingPositive json.Number `json:"flapping_positive,omitempty" icinga:""` FlappingThreshold json.Number `json:"flapping_threshold,omitempty" icinga:""` Groups []string `json:"groups,omitempty" icinga:""` HaMode json.Number `json:"ha_mode,omitempty" icinga:""` IconImage string `json:"icon_image,omitempty" icinga:""` IconImageAlt string `json:"icon_image_alt,omitempty" icinga:""` LastCheck float64 `json:"last_check,omitempty" icinga:""` LastHardState json.Number `json:"last_hard_state,omitempty" icinga:""` LastHardStateChange float64 `json:"last_hard_state_change,omitempty" icinga:""` LastState json.Number `json:"last_state,omitempty" icinga:""` LastStateChange float64 `json:"last_state_change,omitempty" icinga:""` LastStateDown float64 `json:"last_state_down,omitempty" icinga:""` LastStateType json.Number `json:"last_state_type,omitempty" icinga:""` LastStateUnreachable json.Number `json:"last_state_unreachable,omitempty" icinga:""` LastStateUp float64 `json:"last_state_up,omitempty" icinga:""` MaxCheckAttempts json.Number `json:"max_check_attempts,omitempty" icinga:""` NextCheck float64 `json:"next_check,omitempty" icinga:""` Notes string `json:"notes,omitempty" icinga:""` NotesURL string `json:"notes_url,omitempty" icinga:""` OriginalAttributes interface{} `json:"original_attributes,omitempty" icinga:""` Package string `json:"package,omitempty" icinga:""` RetryInterval json.Number `json:"retry_interval,omitempty" icinga:""` State json.Number `json:"state,omitempty" icinga:""` StateType json.Number `json:"state_type,omitempty" icinga:""` Templates []string `json:"templates,omitempty" icinga:""` Type string `json:"type,omitempty" icinga:""` Version float64 `json:"version,omitempty" icinga:""` Zone string `json:"zone,omitempty" icinga:""` Flapping bool `json:"flapping,omitempty" icinga:""` Active bool `json:"active,omitempty" icinga:""` EnableActiveChecks bool `json:"enable_active_checks,omitempty" icinga:""` EnableEventHandler bool `json:"enable_event_handler,omitempty" icinga:""` EnableFlapping bool `json:"enable_flapping,omitempty" icinga:""` EnableNotifications bool `json:"enable_notifications,omitempty" icinga:""` EnablePassiveChecks bool `json:"enable_passive_checks,omitempty" icinga:""` EnablePerfdata bool `json:"enable_perfdata,omitempty" icinga:""` ForceNextCheck bool `json:"force_next_check,omitempty" icinga:""` ForceNextNotification bool `json:"force_next_notification,omitempty" icinga:""` LastReachable bool `json:"last_reachable,omitempty" icinga:""` Paused bool `json:"paused,omitempty" icinga:""` Volatile bool `json:"volatile,omitempty" icinga:""` Vars interface{} `json:"vars,omitempty" icinga:""` LastCheckResult *struct { Active bool `json:"active,omitempty"` CheckSource string `json:"check_source,omitempty"` Command []string `json:"command,omitempty"` ExecutionEnd float64 `json:"execution_end,omitempty"` ExecutionStart float64 `json:"execution_start,omitempty"` ExitStatus json.Number `json:"exit_status,omitempty"` Output string `json:"output,omitempty"` PerformanceData []string `json:"performance_data,omitempty"` ScheduleEnd float64 `json:"schedule_end,omitempty"` ScheduleStart float64 `json:"schedule_start,omitempty"` State json.Number `json:"state,omitempty"` Type string `json:"type,omitempty"` VarsAfter *struct { Attempt json.Number `json:"attempt,omitempty"` Reachable bool `json:"reachable,omitempty"` State json.Number `json:"state,omitempty"` StateType json.Number `json:"state_type,omitempty"` } `json:"vars_after,omitempty"` VarsBefore *struct { Attempt json.Number `json:"attempt,omitempty"` Reachable bool `json:"reachable,omitempty"` State json.Number `json:"state,omitempty"` StateType json.Number `json:"state_type,omitempty"` } `json:"vars_before,omitempty"` } `json:"last_check_result,omitempty" icinga:""` }
Host represents a Icinga2 Host object
type HostsService ¶
type HostsService service
HostsService handles communication with the host object related methods of the Icinga2 API