mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-04-08 18:55:09 +02:00
update endpoints and add new fields integration pandoraitsm pandora_enterprise#13004
This commit is contained in:
parent
53bead2acc
commit
75f416ae50
@ -6,6 +6,8 @@ use PandoraFMS\Modules\Events\Repositories\EventRepository;
|
||||
use PandoraFMS\Modules\Events\Repositories\EventRepositoryMySQL;
|
||||
use PandoraFMS\Modules\Groups\Repositories\GroupRepository;
|
||||
use PandoraFMS\Modules\Groups\Repositories\GroupRepositoryMySQL;
|
||||
use PandoraFMS\Modules\PandoraITSM\Inventories\Repositories\PandoraITSMInventoryRepository;
|
||||
use PandoraFMS\Modules\PandoraITSM\Inventories\Repositories\PandoraITSMInventoryRepositoryMySQL;
|
||||
use PandoraFMS\Modules\Shared\Repositories\Repository;
|
||||
use PandoraFMS\Modules\Shared\Repositories\RepositoryMySQL;
|
||||
use PandoraFMS\Modules\Users\Repositories\UserRepository;
|
||||
@ -15,10 +17,10 @@ use Slim\App;
|
||||
use Slim\Factory\AppFactory;
|
||||
|
||||
return [
|
||||
'settings' => function () {
|
||||
'settings' => function () {
|
||||
return include __DIR__.'/settings.php';
|
||||
},
|
||||
App::class => function (ContainerInterface $container) {
|
||||
App::class => function (ContainerInterface $container) {
|
||||
AppFactory::setContainer($container);
|
||||
|
||||
$app = AppFactory::create();
|
||||
@ -39,19 +41,22 @@ return [
|
||||
|
||||
return $app;
|
||||
},
|
||||
Repository::class => function (ContainerInterface $container) {
|
||||
Repository::class => function (ContainerInterface $container) {
|
||||
return $container->get(RepositoryMySQL::class);
|
||||
},
|
||||
TokenRepository::class => function (ContainerInterface $container) {
|
||||
TokenRepository::class => function (ContainerInterface $container) {
|
||||
return $container->get(TokenRepositoryMySQL::class);
|
||||
},
|
||||
UserRepository::class => function (ContainerInterface $container) {
|
||||
UserRepository::class => function (ContainerInterface $container) {
|
||||
return $container->get(UserRepositoryMySQL::class);
|
||||
},
|
||||
GroupRepository::class => function (ContainerInterface $container) {
|
||||
GroupRepository::class => function (ContainerInterface $container) {
|
||||
return $container->get(GroupRepositoryMySQL::class);
|
||||
},
|
||||
EventRepository::class => function (ContainerInterface $container) {
|
||||
EventRepository::class => function (ContainerInterface $container) {
|
||||
return $container->get(EventRepositoryMySQL::class);
|
||||
},
|
||||
PandoraITSMInventoryRepository::class => function (ContainerInterface $container) {
|
||||
return $container->get(PandoraITSMInventoryRepositoryMySQL::class);
|
||||
},
|
||||
];
|
||||
|
@ -9,4 +9,5 @@ return function (App $app) {
|
||||
(include __DIR__.'/../../../include/lib/Modules/Profiles/routes.php')($app);
|
||||
(include __DIR__.'/../../../include/lib/Modules/Tags/routes.php')($app);
|
||||
(include __DIR__.'/../../../include/lib/Modules/Users/routes.php')($app);
|
||||
(include __DIR__.'/../../../include/lib/Modules/PandoraITSM/routes.php')($app);
|
||||
};
|
||||
|
@ -1118,6 +1118,110 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/pandoraITSM/inventory/{idPandoraITSMInventory}": {
|
||||
"get": {
|
||||
"tags": ["PandoraITSM"],
|
||||
"summary": "Show pandoraITSMInventory",
|
||||
"operationId": "09b6d1f91536441fc65dc66142a6f9cb",
|
||||
"parameters": [
|
||||
{
|
||||
"$ref": "#/components/parameters/parameterIdPandoraITSMInventory"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/components/responses/ResponsePandoraITSMInventory"
|
||||
},
|
||||
"400": {
|
||||
"$ref": "#/components/responses/BadRequest"
|
||||
},
|
||||
"401": {
|
||||
"$ref": "#/components/responses/Unauthorized"
|
||||
},
|
||||
"403": {
|
||||
"$ref": "#/components/responses/Forbidden"
|
||||
},
|
||||
"404": {
|
||||
"$ref": "#/components/responses/NotFound"
|
||||
},
|
||||
"500": {
|
||||
"$ref": "#/components/responses/InternalServerError"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearerAuth": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/pandoraITSM/inventory/list": {
|
||||
"post": {
|
||||
"tags": ["PandoraITSM"],
|
||||
"summary": "List pandoraITSMInventories",
|
||||
"operationId": "149f20397779ed681c1f7680c1214974",
|
||||
"parameters": [
|
||||
{
|
||||
"$ref": "#/components/parameters/parameterPage"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/parameters/parameterSizePage"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/parameters/parameterSortField"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/parameters/parameterSortDirection"
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"$ref": "#/components/requestBodies/requestBodyPandoraITSMInventoryFilter"
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "List PandoraITSM Inventories Object",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"paginationData": {
|
||||
"$ref": "#/components/schemas/paginationData"
|
||||
},
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/PandoraITSMInventory"
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"$ref": "#/components/responses/BadRequest"
|
||||
},
|
||||
"401": {
|
||||
"$ref": "#/components/responses/Unauthorized"
|
||||
},
|
||||
"403": {
|
||||
"$ref": "#/components/responses/Forbidden"
|
||||
},
|
||||
"404": {
|
||||
"$ref": "#/components/responses/NotFound"
|
||||
},
|
||||
"500": {
|
||||
"$ref": "#/components/responses/InternalServerError"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearerAuth": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/profile": {
|
||||
"post": {
|
||||
"tags": ["Profiles"],
|
||||
@ -2081,6 +2185,192 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"Event": {
|
||||
"properties": {
|
||||
"idEvent": {
|
||||
"description": "Id event",
|
||||
"type": "integer",
|
||||
"readOnly": true,
|
||||
"nullable": false
|
||||
},
|
||||
"idAgent": {
|
||||
"description": "Id agent",
|
||||
"type": "integer",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"idUser": {
|
||||
"description": "Id user",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"idGroup": {
|
||||
"description": "Id group",
|
||||
"type": "integer",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"status": {
|
||||
"description": "Event status, the available status are: new, validated, inprocess",
|
||||
"type": "integer",
|
||||
"default": "new",
|
||||
"enum": ["new", "validated", "inprocess"],
|
||||
"nullable": false
|
||||
},
|
||||
"timestamp": {
|
||||
"description": "Event registration date",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"readOnly": true,
|
||||
"example": "2023-02-21 08:34:16",
|
||||
"nullable": true
|
||||
},
|
||||
"event": {
|
||||
"description": "Description event",
|
||||
"type": "string",
|
||||
"default": "Event created for api",
|
||||
"nullable": false
|
||||
},
|
||||
"utimestamp": {
|
||||
"description": "Event registration date",
|
||||
"type": "integer",
|
||||
"default": null,
|
||||
"readOnly": true,
|
||||
"example": "1704898868",
|
||||
"nullable": true
|
||||
},
|
||||
"eventType": {
|
||||
"description": "Event status, the available status are: going_unknown, unknown, alert_fired, alert_recovered, alert_ceased, alert_manual_validation, recon_host_detected, system, error, new_agent, going_up_critical, going_down_critical, going_up_warning, going_down_warning, going_up_normal, going_down_normal, configuration_change, ncm",
|
||||
"type": "string",
|
||||
"default": "unknown",
|
||||
"enum": [
|
||||
"going_unknown",
|
||||
"unknown",
|
||||
"alert_fired",
|
||||
"alert_recovered",
|
||||
"alert_ceased",
|
||||
"alert_manual_validation",
|
||||
"recon_host_detected",
|
||||
"system",
|
||||
"error",
|
||||
"new_agent",
|
||||
"going_up_critical",
|
||||
"going_down_critical",
|
||||
"going_up_warning",
|
||||
"going_down_warning",
|
||||
"going_up_normal",
|
||||
"going_down_normal",
|
||||
"configuration_change",
|
||||
"ncm"
|
||||
],
|
||||
"nullable": false
|
||||
},
|
||||
"idAgentModule": {
|
||||
"description": "Id agent module",
|
||||
"type": "integer",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"idAlertAm": {
|
||||
"description": "Id alert action",
|
||||
"type": "integer",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"severity": {
|
||||
"description": "Event severity, the available severity are: maintenance, informational, normal, warning, critical, minor, major",
|
||||
"type": "integer",
|
||||
"default": "maintenance",
|
||||
"enum": [
|
||||
"maintenance",
|
||||
"informational",
|
||||
"normal",
|
||||
"warning",
|
||||
"critical",
|
||||
"minor",
|
||||
"major"
|
||||
],
|
||||
"nullable": false
|
||||
},
|
||||
"tags": {
|
||||
"description": "Tags",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"source": {
|
||||
"description": "Source",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"idExtra": {
|
||||
"description": "Extra id",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"criticalInstructions": {
|
||||
"description": "Critical instructions",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"warningInstructions": {
|
||||
"description": "Warning instructions",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"unknownInstructions": {
|
||||
"description": "Unknows instructions",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"ownerUser": {
|
||||
"description": "Id user",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"ackUtimestamp": {
|
||||
"description": "Event ack utimestamp",
|
||||
"type": "integer",
|
||||
"default": null,
|
||||
"readOnly": true,
|
||||
"example": "1704898868",
|
||||
"nullable": true
|
||||
},
|
||||
"customData": {
|
||||
"description": "Custom data",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"data": {
|
||||
"description": "Data",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"moduleStatus": {
|
||||
"description": "Module status",
|
||||
"type": "integer",
|
||||
"default": null,
|
||||
"readOnly": true,
|
||||
"nullable": true
|
||||
},
|
||||
"eventCustomId": {
|
||||
"description": "Events Custom Id",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"EventFilter": {
|
||||
"properties": {
|
||||
"idEventFilter": {
|
||||
@ -2529,6 +2819,96 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"PandoraITSMInventory": {
|
||||
"properties": {
|
||||
"idPandoraITSMInventory": {
|
||||
"description": "Id Agent pandoraITSMInventory",
|
||||
"type": "integer",
|
||||
"readOnly": true,
|
||||
"nullable": false
|
||||
},
|
||||
"agentAlias": {
|
||||
"description": "Agent Name pandoraITSMInventory",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"osVersion": {
|
||||
"description": "Agent os version pandoraITSMInventory",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"agentAddress": {
|
||||
"description": "Agent address pandoraITSMInventory",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"agentUrlAddress": {
|
||||
"description": "Agent url address pandoraITSMInventory",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"agentDisabled": {
|
||||
"description": "Agent disable pandoraITSMInventory",
|
||||
"type": "boolean",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"groupName": {
|
||||
"description": "Agent group name pandoraITSMInventory",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"groupId": {
|
||||
"description": "Agent group id pandoraITSMInventory",
|
||||
"type": "integer",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
"osName": {
|
||||
"description": "Agent OS name pandoraITSMInventory",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"PandoraITSMInventoryFilter": {
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/PandoraITSMInventory"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"idPandoraITSMInventory": {
|
||||
"default": null,
|
||||
"readOnly": false
|
||||
},
|
||||
"freeSearch": {
|
||||
"description": "Find word in name field.",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"multipleSearch": {
|
||||
"$ref": "#/components/schemas/multipleSearch"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Profile": {
|
||||
"properties": {
|
||||
"idProfile": {
|
||||
@ -2707,6 +3087,42 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"multipleSearch": {
|
||||
"properties": {
|
||||
"field": {
|
||||
"description": "Field to search of query",
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"data": {
|
||||
"description": "Values to search of query IN()",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
},
|
||||
"nullable": true
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"multipleSearchString": {
|
||||
"properties": {
|
||||
"field": {
|
||||
"description": "Field to search of query",
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"data": {
|
||||
"description": "Values to search of query IN()",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"nullable": true
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"paginationData": {
|
||||
"description": "Info pagination data",
|
||||
"properties": {
|
||||
@ -3196,12 +3612,14 @@
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
},
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"multipleSearchString": {
|
||||
"description": "search string in field.",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
"$ref": "#/components/schemas/multipleSearch"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
@ -3316,6 +3734,16 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"ResponseEvent": {
|
||||
"description": "Event object",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Event"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ResponseEventFilter": {
|
||||
"description": "EventFilter object",
|
||||
"content": {
|
||||
@ -3336,6 +3764,16 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"ResponsePandoraITSMInventory": {
|
||||
"description": "PandoraITSMInventory object",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/PandoraITSMInventory"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ResponseProfile": {
|
||||
"description": "Profile object",
|
||||
"content": {
|
||||
@ -3499,6 +3937,16 @@
|
||||
"default": 1
|
||||
}
|
||||
},
|
||||
"parameterIdEvent": {
|
||||
"name": "idEvent",
|
||||
"in": "path",
|
||||
"description": "Event id",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"default": 1
|
||||
}
|
||||
},
|
||||
"parameterIdEventFilter": {
|
||||
"name": "idEventFilter",
|
||||
"in": "path",
|
||||
@ -3519,6 +3967,16 @@
|
||||
"default": 1
|
||||
}
|
||||
},
|
||||
"parameterIdPandoraITSMInventory": {
|
||||
"name": "idPandoraITSMInventory",
|
||||
"in": "path",
|
||||
"description": "PandoraITSMInventory id",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"default": 1
|
||||
}
|
||||
},
|
||||
"parameterIdProfile": {
|
||||
"name": "idProfile",
|
||||
"in": "path",
|
||||
@ -3642,6 +4100,16 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"requestBodyEvent": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Event"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"requestBodyEventFilter": {
|
||||
"required": true,
|
||||
"content": {
|
||||
@ -3682,6 +4150,26 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"requestBodyPandoraITSMInventory": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/PandoraITSMInventory"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"requestBodyPandoraITSMInventoryFilter": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/PandoraITSMInventoryFilter"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"requestBodyProfile": {
|
||||
"required": true,
|
||||
"content": {
|
||||
@ -3797,6 +4285,10 @@
|
||||
{
|
||||
"name": "Users",
|
||||
"description": "API Endpoints of users"
|
||||
},
|
||||
{
|
||||
"name": "PandoraITSM",
|
||||
"description": "API Endpoints of integration pandoraITSM"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -56,11 +56,18 @@ try {
|
||||
$status_values = $ITSM->getStatus();
|
||||
$object_types_values = $ITSM->getObjectypes();
|
||||
if ((bool) get_parameter('update_config', 0) === true) {
|
||||
$ITSM_groups_agents_sync_base = null;
|
||||
if (empty($config['ITSM_groups_agents_sync']) === false) {
|
||||
$ITSM_groups_agents_sync_base = base64_encode($config['ITSM_groups_agents_sync']);
|
||||
}
|
||||
|
||||
$set_config_inventories = $ITSM->createNode(
|
||||
[
|
||||
'serverAuth' => $config['server_unique_identifier'],
|
||||
'apiPass' => $config['api_password'],
|
||||
'serverAuth' => md5($config['server_unique_identifier']),
|
||||
'apiPass' => md5($config['api_password']),
|
||||
'agentsForExecution' => $config['ITSM_agents_sync'],
|
||||
'groups' => $ITSM_groups_agents_sync_base,
|
||||
'mode' => $config['ITSM_mode_agents_sync'],
|
||||
'path' => $config['ITSM_public_url'],
|
||||
'label' => array_keys(servers_get_names())[0],
|
||||
'nodeId' => $config['metaconsole_node_id'],
|
||||
@ -69,7 +76,7 @@ try {
|
||||
}
|
||||
|
||||
try {
|
||||
$node = $ITSM->getNode($config['server_unique_identifier']);
|
||||
$node = $ITSM->getNode(md5($config['server_unique_identifier']));
|
||||
} catch (\Throwable $th) {
|
||||
$node = [];
|
||||
}
|
||||
@ -207,7 +214,7 @@ if (empty($itsm_public_url) === true) {
|
||||
|
||||
$row['publicUrl'] = html_print_label_input_block(
|
||||
__('URL conect to API %s', get_product_name()).ui_print_help_tip(
|
||||
__('Full URL to your Pandora (e.g., http://192.168.1.20).'),
|
||||
__('Full URL to your Pandora (e.g., http://192.168.1.20/XXX/api/v2).'),
|
||||
true
|
||||
),
|
||||
html_print_input_text(
|
||||
@ -237,6 +244,55 @@ $row['agentsSync'] = html_print_label_input_block(
|
||||
|
||||
$table_remote->data['ITSM_sync_inventory'] = $row;
|
||||
|
||||
$row = [];
|
||||
$itsm_groups_agents_sync = [];
|
||||
if (empty($config['ITSM_groups_agents_sync']) === false) {
|
||||
$itsm_groups_agents_sync = json_decode(
|
||||
io_safe_output($config['ITSM_groups_agents_sync']),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
$mode_values = [
|
||||
1 => __('Enable'),
|
||||
2 => __('Disable'),
|
||||
];
|
||||
|
||||
$row['modeAgentsSync'] = html_print_label_input_block(
|
||||
__('Mode Agents to synchronize'),
|
||||
html_print_select(
|
||||
$mode_values,
|
||||
'ITSM_mode_agents_sync',
|
||||
$config['ITSM_mode_agents_sync'],
|
||||
'',
|
||||
__('All'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
$row['groupsAgentsSync'] = html_print_label_input_block(
|
||||
__('Groups Agents to synchronize'),
|
||||
html_print_select_groups(
|
||||
false,
|
||||
'AW',
|
||||
false,
|
||||
'ITSM_groups_agents_sync[]',
|
||||
$itsm_groups_agents_sync,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
$table_remote->data['ITSM_sync_inventory_filters'] = $row;
|
||||
|
||||
// Test.
|
||||
$row = [];
|
||||
$button_test_pandora = html_print_button(
|
||||
|
@ -1972,6 +1972,27 @@ function config_update_config()
|
||||
$error_update[] = __('Pandora ITSM API agents sync');
|
||||
}
|
||||
|
||||
$ITSM_mode_agents_sync = (int) get_parameter(
|
||||
'ITSM_mode_agents_sync',
|
||||
$config['ITSM_mode_agents_sync']
|
||||
);
|
||||
if (config_update_value('ITSM_mode_agents_sync', $ITSM_mode_agents_sync, true) === false) {
|
||||
$error_update[] = __('Pandora ITSM mode agents to synch');
|
||||
}
|
||||
|
||||
$ITSM_groups_agents_sync = get_parameter(
|
||||
'ITSM_groups_agents_sync',
|
||||
null
|
||||
);
|
||||
|
||||
if (empty($ITSM_groups_agents_sync) === false) {
|
||||
$ITSM_groups_agents_sync = json_encode($ITSM_groups_agents_sync);
|
||||
}
|
||||
|
||||
if (config_update_value('ITSM_groups_agents_sync', $ITSM_groups_agents_sync, true) === false) {
|
||||
$error_update[] = __('Pandora ITSM groups agents to synch');
|
||||
}
|
||||
|
||||
$incident_default_group = (int) get_parameter('default_group', $config['default_group']);
|
||||
if (empty($incident_default_group) === true) {
|
||||
try {
|
||||
@ -3923,6 +3944,14 @@ function config_process_config()
|
||||
config_update_value('ITSM_agents_sync', 20);
|
||||
}
|
||||
|
||||
if (!isset($config['ITSM_mode_agents_sync'])) {
|
||||
config_update_value('ITSM_mode_agents_sync', 0);
|
||||
}
|
||||
|
||||
if (!isset($config['ITSM_groups_agents_sync'])) {
|
||||
config_update_value('ITSM_groups_agents_sync', null);
|
||||
}
|
||||
|
||||
// Module Library.
|
||||
if (!isset($config['module_library_user'])) {
|
||||
config_update_value('module_library_user', '');
|
||||
|
@ -179,6 +179,7 @@ function testConectionApiItsmToPandora(path) {
|
||||
} else {
|
||||
showFailureImage();
|
||||
showMessage();
|
||||
$("span#ITSM-message-pandora").html(data);
|
||||
}
|
||||
})
|
||||
.fail(function() {
|
||||
|
@ -594,7 +594,7 @@ class ITSM
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function pingItsmtoPandora(string $path): bool
|
||||
public function pingItsmtoPandora(string $path): array
|
||||
{
|
||||
global $config;
|
||||
|
||||
@ -603,12 +603,12 @@ class ITSM
|
||||
[],
|
||||
[
|
||||
'path' => $path,
|
||||
'apiPass' => $config['api_password'],
|
||||
'serverAuth' => $config['server_unique_identifier'],
|
||||
'apiPass' => md5($config['api_password']),
|
||||
'serverAuth' => md5($config['server_unique_identifier']),
|
||||
]
|
||||
);
|
||||
|
||||
return (bool) $result['valid'];
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1500,12 +1500,10 @@ class Manager
|
||||
$ITSM = new ITSM();
|
||||
$result = $ITSM->pingItsmtoPandora($path);
|
||||
} catch (Throwable $e) {
|
||||
echo $e->getMessage();
|
||||
$result = false;
|
||||
exit;
|
||||
$result = $e->getMessage();
|
||||
}
|
||||
|
||||
echo json_encode(['valid' => ($result !== false) ? 1 : 0]);
|
||||
echo json_encode($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ final class TokenRepositoryMySQL extends RepositoryMySQL implements TokenReposit
|
||||
$filters = $this->buildQueryFilters($filter, $mapper);
|
||||
|
||||
// Check ACL for user list.
|
||||
if (\users_is_admin() === false) {
|
||||
if (empty($this->config->get('id_user')) === false && \users_is_admin() === false) {
|
||||
// No admin.
|
||||
$filters .= sprintf(
|
||||
' AND ttoken.id_user = "%s"',
|
||||
|
@ -16,7 +16,7 @@ use PandoraFMS\Modules\Shared\Entities\Entity;
|
||||
* property="idEvent",
|
||||
* type="integer",
|
||||
* nullable=false,
|
||||
* description="Id event"
|
||||
* description="Id event",
|
||||
* readOnly=true
|
||||
* ),
|
||||
* @OA\Property(
|
||||
@ -212,7 +212,7 @@ use PandoraFMS\Modules\Shared\Entities\Entity;
|
||||
* nullable=true,
|
||||
* default=null,
|
||||
* description="Module status",
|
||||
* readonly=true
|
||||
* readOnly=true
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="eventCustomId",
|
||||
|
@ -60,6 +60,10 @@ More useful links:
|
||||
* name="Users",
|
||||
* description="API Endpoints of users"
|
||||
* ),
|
||||
* @OA\Tag(
|
||||
* name="PandoraITSM",
|
||||
* description="API Endpoints of integration pandoraITSM"
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* parameter="parameterPage",
|
||||
* name="page",
|
||||
@ -223,7 +227,43 @@ More useful links:
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
*
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="multipleSearch",
|
||||
* type="object",
|
||||
* @OA\Property(
|
||||
* property="field",
|
||||
* type="string",
|
||||
* nullable=true,
|
||||
* description="Field to search of query"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="data",
|
||||
* type="array",
|
||||
* nullable=true,
|
||||
* @OA\Items(type="integer"),
|
||||
* description="Values to search of query IN()"
|
||||
* )
|
||||
* )
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="multipleSearchString",
|
||||
* type="object",
|
||||
* @OA\Property(
|
||||
* property="field",
|
||||
* type="string",
|
||||
* nullable=true,
|
||||
* description="Field to search of query"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="data",
|
||||
* type="array",
|
||||
* nullable=true,
|
||||
* @OA\Items(type="string"),
|
||||
* description="Values to search of query IN()"
|
||||
* )
|
||||
* )
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="paginationData",
|
||||
* type="object",
|
||||
|
@ -30,22 +30,23 @@ final class UserTokenMiddleware
|
||||
$token = null;
|
||||
try {
|
||||
$authorization = str_replace('Bearer ', '', $authorization);
|
||||
preg_match(
|
||||
'/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/',
|
||||
$authorization,
|
||||
$matches
|
||||
);
|
||||
|
||||
$uuid = ($matches[0] ?? '');
|
||||
if (empty($uuid) === true) {
|
||||
return false;
|
||||
}
|
||||
$strToken = str_replace($uuid.'-', '', $authorization);
|
||||
$validTokenUiniqueServerIdentifier = $this->validateServerIdentifierTokenService->__invoke($strToken);
|
||||
$validTokenUiniqueServerIdentifier = $this->validateServerIdentifierTokenService->__invoke($authorization);
|
||||
if ($validTokenUiniqueServerIdentifier === false) {
|
||||
preg_match(
|
||||
'/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/',
|
||||
$authorization,
|
||||
$matches
|
||||
);
|
||||
|
||||
$uuid = ($matches[0] ?? '');
|
||||
if (empty($uuid) === true) {
|
||||
return false;
|
||||
}
|
||||
$strToken = str_replace($uuid.'-', '', $authorization);
|
||||
$validToken = $this->validateUserTokenService->__invoke($uuid, $strToken);
|
||||
$token = $this->getUserTokenService->__invoke($uuid);
|
||||
if ($token !== null && $validToken) {
|
||||
$this->config->set('id_user', $token->getIdUser());
|
||||
$oldToken = clone $token;
|
||||
$token->setLastUsage($this->timestamp->getMysqlCurrentTimestamp(0));
|
||||
$this->updateTokenService->__invoke($token, $oldToken);
|
||||
|
@ -165,16 +165,32 @@ class RepositoryMySQL extends Repository
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function buildQueryFilters(FilterAbstract $filter, DataMapperAbstract $mapper): string
|
||||
public function buildQueryFilters(FilterAbstract $filter, ?DataMapperAbstract $mapper = null): string
|
||||
{
|
||||
$where_clause = '1=1';
|
||||
|
||||
if ($filter->getEntityFilter() !== null) {
|
||||
if ($mapper !== null && $filter->getEntityFilter() !== null) {
|
||||
$searchEntity = $mapper->toDatabase($filter->getEntityFilter());
|
||||
$searchEntity = array_filter($searchEntity, fn ($value) => !is_null($value) && $value !== '' && $value !== 'null');
|
||||
if (empty($searchEntity) === false) {
|
||||
$where_clause .= ' AND '.$this->dbFormatWhereClauseSQL($searchEntity, '`'.$mapper->getTableName().'`.');
|
||||
}
|
||||
} else {
|
||||
$searchEntity = $filter->getEntityFilter()->toArray();
|
||||
$translates = $filter->fieldsTranslate();
|
||||
$searchEntity = array_filter($searchEntity, fn ($value) => !is_null($value) && $value !== '' && $value !== 'null');
|
||||
if(empty($searchEntity) === false) {
|
||||
$resultEntity = [];
|
||||
foreach ($searchEntity as $key => $value) {
|
||||
if (isset($translates[$key]) === true) {
|
||||
$resultEntity[$translates[$key]] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($resultEntity) === false) {
|
||||
$where_clause .= ' AND '.$this->dbFormatWhereClauseSQL($resultEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($filter->getFieldsFreeSearch()) === false
|
||||
@ -222,8 +238,16 @@ class RepositoryMySQL extends Repository
|
||||
{
|
||||
$fields = $filter->fieldsTranslate();
|
||||
$field = '';
|
||||
if (empty($fields) === false) {
|
||||
if (empty($fields) === false
|
||||
&& isset($fields[($filter->getMultipleSearch()['field'])]) === true) {
|
||||
$field = ($fields[($filter->getMultipleSearch()['field'] ?? '')] ?? '');
|
||||
} else {
|
||||
throw new Exception(
|
||||
__(
|
||||
'Bad request, multiple field %s is not a valid field',
|
||||
$filter->getMultipleSearch()['field']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($field) === true) {
|
||||
@ -238,8 +262,17 @@ class RepositoryMySQL extends Repository
|
||||
{
|
||||
$fields = $filter->fieldsTranslate();
|
||||
$field = '';
|
||||
if (empty($fields) === false) {
|
||||
if (empty($fields) === false
|
||||
&& isset($fields[($filter->getMultipleSearchString()['field'])]) === true
|
||||
) {
|
||||
$field = ($fields[($filter->getMultipleSearchString()['field'] ?? '')] ?? '');
|
||||
} else {
|
||||
throw new Exception(
|
||||
__(
|
||||
'Bad request, multiple field %s is not a valid field',
|
||||
$filter->getMultipleSearchString()['field']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($field) === true) {
|
||||
|
@ -18,13 +18,14 @@ use PandoraFMS\Modules\Users\Validators\UserValidator;
|
||||
* nullable=true,
|
||||
* default=null,
|
||||
* description="Find word in fullname and comments fields."
|
||||
* ),
|
||||
* )
|
||||
* ),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(
|
||||
* property="multipleSearchString",
|
||||
* type="string",
|
||||
* nullable=true,
|
||||
* default=null,
|
||||
* description="search string in field."
|
||||
* type="object",
|
||||
* ref="#/components/schemas/multipleSearch",
|
||||
* description="Multiple search object",
|
||||
* )
|
||||
* )
|
||||
* }
|
||||
|
Loading…
x
Reference in New Issue
Block a user