mirror of https://github.com/Icinga/icinga2.git
Merge pull request #7037 from lamaral/bugfix/api_doc_title
Fix incorrect title in API docs
This commit is contained in:
commit
f4e9028543
|
@ -1633,7 +1633,7 @@ have an active stage.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
### List Configuration Packages and their Stages <a id="icinga2-api-config-management-list-config-package-stage-files"></a>
|
### List Configuration Package Stage Files <a id="icinga2-api-config-management-list-config-package-stage-files"></a>
|
||||||
|
|
||||||
In order to retrieve a list of files for a stage you can send a `GET` request to
|
In order to retrieve a list of files for a stage you can send a `GET` request to
|
||||||
the URL endpoint `/v1/config/stages`. You need to include
|
the URL endpoint `/v1/config/stages`. You need to include
|
||||||
|
@ -1916,9 +1916,9 @@ The following example uses **Python** and the `requests` and `json` module:
|
||||||
$ vim icinga2-api-example.py
|
$ vim icinga2-api-example.py
|
||||||
|
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import requests, json
|
import requests, json
|
||||||
|
|
||||||
# Replace 'localhost' with your FQDN and certificate CN
|
# Replace 'localhost' with your FQDN and certificate CN
|
||||||
# for SSL verification
|
# for SSL verification
|
||||||
request_url = "https://localhost:5665/v1/objects/services"
|
request_url = "https://localhost:5665/v1/objects/services"
|
||||||
|
@ -1931,16 +1931,16 @@ The following example uses **Python** and the `requests` and `json` module:
|
||||||
"joins": [ "host.name", "host.state", "host.last_check_result" ],
|
"joins": [ "host.name", "host.state", "host.last_check_result" ],
|
||||||
"filter": "match(\"ping*\", service.name)",
|
"filter": "match(\"ping*\", service.name)",
|
||||||
}
|
}
|
||||||
|
|
||||||
r = requests.post(request_url,
|
r = requests.post(request_url,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
auth=('root', 'icinga'),
|
auth=('root', 'icinga'),
|
||||||
data=json.dumps(data),
|
data=json.dumps(data),
|
||||||
verify="pki/icinga2-ca.crt")
|
verify="pki/icinga2-ca.crt")
|
||||||
|
|
||||||
print "Request URL: " + str(r.url)
|
print "Request URL: " + str(r.url)
|
||||||
print "Status code: " + str(r.status_code)
|
print "Status code: " + str(r.status_code)
|
||||||
|
|
||||||
if (r.status_code == 200):
|
if (r.status_code == 200):
|
||||||
print "Result: " + json.dumps(r.json())
|
print "Result: " + json.dumps(r.json())
|
||||||
else:
|
else:
|
||||||
|
@ -1959,9 +1959,9 @@ The following example uses **Ruby** and the `rest_client` gem:
|
||||||
$ vim icinga2-api-example.rb
|
$ vim icinga2-api-example.rb
|
||||||
|
|
||||||
#!/usr/bin/ruby
|
#!/usr/bin/ruby
|
||||||
|
|
||||||
require 'rest_client'
|
require 'rest_client'
|
||||||
|
|
||||||
# Replace 'localhost' with your FQDN and certificate CN
|
# Replace 'localhost' with your FQDN and certificate CN
|
||||||
# for SSL verification
|
# for SSL verification
|
||||||
request_url = "https://localhost:5665/v1/objects/services"
|
request_url = "https://localhost:5665/v1/objects/services"
|
||||||
|
@ -1974,20 +1974,20 @@ The following example uses **Ruby** and the `rest_client` gem:
|
||||||
"joins" => [ "host.name", "host.state", "host.last_check_result" ],
|
"joins" => [ "host.name", "host.state", "host.last_check_result" ],
|
||||||
"filter" => "match(\"ping*\", service.name)",
|
"filter" => "match(\"ping*\", service.name)",
|
||||||
}
|
}
|
||||||
|
|
||||||
r = RestClient::Resource.new(
|
r = RestClient::Resource.new(
|
||||||
URI.encode(request_url),
|
URI.encode(request_url),
|
||||||
:headers => headers,
|
:headers => headers,
|
||||||
:user => "root",
|
:user => "root",
|
||||||
:password => "icinga",
|
:password => "icinga",
|
||||||
:ssl_ca_file => "pki/icinga2-ca.crt")
|
:ssl_ca_file => "pki/icinga2-ca.crt")
|
||||||
|
|
||||||
begin
|
begin
|
||||||
response = r.post(data.to_json)
|
response = r.post(data.to_json)
|
||||||
rescue => e
|
rescue => e
|
||||||
response = e.response
|
response = e.response
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Status: " + response.code.to_s
|
puts "Status: " + response.code.to_s
|
||||||
if response.code == 200
|
if response.code == 200
|
||||||
puts "Result: " + (JSON.pretty_generate JSON.parse(response.body))
|
puts "Result: " + (JSON.pretty_generate JSON.parse(response.body))
|
||||||
|
@ -2021,7 +2021,7 @@ The following example uses **PHP** and its `curl` library:
|
||||||
joins => array('host.name', 'host.state', 'host.last_check_result'),
|
joins => array('host.name', 'host.state', 'host.last_check_result'),
|
||||||
filter => 'match("ping*", service.name)',
|
filter => 'match("ping*", service.name)',
|
||||||
);
|
);
|
||||||
|
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt_array($ch, array(
|
curl_setopt_array($ch, array(
|
||||||
CURLOPT_URL => $request_url,
|
CURLOPT_URL => $request_url,
|
||||||
|
@ -2032,16 +2032,16 @@ The following example uses **PHP** and its `curl` library:
|
||||||
CURLOPT_POST => count($data),
|
CURLOPT_POST => count($data),
|
||||||
CURLOPT_POSTFIELDS => json_encode($data)
|
CURLOPT_POSTFIELDS => json_encode($data)
|
||||||
));
|
));
|
||||||
|
|
||||||
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
||||||
if ($response === false) {
|
if ($response === false) {
|
||||||
print "Error: " . curl_error($ch) . "(" . $response . ")\n";
|
print "Error: " . curl_error($ch) . "(" . $response . ")\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
print "Status: " . $code . "\n";
|
print "Status: " . $code . "\n";
|
||||||
|
|
||||||
if ($code == 200) {
|
if ($code == 200) {
|
||||||
$response = json_decode($response, true);
|
$response = json_decode($response, true);
|
||||||
print_r($response);
|
print_r($response);
|
||||||
|
@ -2062,19 +2062,19 @@ The following example uses **Perl** and the `Rest::Client` module:
|
||||||
$ vim icinga2-api-example.pl
|
$ vim icinga2-api-example.pl
|
||||||
|
|
||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use REST::Client;
|
use REST::Client;
|
||||||
use MIME::Base64;
|
use MIME::Base64;
|
||||||
use JSON;
|
use JSON;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
# Replace 'localhost' with your FQDN and certificate CN
|
# Replace 'localhost' with your FQDN and certificate CN
|
||||||
# for SSL verification
|
# for SSL verification
|
||||||
my $request_host = "https://localhost:5665";
|
my $request_host = "https://localhost:5665";
|
||||||
my $userpass = "root:icinga";
|
my $userpass = "root:icinga";
|
||||||
|
|
||||||
my $client = REST::Client->new();
|
my $client = REST::Client->new();
|
||||||
$client->setHost($request_host);
|
$client->setHost($request_host);
|
||||||
$client->setCa("pki/icinga2-ca.crt");
|
$client->setCa("pki/icinga2-ca.crt");
|
||||||
|
@ -2088,7 +2088,7 @@ The following example uses **Perl** and the `Rest::Client` module:
|
||||||
);
|
);
|
||||||
my $data = encode_json(\%json_data);
|
my $data = encode_json(\%json_data);
|
||||||
$client->POST("/v1/objects/services", $data);
|
$client->POST("/v1/objects/services", $data);
|
||||||
|
|
||||||
my $status = $client->responseCode();
|
my $status = $client->responseCode();
|
||||||
print "Status: " . $status . "\n";
|
print "Status: " . $status . "\n";
|
||||||
my $response = $client->responseContent();
|
my $response = $client->responseContent();
|
||||||
|
|
Loading…
Reference in New Issue