new api 2.0
This commit is contained in:
parent
851b046add
commit
0f6fab06fb
|
@ -2081,191 +2081,6 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"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,
|
||||
"nullable": true
|
||||
},
|
||||
"eventCustomId": {
|
||||
"description": "Events Custom Id",
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"nullable": true
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"EventFilter": {
|
||||
"properties": {
|
||||
"idEventFilter": {
|
||||
|
@ -3501,16 +3316,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"ResponseEvent": {
|
||||
"description": "Event object",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Event"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ResponseEventFilter": {
|
||||
"description": "EventFilter object",
|
||||
"content": {
|
||||
|
@ -3694,16 +3499,6 @@
|
|||
"default": 1
|
||||
}
|
||||
},
|
||||
"parameterIdEvent": {
|
||||
"name": "idEvent",
|
||||
"in": "path",
|
||||
"description": "Event id",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"default": 1
|
||||
}
|
||||
},
|
||||
"parameterIdEventFilter": {
|
||||
"name": "idEventFilter",
|
||||
"in": "path",
|
||||
|
@ -3847,16 +3642,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"requestBodyEvent": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Event"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"requestBodyEventFilter": {
|
||||
"required": true,
|
||||
"content": {
|
||||
|
|
|
@ -1929,7 +1929,7 @@ function events_get_all(
|
|||
&& $sort_field !== 'server_name'
|
||||
&& $sort_field !== 'timestamp'
|
||||
) {
|
||||
$sort_field = explode('.', $sort_field)[1];
|
||||
$sort_field = (explode('.', $sort_field)[1] ?? $sort_field);
|
||||
if ($sort_field === 'user_comment') {
|
||||
$sort_field = 'comments';
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
@ -24,14 +24,14 @@ use PandoraFMS\Modules\Shared\Entities\Entity;
|
|||
* type="integer",
|
||||
* nullable=true,
|
||||
* default=null,
|
||||
* description="Id agent",
|
||||
* description="Id agent"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="idUser",
|
||||
* type="string",
|
||||
* nullable=true,
|
||||
* default=null,
|
||||
* description="Id user",
|
||||
* description="Id user"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="idGroup",
|
||||
|
@ -66,7 +66,7 @@ use PandoraFMS\Modules\Shared\Entities\Entity;
|
|||
* type="string",
|
||||
* nullable=false,
|
||||
* default="Event created for api",
|
||||
* description="Description event",
|
||||
* description="Description event"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="utimestamp",
|
||||
|
@ -109,14 +109,14 @@ use PandoraFMS\Modules\Shared\Entities\Entity;
|
|||
* type="integer",
|
||||
* nullable=true,
|
||||
* default=null,
|
||||
* description="Id agent module",
|
||||
* description="Id agent module"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="idAlertAm",
|
||||
* type="integer",
|
||||
* nullable=true,
|
||||
* default=null,
|
||||
* description="Id alert action",
|
||||
* description="Id alert action"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="severity",
|
||||
|
@ -139,49 +139,49 @@ use PandoraFMS\Modules\Shared\Entities\Entity;
|
|||
* type="string",
|
||||
* nullable=true,
|
||||
* default=null,
|
||||
* description="Tags",
|
||||
* description="Tags"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="source",
|
||||
* type="string",
|
||||
* nullable=true,
|
||||
* default=null,
|
||||
* description="Source",
|
||||
* description="Source"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="idExtra",
|
||||
* type="string",
|
||||
* nullable=true,
|
||||
* default=null,
|
||||
* description="Extra id",
|
||||
* description="Extra id"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="criticalInstructions",
|
||||
* type="string",
|
||||
* nullable=true,
|
||||
* default=null,
|
||||
* description="Critical instructions",
|
||||
* description="Critical instructions"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="warningInstructions",
|
||||
* type="string",
|
||||
* nullable=true,
|
||||
* default=null,
|
||||
* description="Warning instructions",
|
||||
* description="Warning instructions"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="unknownInstructions",
|
||||
* type="string",
|
||||
* nullable=true,
|
||||
* default=null,
|
||||
* description="Unknows instructions",
|
||||
* description="Unknows instructions"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="ownerUser",
|
||||
* type="string",
|
||||
* nullable=true,
|
||||
* default=null,
|
||||
* description="Id user",
|
||||
* description="Id user"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="ackUtimestamp",
|
||||
|
@ -197,14 +197,14 @@ use PandoraFMS\Modules\Shared\Entities\Entity;
|
|||
* type="string",
|
||||
* nullable=true,
|
||||
* default=null,
|
||||
* description="Custom data",
|
||||
* description="Custom data"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="data",
|
||||
* type="string",
|
||||
* nullable=true,
|
||||
* default=null,
|
||||
* description="Data",
|
||||
* description="Data"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="moduleStatus",
|
||||
|
@ -212,13 +212,14 @@ use PandoraFMS\Modules\Shared\Entities\Entity;
|
|||
* nullable=true,
|
||||
* default=null,
|
||||
* description="Module status",
|
||||
* readonly=true
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="eventCustomId",
|
||||
* type="string",
|
||||
* nullable=true,
|
||||
* default=null,
|
||||
* description="Events Custom Id",
|
||||
* description="Events Custom Id"
|
||||
* )
|
||||
* )
|
||||
*
|
||||
|
@ -296,6 +297,7 @@ final class Event extends Entity
|
|||
'timestamp' => 1,
|
||||
'utimestamp' => 1,
|
||||
'ackUtimestamp' => 1,
|
||||
'moduleStatus' => 1,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ final class EventFilterValidation
|
|||
new Agent($idAgent);
|
||||
} catch (\Exception $e) {
|
||||
throw new BadRequestException(
|
||||
__('Invalid id agent, %s', $e->getMessage())
|
||||
__('Invalid id agent: %s, %s', $idAgent, $e->getMessage())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -163,29 +163,30 @@ final class EventFilterValidation
|
|||
protected function validateAgentModule(int $idAgentModule, ?int $idAgent = 0): void
|
||||
{
|
||||
// TODO: create new service for this.
|
||||
try {
|
||||
if(empty($idAgent) === false) {
|
||||
$agent = new Agent($idAgent);
|
||||
$existModule = $agent->searchModules(
|
||||
['id_agente_modulo' => $idAgentModule],
|
||||
1
|
||||
);
|
||||
|
||||
if (empty($existModule) === true) {
|
||||
throw new BadRequestException(
|
||||
__(
|
||||
'Id agent module not exist in agent %s',
|
||||
io_safe_output($agent->alias())
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
new Module($idAgentModule);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new BadRequestException(
|
||||
__('Invalid id agent module, %s', $e->getMessage())
|
||||
if(empty($idAgent) === false) {
|
||||
$agent = new Agent($idAgent);
|
||||
$existModule = $agent->searchModules(
|
||||
['id_agente_modulo' => $idAgentModule],
|
||||
1
|
||||
);
|
||||
|
||||
if (empty($existModule) === true) {
|
||||
throw new BadRequestException(
|
||||
__(
|
||||
'Id agent module: %s not exist in agent %s',
|
||||
$idAgentModule,
|
||||
io_safe_output($agent->alias())
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
new Module($idAgentModule);
|
||||
} catch (\Exception $e) {
|
||||
throw new BadRequestException(
|
||||
__('Invalid id agent module, %s', $e->getMessage())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,6 @@ final class EventValidation
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: readonly ??.
|
||||
if ($event->getModuleStatus() === null) {
|
||||
$event->setModuleStatus(0);
|
||||
}
|
||||
|
@ -121,7 +120,7 @@ final class EventValidation
|
|||
new Agent($idAgent);
|
||||
} catch (\Exception $e) {
|
||||
throw new BadRequestException(
|
||||
__('Invalid id agent, %s', $e->getMessage())
|
||||
__('Invalid id agent: %s, %s', $idAgent, $e->getMessage())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -129,35 +128,39 @@ final class EventValidation
|
|||
protected function validateAgentModule(int $idAgentModule, ?int $idAgent = 0): void
|
||||
{
|
||||
// TODO: create new service for this.
|
||||
try {
|
||||
if(empty($idAgent) === false) {
|
||||
$agent = new Agent($idAgent);
|
||||
$existModule = $agent->searchModules(
|
||||
['id_agente_modulo' => $idAgentModule],
|
||||
1
|
||||
);
|
||||
|
||||
if (empty($existModule) === true) {
|
||||
throw new BadRequestException(
|
||||
__(
|
||||
'Id agent module not exist in agent %s',
|
||||
io_safe_output($agent->alias())
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
new Module($idAgentModule);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new BadRequestException(
|
||||
__('Invalid id agent module, %s', $e->getMessage())
|
||||
if(empty($idAgent) === false) {
|
||||
$agent = new Agent($idAgent);
|
||||
$existModule = $agent->searchModules(
|
||||
['id_agente_modulo' => $idAgentModule],
|
||||
1
|
||||
);
|
||||
|
||||
if (empty($existModule) === true) {
|
||||
throw new BadRequestException(
|
||||
__(
|
||||
'Id agent module: %s not exist in agent %s',
|
||||
$idAgentModule,
|
||||
io_safe_output($agent->alias())
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
new Module($idAgentModule);
|
||||
} catch (\Exception $e) {
|
||||
throw new BadRequestException(
|
||||
__('Invalid id agent module, %s', $e->getMessage())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function validateAlert(int $idAlert): void
|
||||
{
|
||||
// TODO: create new service for this.
|
||||
if (! (bool) \alerts_get_alert_agent_module($idAlert)) {
|
||||
throw new BadRequestException(__('Invalid id Alert template'));
|
||||
}
|
||||
}
|
||||
|
||||
protected function getCurrentTimestamp(): string
|
||||
|
|
|
@ -26,8 +26,6 @@ final class CreateUserProfileService
|
|||
|
||||
$profile = $this->getProfileService->__invoke($userProfile->getIdprofile());
|
||||
|
||||
// TODO: Notificaciones.
|
||||
|
||||
$this->audit->write(
|
||||
AUDIT_LOG_USER_MANAGEMENT,
|
||||
'Added profile: '.$profile->getName().' for user: '.$userProfile->getIdUser(),
|
||||
|
|
Loading…
Reference in New Issue