Skip to content

Latest commit

 

History

History
76 lines (52 loc) · 1.36 KB

client.md

File metadata and controls

76 lines (52 loc) · 1.36 KB

Client object

Requirements

  • Requests
  • urllib3
  • logging
  • json

Parameter

URLCHOICES => a list of uris that are used to switch between the different objects that icinga2 provides

Example

"host": "/v1/objects/hosts",
.
.
.
"users": "/v1/objects/users",

Functions

Constructor

Does not take any parameters.
Sets the default logger for debugging.
Creates a Session object that is used as the single connection to Icinga2.
Updates the Session Headers to include 'Accept': 'application/json'
Disables the urllib3 warning for self-signed certificates.

setconfig

Parameters taken:

  • username
  • password
  • url

Sets the baseurl as well as the username and Password needed for authentication.

get_Data

WARNING: This function is deprecated and will be removed in a later version

Parameters taken:

  • uri

Uses HTTP-GET to retrieve data from baseurl + uri. Returns a dictionary that is parsed from json.

delete_Data

Parameters taken:

  • uri

Uses HTTP-DELETE to remove objects from icinga2 Returns a dictionary that is parsed from json.

put_Data

Parameters taken:

  • uri
  • data

Uses HTTP-PUT to create new objects in Icinga2 Returns a dictionary that is parsed from json.

post_Data

Parameters taken:

  • uri
  • data

Uses HTTP-PUT to create new objects in Icinga2 Returns a dictionary that is parsed from json.