diff --git a/doc/12-icinga2-api.md b/doc/12-icinga2-api.md index 8032149c0..fe04a45d3 100644 --- a/doc/12-icinga2-api.md +++ b/doc/12-icinga2-api.md @@ -1,4 +1,20 @@ -# Icinga 2 API +# REST API + +* [Setup](12-icinga2-api.md#icinga2-api-setup) +* [Introduction](12-icinga2-api.md#icinga2-api-introduction) +* Endpoints + * [Config Objects](12-icinga2-api.md#icinga2-api-config-objects) + * [Actions](12-icinga2-api.md#icinga2-api-actions) + * [Event Streams](12-icinga2-api.md#icinga2-api-event-streams) + * [Status and Statistics](12-icinga2-api.md#icinga2-api-status) + * [Config Management](12-icinga2-api.md#icinga2-api-config-management) + * [Types](12-icinga2-api.md#icinga2-api-types) + * [Templates](12-icinga2-api.md#icinga2-api-config-templates) + * [Variables](12-icinga2-api.md#icinga2-api-variables) + * [Debug Console](12-icinga2-api.md#icinga2-api-console) +* [API Clients](12-icinga2-api.md#icinga2-api-clients) + * [Programmatic Examples](12-icinga2-api.md#icinga2-api-clients-programmatic-examples) + ## Setting up the API @@ -922,87 +938,6 @@ $ curl -k -s -u root:icinga -H 'Accept: application/json' \ } ``` -## Config Templates - -Provides methods to manage configuration templates: - -* [querying templates](12-icinga2-api.md#icinga2-api-config-templates-query) - -Creation, modification and deletion of templates at runtime is not supported. - -### Querying Templates - -You can request information about configuration templates by sending -a `GET` query to the `/v1/templates/` URL endpoint. ` - -Provides methods to manage global variables: - -* [querying variables](12-icinga2-api.md#icinga2-api-variables-query) - -### Querying Variables - -You can request information about global variables by sending -a `GET` query to the `/v1/variables/` URL endpoint: - -``` -$ curl -k -s -u root:icinga 'https://localhost:5665/v1/variables' -``` - -A [filter](12-icinga2-api.md#icinga2-api-filters) may be provided for this query type. The -variable information object can be accessed in the filter using the `variable` variable. -The `filter` attribute is passed inside the request body thus requiring to use [X-HTTP-Method-Override](12-icinga2-api.md#icinga2-api-requests-method-override) -here. - -``` -$ curl -k -s -u root:icinga -H 'Accept: application/json' \ - -H 'X-HTTP-Method-Override: GET' -X POST \ - 'https://localhost:5661/v1/variables' \ - -d '{ "filter": "variable.type in [ \"String\", \"Number\" ]" }' -``` - -Instead of using a filter you can optionally specify the variable name in the -URL path when querying a single variable: - -``` -$ curl -k -s -u root:icinga 'https://localhost:5665/v1/variables/PrefixDir' -``` - -The result set contains the type, name and value of the global variable. - ## Actions There are several actions available for Icinga 2 provided by the `/v1/actions` @@ -2174,6 +2109,87 @@ $ curl -k -s -u root:icinga 'https://localhost:5665/v1/types/Object?pretty=1' } ``` +## Config Templates + +Provides methods to manage configuration templates: + +* [querying templates](12-icinga2-api.md#icinga2-api-config-templates-query) + +Creation, modification and deletion of templates at runtime is not supported. + +### Querying Templates + +You can request information about configuration templates by sending +a `GET` query to the `/v1/templates/` URL endpoint. ` + +Provides methods to manage global variables: + +* [querying variables](12-icinga2-api.md#icinga2-api-variables-query) + +### Querying Variables + +You can request information about global variables by sending +a `GET` query to the `/v1/variables/` URL endpoint: + +``` +$ curl -k -s -u root:icinga 'https://localhost:5665/v1/variables' +``` + +A [filter](12-icinga2-api.md#icinga2-api-filters) may be provided for this query type. The +variable information object can be accessed in the filter using the `variable` variable. +The `filter` attribute is passed inside the request body thus requiring to use [X-HTTP-Method-Override](12-icinga2-api.md#icinga2-api-requests-method-override) +here. + +``` +$ curl -k -s -u root:icinga -H 'Accept: application/json' \ + -H 'X-HTTP-Method-Override: GET' -X POST \ + 'https://localhost:5661/v1/variables' \ + -d '{ "filter": "variable.type in [ \"String\", \"Number\" ]" }' +``` + +Instead of using a filter you can optionally specify the variable name in the +URL path when querying a single variable: + +``` +$ curl -k -s -u root:icinga 'https://localhost:5665/v1/variables/PrefixDir' +``` + +The result set contains the type, name and value of the global variable. + ## Debug Console You can inspect variables and execute other expressions by sending a `POST` request to the URL endpoint `/v1/console/execute-script`. @@ -2353,6 +2369,7 @@ The following languages are covered: * [PHP](12-icinga2-api.md#icinga2-api-clients-programmatic-examples-php) * [Perl](12-icinga2-api.md#icinga2-api-clients-programmatic-examples-perl) * [Golang](12-icinga2-api.md#icinga2-api-clients-programmatic-examples-golang) +* [Powershell](12-icinga2-api.md#icinga2-api-clients-programmatic-examples-powershell) The [request method](icinga2-api-requests) is `POST` using [X-HTTP-Method-Override: GET](12-icinga2-api.md#icinga2-api-requests-method-override) which allows you to send a JSON request body. The examples request specific service