smart services API adjustments

This commit is contained in:
fbsanchez 2020-07-07 10:19:49 +02:00
parent 534aa8c7c5
commit 80015a8691
2 changed files with 78 additions and 39 deletions

View File

@ -29,7 +29,7 @@
// Begin.
require_once 'config.php';
require_once 'functions_api.php';
require '../vendor/autoload.php';
global $config;
define('DEBUG', 0);

View File

@ -13123,6 +13123,9 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3)
$quiet = $other['data'][11];
$cascade_protection = $other['data'][12];
$evaluate_sla = $other['data'][13];
$is_favourite = $other['data'][14];
$unknown_as_critical = $other['data'][15];
$server_name = $other['data'][16];
if (empty($name)) {
returnError('error_create_service', __('Error in creation service. No name'));
@ -13189,7 +13192,21 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3)
$evaluate_sla = 0;
}
$result = services_create_service(
if (empty($is_favourite)) {
$is_favourite = false;
}
if (empty($unknown_as_critical)) {
$unknown_as_critical = false;
}
if (empty($server_name)) {
$server_name = null;
}
$result = enterprise_hook(
'services_create_service',
[
$name,
$description,
$id_group,
@ -13206,7 +13223,8 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3)
$id_critical_module_sla,
$quiet,
$cascade_protection,
$evaluate_sla
$evaluate_sla,
]
);
if ($result) {
@ -13225,7 +13243,7 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3)
* @param array $other it's array, $other as param is <name>;<description>;<id_group>;<critical>;
* <warning>;<id_agent>;<sla_interval>;<sla_limit>;<id_warning_module_template_alert>;
* <id_critical_module_template_alert>;<id_critical_module_sla_template_alert>;<quiet>;
* <cascade_protection>;<evaluate_sla>;
* <cascade_protection>;<evaluate_sla>;<is_favourite>;<unknown_as_critical>;<server_name>;
* in this order and separator char (after text ; ) and separator
* (pass in param othermode as othermode=url_encode_separator_<separator>)
* @param $thrash3 Don't use
@ -13342,7 +13360,24 @@ function api_set_update_service($thrash1, $thrash2, $other, $thrash3)
$evaluate_sla = $service['evaluate_sla'];
}
$result = services_update_service(
$is_favourite = $other['data'][14];
if (empty($is_favourite)) {
$is_favourite = $service['is_favourite'];
}
$unknown_as_critical = $other['data'][15];
if (empty($unknown_as_critical)) {
$unknown_as_critical = $service['unknown_as_critical'];
}
$server_name = $other['data'][16];
if (empty($server_name)) {
$server_name = $service['server_name'];
}
$result = enterprise_hook(
'services_update_service',
[
$id_service,
$name,
$description,
@ -13360,7 +13395,11 @@ function api_set_update_service($thrash1, $thrash2, $other, $thrash3)
$id_critical_module_sla,
$quiet,
$cascade_protection,
$evaluate_sla
$evaluate_sla,
$is_favourite,
$unknown_as_critical,
$server_name,
]
);
if ($result) {