new api 2.0

This commit is contained in:
daniel 2024-01-17 16:41:37 +01:00
parent 17edd73f35
commit 79a70ac588
57 changed files with 2302 additions and 336 deletions

View File

@ -4,4 +4,5 @@ use Slim\App;
return function (App $app) {
(include __DIR__.'/../../../include/lib/Modules/Users/routes.php')($app);
(include __DIR__.'/../../../include/lib/Modules/Profiles/routes.php')($app);
};

View File

@ -22,6 +22,218 @@
}
],
"paths": {
"/profile": {
"post": {
"tags": ["Profiles"],
"summary": "Creates a new profiles",
"operationId": "09c50bd77afb2856ee6625af0ee9c716",
"requestBody": {
"$ref": "#/components/requestBodies/requestBodyProfile"
},
"responses": {
"200": {
"$ref": "#/components/responses/ResponseProfile"
},
"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/{idProfile}": {
"get": {
"tags": ["Profiles"],
"summary": "Show profile",
"operationId": "e66704aa8cb757e23de04ce65c7bf028",
"parameters": [
{
"$ref": "#/components/parameters/parameterIdProfile"
}
],
"responses": {
"200": {
"$ref": "#/components/responses/ResponseProfile"
},
"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": []
}
]
},
"put": {
"tags": ["Profiles"],
"summary": "Updates an profile",
"operationId": "723fc236ab3b6069b7dcca9e317c953f",
"parameters": [
{
"$ref": "#/components/parameters/parameterIdProfile"
}
],
"requestBody": {
"$ref": "#/components/requestBodies/requestBodyProfile"
},
"responses": {
"200": {
"$ref": "#/components/responses/ResponseProfile"
},
"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": []
}
]
},
"delete": {
"tags": ["Profiles"],
"summary": "Deletes an profile object.",
"operationId": "ca8ec2d296930aac798229f83e93bff8",
"parameters": [
{
"$ref": "#/components/parameters/parameterIdProfile"
}
],
"responses": {
"200": {
"$ref": "#/components/responses/successfullyDeleted"
},
"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/list": {
"post": {
"tags": ["Profiles"],
"summary": "List profiles",
"operationId": "875c11ea1ec723d55e2f582ed198db7a",
"parameters": [
{
"$ref": "#/components/parameters/parameterPage"
},
{
"$ref": "#/components/parameters/parameterSizePage"
},
{
"$ref": "#/components/parameters/parameterSortField"
},
{
"$ref": "#/components/parameters/parameterSortDirection"
}
],
"requestBody": {
"$ref": "#/components/requestBodies/requestBodyProfileFilter"
},
"responses": {
"200": {
"description": "List Incidence object",
"content": {
"application/json": {
"schema": {
"properties": {
"paginationData": {
"$ref": "#/components/schemas/paginationData"
},
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Profile"
}
}
},
"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": []
}
]
}
},
"/user": {
"post": {
"tags": ["Users"],
@ -57,11 +269,11 @@
]
}
},
"/user/{id}": {
"/user/{idUser}": {
"get": {
"tags": ["Users"],
"summary": "show users",
"operationId": "8ebeb7e21b56d63f15d9b6341311a43d",
"operationId": "aca8667503b4f47013622baeea8ecee3",
"parameters": [
{
"$ref": "#/components/parameters/parameterIdUser"
@ -96,7 +308,7 @@
"put": {
"tags": ["Users"],
"summary": "Updates an user",
"operationId": "0d9890b106c7c16338fc9f5ff38a9401",
"operationId": "0a1f3fa99cb711d2ed1f47897d0e05f7",
"parameters": [
{
"$ref": "#/components/parameters/parameterIdUser"
@ -134,7 +346,7 @@
"delete": {
"tags": ["Users"],
"summary": "Deletes an user object.",
"operationId": "37abf8ed09f93f7739259528c626cc67",
"operationId": "ac81c40c168ebda19372ceb213a4d422",
"parameters": [
{
"$ref": "#/components/parameters/parameterIdUser"
@ -234,17 +446,17 @@
]
}
},
"/user/{id}/profile/{idProfile}": {
"/user/{idUser}/profile/{idProfile}": {
"get": {
"tags": ["Users"],
"summary": "show data field user profile",
"operationId": "fd19fade240728e3d8e152c6d76e63f7",
"operationId": "6aacb61062bd1ec04b91907273e2dd8f",
"parameters": [
{
"$ref": "#/components/parameters/parameterIdUser"
},
{
"$ref": "#/components/parameters/parameterProfileId"
"$ref": "#/components/parameters/parameterIdProfile"
}
],
"responses": {
@ -276,13 +488,13 @@
"post": {
"tags": ["Users"],
"summary": "Create user profile",
"operationId": "c30c48c85aed2f7e3e6c98f7785bd9ca",
"operationId": "9fe3300b6a0e031989b085cdba8def4d",
"parameters": [
{
"$ref": "#/components/parameters/parameterIdUser"
},
{
"$ref": "#/components/parameters/parameterProfileId"
"$ref": "#/components/parameters/parameterIdProfile"
}
],
"requestBody": {
@ -317,13 +529,13 @@
"delete": {
"tags": ["Users"],
"summary": "Deletes user profile.",
"operationId": "63a42b4afbd435bee10bd41bbbb95ccc",
"operationId": "4fc44af32440fc1b9feff41f92c63972",
"parameters": [
{
"$ref": "#/components/parameters/parameterIdUser"
},
{
"$ref": "#/components/parameters/parameterProfileId"
"$ref": "#/components/parameters/parameterIdProfile"
}
],
"responses": {
@ -353,11 +565,11 @@
]
}
},
"/user/{id}/profiles": {
"/user/{idUser}/profiles": {
"post": {
"tags": ["Users"],
"summary": "List user profiles",
"operationId": "1b8d60018091acae41f25a754b028de0",
"operationId": "3952d52c24c4fd099e9c0d15c7104068",
"parameters": [
{
"$ref": "#/components/parameters/parameterIdUser"
@ -426,6 +638,184 @@
},
"components": {
"schemas": {
"Profile": {
"properties": {
"idProfile": {
"description": "Id Incidence Type",
"type": "integer",
"readOnly": true,
"nullable": false
},
"name": {
"description": "Name of the profile",
"type": "string",
"default": null,
"nullable": false
},
"isAgentView": {
"description": "Agent Read",
"type": "boolean",
"default": false,
"nullable": true
},
"isAgentEdit": {
"description": "Agent Write",
"type": "boolean",
"default": false,
"nullable": true
},
"isAlertEdit": {
"description": "Alert write",
"type": "boolean",
"default": false,
"nullable": true
},
"isUserManagement": {
"description": "User Management",
"type": "boolean",
"default": false,
"nullable": true
},
"isDbManagement": {
"description": "Database Management",
"type": "boolean",
"default": false,
"nullable": true
},
"isAlertManagement": {
"description": "Alert Management",
"type": "boolean",
"default": false,
"nullable": true
},
"isPandoraManagement": {
"description": "Pandora Management",
"type": "boolean",
"default": false,
"nullable": true
},
"isReportView": {
"description": "Report view",
"type": "boolean",
"default": false,
"nullable": true
},
"isReportEdit": {
"description": "Report Edit",
"type": "boolean",
"default": false,
"nullable": true
},
"isReportManagement": {
"description": "Report Management",
"type": "boolean",
"default": false,
"nullable": true
},
"isEventView": {
"description": "Event Read",
"type": "boolean",
"default": false,
"nullable": true
},
"isEventEdit": {
"description": "Event write",
"type": "boolean",
"default": false,
"nullable": true
},
"isEventManagement": {
"description": "Event Management",
"type": "boolean",
"default": false,
"nullable": true
},
"isAgentDisable": {
"description": "Agent Disable",
"type": "boolean",
"default": false,
"nullable": true
},
"isMapView": {
"description": "Map Read",
"type": "boolean",
"default": false,
"nullable": true
},
"isMapEdit": {
"description": "Map Write",
"type": "boolean",
"default": false,
"nullable": true
},
"isMapManagement": {
"description": "Map Management",
"type": "boolean",
"default": false,
"nullable": true
},
"isVconsoleView": {
"description": "Visual console Read",
"type": "boolean",
"default": false,
"nullable": true
},
"isVconsoleEdit": {
"description": "Visual console Write",
"type": "boolean",
"default": false,
"nullable": true
},
"isVconsoleManagement": {
"description": "Visual console Management",
"type": "boolean",
"default": false,
"nullable": true
},
"isNetworkConfigView": {
"description": "Network config read",
"type": "boolean",
"default": false,
"nullable": true
},
"isNetworkConfigEdit": {
"description": "Network config Write",
"type": "boolean",
"default": false,
"nullable": true
},
"isNetworkConfigManagement": {
"description": "Network config Management",
"type": "boolean",
"default": false,
"nullable": true
}
},
"type": "object"
},
"ProfileFilter": {
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/Profile"
},
{
"properties": {
"idProfile": {
"default": null,
"readOnly": false
},
"freeSearch": {
"description": "Find word in name field.",
"type": "string",
"default": null,
"nullable": true
}
},
"type": "object"
}
]
},
"paginationData": {
"description": "Info pagination data",
"properties": {
@ -886,12 +1276,40 @@
"type": "integer",
"nullable": false
},
"isNoHierarchy": {
"description": "No hierarchy",
"type": "boolean",
"default": false,
"nullable": true
},
"assignedBy": {
"description": "Create user profile by",
"type": "string",
"default": null,
"readOnly": true,
"nullable": false
},
"idPolicy": {
"description": "Id Policy",
"type": "integer",
"nullable": false
},
"tags": {
"description": "Tags to which a user belongs",
"type": "array",
"items": {
"properties": {
"idTags": {
"description": "Tags id",
"type": "integer",
"default": null,
"nullable": true
}
},
"type": "object"
},
"default": null,
"nullable": true
}
},
"type": "object"
@ -915,6 +1333,16 @@
}
},
"responses": {
"ResponseProfile": {
"description": "Profile object",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Profile"
}
}
}
},
"BadRequest": {
"description": "Bad request",
"content": {
@ -1038,6 +1466,16 @@
}
},
"parameters": {
"parameterIdProfile": {
"name": "idProfile",
"in": "path",
"description": "Profile id",
"required": true,
"schema": {
"type": "integer",
"default": 1
}
},
"parameterPage": {
"name": "page",
"in": "query",
@ -1080,7 +1518,7 @@
}
},
"parameterIdUser": {
"name": "id",
"name": "idUser",
"in": "path",
"description": "User id",
"required": true,
@ -1089,10 +1527,10 @@
"default": "admin"
}
},
"parameterProfileId": {
"name": "idProfile",
"parameterIdUserProfile": {
"name": "idUserProfile",
"in": "path",
"description": "Profile id",
"description": "User profile id",
"required": true,
"schema": {
"type": "integer",
@ -1101,6 +1539,26 @@
}
},
"requestBodies": {
"requestBodyProfile": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Profile"
}
}
}
},
"requestBodyProfileFilter": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProfileFilter"
}
}
}
},
"requestBodyUser": {
"required": true,
"content": {
@ -1156,12 +1614,20 @@
{
"name": "Users",
"description": "API Endpoints of users"
},
{
"name": "Profiles",
"description": "API Endpoints of profiles"
}
],
"x-tagGroups": [
{
"name": "Users",
"tags": ["Users"]
},
{
"name": "Profiles",
"tags": ["Profiles"]
}
]
}

View File

@ -0,0 +1,19 @@
<?php
namespace PandoraFMS\Modules\Profiles\Actions;
use PandoraFMS\Modules\Profiles\Entities\Profile;
use PandoraFMS\Modules\Profiles\Services\CreateProfileService;
final class CreateProfileAction
{
public function __construct(
private CreateProfileService $createProfileService
) {
}
public function __invoke(Profile $profile): Profile
{
return $this->createProfileService->__invoke($profile);
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace PandoraFMS\Modules\Profiles\Actions;
use PandoraFMS\Modules\Profiles\Entities\Profile;
use PandoraFMS\Modules\Profiles\Services\DeleteProfileService;
final class DeleteProfileAction
{
public function __construct(
private DeleteProfileService $deleteProfileService
) {
}
public function __invoke(Profile $profile): void
{
$this->deleteProfileService->__invoke($profile);
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace PandoraFMS\Modules\Profiles\Actions;
use PandoraFMS\Modules\Profiles\Entities\Profile;
use PandoraFMS\Modules\Profiles\Services\GetProfileService;
final class GetProfileAction
{
public function __construct(
private GetProfileService $getProfileService
) {
}
public function __invoke(int $idProfile): Profile
{
return $this->getProfileService->__invoke($idProfile);
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace PandoraFMS\Modules\Profiles\Actions;
use PandoraFMS\Modules\Profiles\Entities\ProfileFilter;
use PandoraFMS\Modules\Profiles\Services\CountProfileService;
use PandoraFMS\Modules\Profiles\Services\ListProfileService;
use PandoraFMS\Modules\Shared\Entities\PaginationData;
final class ListProfileAction
{
public function __construct(
private ListProfileService $listProfileService,
private CountProfileService $countProfileService
) {
}
public function __invoke(ProfileFilter $profileFilter): array
{
return (new PaginationData(
$profileFilter->getPage(),
$profileFilter->getSizePage(),
$this->countProfileService->__invoke($profileFilter),
$this->listProfileService->__invoke($profileFilter)
))->toArray();
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace PandoraFMS\Modules\Profiles\Actions;
use PandoraFMS\Modules\Profiles\Entities\Profile;
use PandoraFMS\Modules\Profiles\Services\UpdateProfileService;
final class UpdateProfileAction
{
public function __construct(
private UpdateProfileService $updateProfileService
) {
}
public function __invoke(Profile $profile, Profile $oldProfile): Profile
{
return $this->updateProfileService->__invoke($profile, $oldProfile);
}
}

View File

@ -0,0 +1,47 @@
<?php
namespace PandoraFMS\Modules\Profiles\Controllers;
use PandoraFMS\Modules\Profiles\Actions\CreateProfileAction;
use PandoraFMS\Modules\Profiles\Entities\Profile;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
final class CreateProfileController extends Controller
{
public function __construct(
private CreateProfileAction $createProfileAction,
private ValidateAclSystem $acl,
) {
}
/**
* @OA\Post(
* security={{ "bearerAuth": {}}},
* tags={"Profiles"},
* path="/profile",
* summary="Creates a new profiles",
* @OA\RequestBody(ref="#/components/requestBodies/requestBodyProfile"),
* @OA\Response(response=200, ref="#/components/responses/ResponseProfile"),
* @OA\Response(response=400, ref="#/components/responses/BadRequest"),
* @OA\Response(response=401, ref="#/components/responses/Unauthorized"),
* @OA\Response(response=403, ref="#/components/responses/Forbidden"),
* @OA\Response(response=404, ref="#/components/responses/NotFound"),
* @OA\Response(response=500, ref="#/components/responses/InternalServerError")
* )
*/
public function __invoke(Request $request, Response $response): Response
{
// @var Profile $profile.
$profile = $this->fromRequest($request, Profile::class);
$this->acl->validate(0, 'UM', ' tried to manage profile');
$result = $this->createProfileAction->__invoke($profile);
return $this->getResponse($response, $result);
}
}

View File

@ -0,0 +1,47 @@
<?php
namespace PandoraFMS\Modules\Profiles\Controllers;
use PandoraFMS\Modules\Profiles\Actions\DeleteProfileAction;
use PandoraFMS\Modules\Profiles\Actions\GetProfileAction;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
final class DeleteProfileController extends Controller
{
public function __construct(
private DeleteProfileAction $deleteProfileAction,
private ValidateAclSystem $acl,
private GetProfileAction $getProfileAction
) {
}
/**
* @OA\Delete(
* security={{ "bearerAuth": {}}},
* tags={"Profiles"},
* path="/profile/{idProfile}",
* summary="Deletes an profile object.",
* @OA\Parameter(ref="#/components/parameters/parameterIdProfile"),
* @OA\Response(response=200, ref="#/components/responses/successfullyDeleted"),
* @OA\Response(response=400, ref="#/components/responses/BadRequest"),
* @OA\Response(response=401, ref="#/components/responses/Unauthorized"),
* @OA\Response(response=403, ref="#/components/responses/Forbidden"),
* @OA\Response(response=404, ref="#/components/responses/NotFound"),
* @OA\Response(response=500, ref="#/components/responses/InternalServerError")
* )
*/
public function __invoke(Request $request, Response $response): Response
{
$idProfile = $this->getParam($request, 'idProfile');
$profile = $this->getProfileAction->__invoke($idProfile);
$this->acl->validate(0, 'UM', ' tried to manage profile');
$result = $this->deleteProfileAction->__invoke($profile);
return $this->getResponse($response, $result);
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace PandoraFMS\Modules\Profiles\Controllers;
use PandoraFMS\Modules\Profiles\Actions\GetProfileAction;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
final class GetProfileController extends Controller
{
public function __construct(
private GetProfileAction $getProfileAction,
private ValidateAclSystem $acl
) {
}
/**
* @OA\Get(
* security={{ "bearerAuth": {}}},
* path="/profile/{idProfile}",
* tags={"Profiles"},
* summary="Show profile",
* @OA\Parameter(ref="#/components/parameters/parameterIdProfile"),
* @OA\Response(response=200, ref="#/components/responses/ResponseProfile"),
* @OA\Response(response=400, ref="#/components/responses/BadRequest"),
* @OA\Response(response=401, ref="#/components/responses/Unauthorized"),
* @OA\Response(response=403, ref="#/components/responses/Forbidden"),
* @OA\Response(response=404, ref="#/components/responses/NotFound"),
* @OA\Response(response=500, ref="#/components/responses/InternalServerError")
* )
*/
public function __invoke(Request $request, Response $response): Response
{
$idProfile = $this->getParam($request, 'idProfile');
$this->acl->validate(0, 'UM', ' tried to manage profile');
$result = $this->getProfileAction->__invoke($idProfile);
return $this->getResponse($response, $result);
}
}

View File

@ -0,0 +1,74 @@
<?php
namespace PandoraFMS\Modules\Profiles\Controllers;
use PandoraFMS\Modules\Profiles\Actions\ListProfileAction;
use PandoraFMS\Modules\Profiles\Entities\ProfileFilter;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
final class ListProfileController extends Controller
{
public function __construct(
private ListProfileAction $listProfileAction,
private ValidateAclSystem $acl,
) {
}
/**
* @OA\Post(
* security={{ "bearerAuth": {}}},
* tags={"Profiles"},
* path="/profile/list",
* summary="List profiles",
* @OA\Parameter(ref="#/components/parameters/parameterPage"),
* @OA\Parameter(ref="#/components/parameters/parameterSizePage"),
* @OA\Parameter(ref="#/components/parameters/parameterSortField"),
* @OA\Parameter(ref="#/components/parameters/parameterSortDirection"),
* @OA\RequestBody(ref="#/components/requestBodies/requestBodyProfileFilter"),
* @OA\Response(
* response="200",
* description="List Incidence object",
* content={
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(
* property="paginationData",
* type="object",
* ref="#/components/schemas/paginationData",
* description="Page object",
* ),
* @OA\Property(
* property="data",
* type="array",
* @OA\Items(
* ref="#/components/schemas/Profile",
* description="Array of incidences Type objects"
* )
* ),
* ),
* )
* }
* ),
* @OA\Response(response=400, ref="#/components/responses/BadRequest"),
* @OA\Response(response=401, ref="#/components/responses/Unauthorized"),
* @OA\Response(response=403, ref="#/components/responses/Forbidden"),
* @OA\Response(response=404, ref="#/components/responses/NotFound"),
* @OA\Response(response=500, ref="#/components/responses/InternalServerError")
* )
*/
public function __invoke(Request $request, Response $response): Response
{
// @var ProfileFilter $profileFilter.
$profileFilter = $this->fromRequest($request, ProfileFilter::class);
$this->acl->validate(0, 'UM', ' tried to manage profile');
$result = $this->listProfileAction->__invoke($profileFilter);
return $this->getResponse($response, $result);
}
}

View File

@ -0,0 +1,52 @@
<?php
namespace PandoraFMS\Modules\Profiles\Controllers;
use PandoraFMS\Modules\Profiles\Actions\GetProfileAction;
use PandoraFMS\Modules\Profiles\Actions\UpdateProfileAction;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
/**
* @OA\Put(
* security={{ "bearerAuth": {}}},
* path="/profile/{idProfile}",
* tags={"Profiles"},
* summary="Updates an profile",
* @OA\Parameter(ref="#/components/parameters/parameterIdProfile"),
* @OA\RequestBody(ref="#/components/requestBodies/requestBodyProfile"),
* @OA\Response(response=200, ref="#/components/responses/ResponseProfile"),
* @OA\Response(response=400, ref="#/components/responses/BadRequest"),
* @OA\Response(response=401, ref="#/components/responses/Unauthorized"),
* @OA\Response(response=403, ref="#/components/responses/Forbidden"),
* @OA\Response(response=404, ref="#/components/responses/NotFound"),
* @OA\Response(response=500, ref="#/components/responses/InternalServerError")
* )
*/
final class UpdateProfileController extends Controller
{
public function __construct(
private UpdateProfileAction $updateProfileAction,
private ValidateAclSystem $acl,
private GetProfileAction $getProfileAction
) {
}
public function __invoke(Request $request, Response $response): Response
{
$idProfile = $this->getParam($request, 'idProfile');
$profile = $this->getProfileAction->__invoke($idProfile);
$oldProfile = clone $profile;
$params = $this->extractParams($request);
$profile->fromArray($params);
$this->acl->validate(0, 'UM', ' tried to manage profile');
$result = $this->updateProfileAction->__invoke($profile, $oldProfile);
return $this->getResponse($response, $result);
}
}

View File

@ -0,0 +1,581 @@
<?php
namespace PandoraFMS\Modules\Profiles\Entities;
use PandoraFMS\Modules\Shared\Entities\Entity;
use PandoraFMS\Modules\Shared\Validators\Validator;
/**
* @OA\Schema(
* schema="Profile",
* type="object",
* @OA\Property(
* property="idProfile",
* type="integer",
* nullable=false,
* description="Id Incidence Type",
* readOnly=true
* ),
* @OA\Property(
* property="name",
* type="string",
* nullable=false,
* default=null,
* description="Name of the profile"
* ),
* @OA\Property(
* property="isAgentView",
* type="boolean",
* nullable=true,
* default=false,
* description="Agent Read"
* ),
* @OA\Property(
* property="isAgentEdit",
* type="boolean",
* nullable=true,
* default=false,
* description="Agent Write"
* ),
* @OA\Property(
* property="isAlertEdit",
* type="boolean",
* nullable=true,
* default=false,
* description="Alert write"
* ),
* @OA\Property(
* property="isUserManagement",
* type="boolean",
* nullable=true,
* default=false,
* description="User Management"
* ),
* @OA\Property(
* property="isDbManagement",
* type="boolean",
* nullable=true,
* default=false,
* description="Database Management"
* ),
* @OA\Property(
* property="isAlertManagement",
* type="boolean",
* nullable=true,
* default=false,
* description="Alert Management"
* ),
* @OA\Property(
* property="isPandoraManagement",
* type="boolean",
* nullable=true,
* default=false,
* description="Pandora Management"
* ),
* @OA\Property(
* property="isReportView",
* type="boolean",
* nullable=true,
* default=false,
* description="Report view"
* ),
* @OA\Property(
* property="isReportEdit",
* type="boolean",
* nullable=true,
* default=false,
* description="Report Edit"
* ),
* @OA\Property(
* property="isReportManagement",
* type="boolean",
* nullable=true,
* default=false,
* description="Report Management"
* ),
* @OA\Property(
* property="isEventView",
* type="boolean",
* nullable=true,
* default=false,
* description="Event Read"
* ),
* @OA\Property(
* property="isEventEdit",
* type="boolean",
* nullable=true,
* default=false,
* description="Event write"
* ),
* @OA\Property(
* property="isEventManagement",
* type="boolean",
* nullable=true,
* default=false,
* description="Event Management"
* ),
* @OA\Property(
* property="isAgentDisable",
* type="boolean",
* nullable=true,
* default=false,
* description="Agent Disable"
* ),
* @OA\Property(
* property="isMapView",
* type="boolean",
* nullable=true,
* default=false,
* description="Map Read"
* ),
* @OA\Property(
* property="isMapEdit",
* type="boolean",
* nullable=true,
* default=false,
* description="Map Write"
* ),
* @OA\Property(
* property="isMapManagement",
* type="boolean",
* nullable=true,
* default=false,
* description="Map Management"
* ),
* @OA\Property(
* property="isVconsoleView",
* type="boolean",
* nullable=true,
* default=false,
* description="Visual console Read"
* ),
* @OA\Property(
* property="isVconsoleEdit",
* type="boolean",
* nullable=true,
* default=false,
* description="Visual console Write"
* ),
* @OA\Property(
* property="isVconsoleManagement",
* type="boolean",
* nullable=true,
* default=false,
* description="Visual console Management"
* ),
* @OA\Property(
* property="isNetworkConfigView",
* type="boolean",
* nullable=true,
* default=false,
* description="Network config read"
* ),
* @OA\Property(
* property="isNetworkConfigEdit",
* type="boolean",
* nullable=true,
* default=false,
* description="Network config Write"
* ),
* @OA\Property(
* property="isNetworkConfigManagement",
* type="boolean",
* nullable=true,
* default=false,
* description="Network config Management"
* )
* )
*
* @OA\Response(
* response="ResponseProfile",
* description="Profile object",
* content={
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* type="object",
* ref="#/components/schemas/Profile",
* description="Profile object"
* ),
* )
* }
* )
*
* @OA\Parameter(
* parameter="parameterIdProfile",
* name="idProfile",
* in="path",
* description="Profile id",
* required=true,
* @OA\Schema(
* type="integer",
* default=1
* ),
* )
*
* @OA\RequestBody(
* request="requestBodyProfile",
* required=true,
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(ref="#/components/schemas/Profile")
* ),
* )
*/
final class Profile extends Entity
{
private ?int $idProfile = null;
private ?string $name = null;
private ?bool $isAgentView = null;
private ?bool $isAgentEdit = null;
private ?bool $isAlertEdit = null;
private ?bool $isUserManagement = null;
private ?bool $isDbManagement = null;
private ?bool $isAlertManagement = null;
private ?bool $isPandoraManagement = null;
private ?bool $isReportView = null;
private ?bool $isReportEdit = null;
private ?bool $isReportManagement = null;
private ?bool $isEventView = null;
private ?bool $isEventEdit = null;
private ?bool $isEventManagement = null;
private ?bool $isAgentDisable = null;
private ?bool $isMapView = null;
private ?bool $isMapEdit = null;
private ?bool $isMapManagement = null;
private ?bool $isVconsoleView = null;
private ?bool $isVconsoleEdit = null;
private ?bool $isVconsoleManagement = null;
private ?bool $isNetworkConfigView = null;
private ?bool $isNetworkConfigEdit = null;
private ?bool $isNetworkConfigManagement = null;
public function __construct()
{
}
public function fieldsReadOnly(): array
{
return ['idProfile' => 1];
}
public function jsonSerialize(): mixed
{
return [
'idProfile' => $this->getIdProfile(),
'name' => $this->getName(),
'isAgentView' => $this->getIsAgentView(),
'isAgentEdit' => $this->getIsAgentEdit(),
'isAlertEdit' => $this->getIsAlertEdit(),
'isUserManagement' => $this->getIsUserManagement(),
'isDbManagement' => $this->getIsDbManagement(),
'isAlertManagement' => $this->getIsAlertManagement(),
'isPandoraManagement' => $this->getIsPandoraManagement(),
'isReportView' => $this->getIsReportView(),
'isReportEdit' => $this->getIsReportEdit(),
'isReportManagement' => $this->getIsReportManagement(),
'isEventView' => $this->getIsEventView(),
'isEventEdit' => $this->getIsEventEdit(),
'isEventManagement' => $this->getIsEventManagement(),
'isAgentDisable' => $this->getIsAgentDisable(),
'isMapView' => $this->getIsMapView(),
'isMapEdit' => $this->getIsMapEdit(),
'isMapManagement' => $this->getIsMapManagement(),
'isVconsoleView' => $this->getIsVconsoleView(),
'isVconsoleEdit' => $this->getIsVconsoleEdit(),
'isVconsoleManagement' => $this->getIsVconsoleManagement(),
'isNetworkConfigView' => $this->getIsNetworkConfigView(),
'isNetworkConfigEdit' => $this->getIsNetworkConfigEdit(),
'isNetworkConfigManagement' => $this->getIsNetworkConfigManagement(),
];
}
public function getValidations(): array
{
return [
'idProfile' => [
Validator::INTEGER,
Validator::GREATERTHAN,
],
'name' => Validator::STRING,
'isAgentView' => Validator::BOOLEAN,
'isAgentEdit' => Validator::BOOLEAN,
'isAlertEdit' => Validator::BOOLEAN,
'isUserManagement' => Validator::BOOLEAN,
'isDbManagement' => Validator::BOOLEAN,
'isAlertManagement' => Validator::BOOLEAN,
'isPandoraManagement' => Validator::BOOLEAN,
'isReportView' => Validator::BOOLEAN,
'isReportEdit' => Validator::BOOLEAN,
'isReportManagement' => Validator::BOOLEAN,
'isEventView' => Validator::BOOLEAN,
'isEventEdit' => Validator::BOOLEAN,
'isEventManagement' => Validator::BOOLEAN,
'isAgentDisable' => Validator::BOOLEAN,
'isMapView' => Validator::BOOLEAN,
'isMapEdit' => Validator::BOOLEAN,
'isMapManagement' => Validator::BOOLEAN,
'isVconsoleView' => Validator::BOOLEAN,
'isVconsoleEdit' => Validator::BOOLEAN,
'isVconsoleManagement' => Validator::BOOLEAN,
'isNetworkConfigView' => Validator::BOOLEAN,
'isNetworkConfigEdit' => Validator::BOOLEAN,
'isNetworkConfigManagement' => Validator::BOOLEAN,
];
}
public function validateFields(array $filters): array
{
return (new Validator())->validate($filters);
}
public function getIdProfile(): ?int
{
return $this->idProfile;
}
public function setIdProfile(?int $idProfile): self
{
$this->idProfile = $idProfile;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getIsAgentView(): ?bool
{
return $this->isAgentView;
}
public function setIsAgentView(?bool $isAgentView): self
{
$this->isAgentView = $isAgentView;
return $this;
}
public function getIsAgentEdit(): ?bool
{
return $this->isAgentEdit;
}
public function setIsAgentEdit(?bool $isAgentEdit): self
{
$this->isAgentEdit = $isAgentEdit;
return $this;
}
public function getIsAlertEdit(): ?bool
{
return $this->isAlertEdit;
}
public function setIsAlertEdit(?bool $isAlertEdit): self
{
$this->isAlertEdit = $isAlertEdit;
return $this;
}
public function getIsUserManagement(): ?bool
{
return $this->isUserManagement;
}
public function setIsUserManagement(?bool $isUserManagement): self
{
$this->isUserManagement = $isUserManagement;
return $this;
}
public function getIsDbManagement(): ?bool
{
return $this->isDbManagement;
}
public function setIsDbManagement(?bool $isDbManagement): self
{
$this->isDbManagement = $isDbManagement;
return $this;
}
public function getIsAlertManagement(): ?bool
{
return $this->isAlertManagement;
}
public function setIsAlertManagement(?bool $isAlertManagement): self
{
$this->isAlertManagement = $isAlertManagement;
return $this;
}
public function getIsPandoraManagement(): ?bool
{
return $this->isPandoraManagement;
}
public function setIsPandoraManagement(?bool $isPandoraManagement): self
{
$this->isPandoraManagement = $isPandoraManagement;
return $this;
}
public function getIsReportView(): ?bool
{
return $this->isReportView;
}
public function setIsReportView(?bool $isReportView): self
{
$this->isReportView = $isReportView;
return $this;
}
public function getIsReportEdit(): ?bool
{
return $this->isReportEdit;
}
public function setIsReportEdit(?bool $isReportEdit): self
{
$this->isReportEdit = $isReportEdit;
return $this;
}
public function getIsReportManagement(): ?bool
{
return $this->isReportManagement;
}
public function setIsReportManagement(?bool $isReportManagement): self
{
$this->isReportManagement = $isReportManagement;
return $this;
}
public function getIsEventView(): ?bool
{
return $this->isEventView;
}
public function setIsEventView(?bool $isEventView): self
{
$this->isEventView = $isEventView;
return $this;
}
public function getIsEventEdit(): ?bool
{
return $this->isEventEdit;
}
public function setIsEventEdit(?bool $isEventEdit): self
{
$this->isEventEdit = $isEventEdit;
return $this;
}
public function getIsEventManagement(): ?bool
{
return $this->isEventManagement;
}
public function setIsEventManagement(?bool $isEventManagement): self
{
$this->isEventManagement = $isEventManagement;
return $this;
}
public function getIsAgentDisable(): ?bool
{
return $this->isAgentDisable;
}
public function setIsAgentDisable(?bool $isAgentDisable): self
{
$this->isAgentDisable = $isAgentDisable;
return $this;
}
public function getIsMapView(): ?bool
{
return $this->isMapView;
}
public function setIsMapView(?bool $isMapView): self
{
$this->isMapView = $isMapView;
return $this;
}
public function getIsMapEdit(): ?bool
{
return $this->isMapEdit;
}
public function setIsMapEdit(?bool $isMapEdit): self
{
$this->isMapEdit = $isMapEdit;
return $this;
}
public function getIsMapManagement(): ?bool
{
return $this->isMapManagement;
}
public function setIsMapManagement(?bool $isMapManagement): self
{
$this->isMapManagement = $isMapManagement;
return $this;
}
public function getIsVconsoleView(): ?bool
{
return $this->isVconsoleView;
}
public function setIsVconsoleView(?bool $isVconsoleView): self
{
$this->isVconsoleView = $isVconsoleView;
return $this;
}
public function getIsVconsoleEdit(): ?bool
{
return $this->isVconsoleEdit;
}
public function setIsVconsoleEdit(?bool $isVconsoleEdit): self
{
$this->isVconsoleEdit = $isVconsoleEdit;
return $this;
}
public function getIsVconsoleManagement(): ?bool
{
return $this->isVconsoleManagement;
}
public function setIsVconsoleManagement(?bool $isVconsoleManagement): self
{
$this->isVconsoleManagement = $isVconsoleManagement;
return $this;
}
public function getIsNetworkConfigView(): ?bool
{
return $this->isNetworkConfigView;
}
public function setIsNetworkConfigView(?bool $isNetworkConfigView): self
{
$this->isNetworkConfigView = $isNetworkConfigView;
return $this;
}
public function getIsNetworkConfigEdit(): ?bool
{
return $this->isNetworkConfigEdit;
}
public function setIsNetworkConfigEdit(?bool $isNetworkConfigEdit): self
{
$this->isNetworkConfigEdit = $isNetworkConfigEdit;
return $this;
}
public function getIsNetworkConfigManagement(): ?bool
{
return $this->isNetworkConfigManagement;
}
public function setIsNetworkConfigManagement(?bool $isNetworkConfigManagement): self
{
$this->isNetworkConfigManagement = $isNetworkConfigManagement;
return $this;
}
}

View File

@ -0,0 +1,116 @@
<?php
namespace PandoraFMS\Modules\Profiles\Entities;
use PandoraFMS\Modules\Shared\Builders\Builder;
use PandoraFMS\Modules\Shared\Core\DataMapperAbstract;
use PandoraFMS\Modules\Shared\Core\MappeableInterface;
use PandoraFMS\Modules\Shared\Repositories\Repository;
final class ProfileDataMapper extends DataMapperAbstract
{
public const TABLE_NAME = 'tperfil';
public const ID_PROFILE = 'id_perfil';
public const NAME = 'name';
public const IS_AGENT_VIEW = 'agent_view';
public const IS_AGENT_EDIT = 'agent_edit';
public const IS_ALERT_EDIT = 'alert_edit';
public const IS_USER_MANAGEMENT = 'user_management';
public const IS_DB_MANAGEMENT = 'db_management';
public const IS_ALERT_MANAGEMENT = 'alert_management';
public const IS_PANDORA_MANAGEMENT = 'pandora_management';
public const IS_REPORT_VIEW = 'report_view';
public const IS_REPORT_EDIT = 'report_edit';
public const IS_REPORT_MANAGEMENT = 'report_management';
public const IS_EVENT_VIEW = 'event_view';
public const IS_EVENT_EDIT = 'event_edit';
public const IS_EVENT_MANAGEMENT = 'event_management';
public const IS_AGENT_DISABLE = 'agent_disable';
public const IS_MAP_VIEW = 'map_view';
public const IS_MAP_EDIT = 'map_edit';
public const IS_MAP_MANAGEMENT = 'map_management';
public const IS_VCONSOLE_VIEW = 'vconsole_view';
public const IS_VCONSOLE_EDIT = 'vconsole_edit';
public const IS_VCONSOLE_MANAGEMENT = 'vconsole_management';
public const IS_NETWORK_CONFIG_VIEW = 'network_config_view';
public const IS_NETWORK_CONFIG_EDIT = 'network_config_edit';
public const IS_NETWORK_CONFIG_MANAGEMENT = 'network_config_management';
public function __construct(
private Repository $repository,
private Builder $builder,
) {
parent::__construct(
self::TABLE_NAME,
self::ID_PROFILE,
);
}
public function getClassName(): string
{
return Profile::class;
}
public function fromDatabase(array $data): Profile
{
return $this->builder->build(new Profile(), [
'idProfile' => $data[self::ID_PROFILE],
'name' => $this->repository->safeOutput($data[self::NAME]),
'isAgentView' => $data[self::IS_AGENT_VIEW],
'isAgentEdit' => $data[self::IS_AGENT_EDIT],
'isAlertEdit' => $data[self::IS_ALERT_EDIT],
'isUserManagement' => $data[self::IS_USER_MANAGEMENT],
'isDbManagement' => $data[self::IS_DB_MANAGEMENT],
'isAlertManagement' => $data[self::IS_ALERT_MANAGEMENT],
'isPandoraManagement' => $data[self::IS_PANDORA_MANAGEMENT],
'isReportView' => $data[self::IS_REPORT_VIEW],
'isReportEdit' => $data[self::IS_REPORT_EDIT],
'isReportManagement' => $data[self::IS_REPORT_MANAGEMENT],
'isEventView' => $data[self::IS_EVENT_VIEW],
'isEventEdit' => $data[self::IS_EVENT_EDIT],
'isEventManagement' => $data[self::IS_EVENT_MANAGEMENT],
'isAgentDisable' => $data[self::IS_AGENT_DISABLE],
'isMapView' => $data[self::IS_MAP_VIEW],
'isMapEdit' => $data[self::IS_MAP_EDIT],
'isMapManagement' => $data[self::IS_MAP_MANAGEMENT],
'isVconsoleView' => $data[self::IS_VCONSOLE_VIEW],
'isVconsoleEdit' => $data[self::IS_VCONSOLE_EDIT],
'isVconsoleManagement' => $data[self::IS_VCONSOLE_MANAGEMENT],
'isNetworkConfigView' => $data[self::IS_NETWORK_CONFIG_VIEW],
'isNetworkConfigEdit' => $data[self::IS_NETWORK_CONFIG_EDIT],
'isNetworkConfigManagement' => $data[self::IS_NETWORK_CONFIG_MANAGEMENT],
]);
}
public function toDatabase(MappeableInterface $data): array
{
/** @var Profile $data */
return [
self::ID_PROFILE => $data->getIdProfile(),
self::NAME => $this->repository->safeInput($data->getName()),
self::IS_AGENT_VIEW => $data->getIsAgentView(),
self::IS_AGENT_EDIT => $data->getIsAgentEdit(),
self::IS_ALERT_EDIT => $data->getIsAlertEdit(),
self::IS_USER_MANAGEMENT => $data->getIsUserManagement(),
self::IS_DB_MANAGEMENT => $data->getIsDbManagement(),
self::IS_ALERT_MANAGEMENT => $data->getIsAlertManagement(),
self::IS_PANDORA_MANAGEMENT => $data->getIsPandoraManagement(),
self::IS_REPORT_VIEW => $data->getIsReportView(),
self::IS_REPORT_EDIT => $data->getIsReportEdit(),
self::IS_REPORT_MANAGEMENT => $data->getIsReportManagement(),
self::IS_EVENT_VIEW => $data->getIsEventView(),
self::IS_EVENT_EDIT => $data->getIsEventEdit(),
self::IS_EVENT_MANAGEMENT => $data->getIsEventManagement(),
self::IS_AGENT_DISABLE => $data->getIsAgentDisable(),
self::IS_MAP_VIEW => $data->getIsMapView(),
self::IS_MAP_EDIT => $data->getIsMapEdit(),
self::IS_MAP_MANAGEMENT => $data->getIsMapManagement(),
self::IS_VCONSOLE_VIEW => $data->getIsVconsoleView(),
self::IS_VCONSOLE_EDIT => $data->getIsVconsoleEdit(),
self::IS_VCONSOLE_MANAGEMENT => $data->getIsVconsoleManagement(),
self::IS_NETWORK_CONFIG_VIEW => $data->getIsNetworkConfigView(),
self::IS_NETWORK_CONFIG_EDIT => $data->getIsNetworkConfigEdit(),
self::IS_NETWORK_CONFIG_MANAGEMENT => $data->getIsNetworkConfigManagement(),
];
}
}

View File

@ -0,0 +1,118 @@
<?php
namespace PandoraFMS\Modules\Profiles\Entities;
use PandoraFMS\Modules\Shared\Core\FilterAbstract;
use PandoraFMS\Modules\Shared\Validators\Validator;
/**
* @OA\Schema(
* schema="ProfileFilter",
* type="object",
* allOf={
* @OA\Schema(ref="#/components/schemas/Profile"),
* @OA\Schema(
* @OA\Property(
* property="idProfile",
* default=null,
* readOnly=false
* ),
* @OA\Property(
* property="freeSearch",
* type="string",
* nullable=true,
* default=null,
* description="Find word in name field."
* )
* )
* }
* )
*
* @OA\RequestBody(
* request="requestBodyProfileFilter",
* required=true,
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(ref="#/components/schemas/ProfileFilter")
* ),
* )
*/
final class ProfileFilter extends FilterAbstract
{
private ?string $freeSearch = null;
public function __construct()
{
$this->setDefaultFieldOrder(ProfileDataMapper::NAME);
$this->setDefaultDirectionOrder($this::ASC);
$this->setEntityFilter(new Profile());
}
public function fieldsTranslate(): array
{
return [
'idProfile' => ProfileDataMapper::ID_PROFILE,
'name' => ProfileDataMapper::NAME,
];
}
public function fieldsReadOnly(): array
{
return [];
}
public function jsonSerialize(): mixed
{
return [
'freeSearch' => $this->getFreeSearch(),
];
}
public function getValidations(): array
{
$validations = [];
if($this->getEntityFilter() !== null) {
$validations = $this->getEntityFilter()->getValidations();
}
$validations['freeSearch'] = Validator::STRING;
return $validations;
}
public function validateFields(array $filters): array
{
return (new Validator())->validate($filters);
}
/**
* Get the value of freeSearch.
*
* @return ?string
*/
public function getFreeSearch(): ?string
{
return $this->freeSearch;
}
/**
* Set the value of freeSearch.
*
* @param ?string $freeSearch
*
*/
public function setFreeSearch(?string $freeSearch): self
{
$this->freeSearch = $freeSearch;
return $this;
}
/**
* Get the value of fieldsFreeSearch.
*
* @return ?array
*/
public function getFieldsFreeSearch(): ?array
{
return [ProfileDataMapper::NAME];
}
}

View File

@ -0,0 +1,65 @@
<?php
namespace PandoraFMS\Modules\Profiles\Repositories;
use PandoraFMS\Modules\Profiles\Entities\Profile;
use PandoraFMS\Modules\Profiles\Entities\ProfileDataMapper;
use PandoraFMS\Modules\Profiles\Entities\ProfileFilter;
use PandoraFMS\Modules\Shared\Repositories\Repository;
class ProfileRepository
{
public function __construct(
private Repository $repository,
private ProfileDataMapper $profileDataMapper
) {
}
/**
* @return Profile[],
*/
public function list(ProfileFilter $profileFilter): array
{
return $this->repository->__list(
$profileFilter,
$this->profileDataMapper
);
}
public function count(ProfileFilter $profileFilter): int
{
return $this->repository->__count(
$profileFilter,
$this->profileDataMapper
);
}
public function getOne(ProfileFilter $profileFilter): Profile
{
return $this->repository->__getOne(
$profileFilter,
$this->profileDataMapper
);
}
public function create(Profile $profile): Profile
{
$id = $this->repository->__create($profile, $this->profileDataMapper);
return $profile->setIdProfile($id);
}
public function update(Profile $profile): Profile
{
return $this->repository->__update(
$profile,
$this->profileDataMapper,
$profile->getIdProfile()
);
}
public function delete(int $id): void
{
$this->repository->__delete($id, $this->profileDataMapper);
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace PandoraFMS\Modules\Profiles\Services;
use PandoraFMS\Modules\Profiles\Entities\ProfileFilter;
use PandoraFMS\Modules\Profiles\Repositories\ProfileRepository;
final class CountProfileService
{
public function __construct(
private ProfileRepository $profileRepository,
) {
}
public function __invoke(ProfileFilter $profileFilter): int
{
return $this->profileRepository->count($profileFilter);
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace PandoraFMS\Modules\Profiles\Services;
use PandoraFMS\Modules\Profiles\Entities\Profile;
use PandoraFMS\Modules\Profiles\Repositories\ProfileRepository;
use PandoraFMS\Modules\Profiles\Validations\ProfileValidation;
use PandoraFMS\Modules\Shared\Services\Audit;
final class CreateProfileService
{
public function __construct(
private Audit $audit,
private ProfileRepository $profileRepository,
private ProfileValidation $profileValidation
) {
}
public function __invoke(Profile $profile): Profile
{
$this->profileValidation->__invoke($profile);
$profile = $this->profileRepository->create($profile);
$this->audit->write(
AUDIT_LOG_USER_MANAGEMENT,
'Create profile '.$profile->getName(),
json_encode($profile->toArray())
);
return $profile;
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace PandoraFMS\Modules\Profiles\Services;
use PandoraFMS\Modules\Profiles\Entities\Profile;
use PandoraFMS\Modules\Profiles\Repositories\ProfileRepository;
use PandoraFMS\Modules\Shared\Services\Audit;
final class DeleteProfileService
{
public function __construct(
private Audit $audit,
private ProfileRepository $profileRepository,
) {
}
public function __invoke(Profile $profile): void
{
$idProfile = $profile->getIdProfile();
$nameProfile = $profile->getName();
$this->profileRepository->delete($idProfile);
$this->audit->write(
AUDIT_LOG_USER_MANAGEMENT,
'Deleted profile '.$nameProfile
);
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace PandoraFMS\Modules\Profiles\Services;
use PandoraFMS\Modules\Profiles\Entities\Profile;
use PandoraFMS\Modules\Profiles\Entities\ProfileFilter;
use PandoraFMS\Modules\Profiles\Repositories\ProfileRepository;
use PandoraFMS\Modules\Shared\Exceptions\NotFoundException;
final class ExistNameProfileService
{
public function __construct(
private ProfileRepository $profileRepository,
) {
}
public function __invoke(string $name): bool
{
$profileFilter = new ProfileFilter();
/** @var Profile $entityFilter */
$entityFilter = $profileFilter->getEntityFilter();
$entityFilter->setName($name);
try {
$this->profileRepository->getOne($profileFilter);
return true;
} catch (NotFoundException) {
return false;
}
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace PandoraFMS\Modules\Profiles\Services;
use PandoraFMS\Modules\Profiles\Entities\Profile;
use PandoraFMS\Modules\Profiles\Entities\ProfileFilter;
use PandoraFMS\Modules\Profiles\Repositories\ProfileRepository;
final class GetProfileService
{
public function __construct(
private ProfileRepository $profileRepository,
) {
}
public function __invoke(int $idProfile): Profile
{
$profileFilter = new ProfileFilter();
/** @var Profile $entityFilter */
$entityFilter = $profileFilter->getEntityFilter();
$entityFilter->setIdProfile($idProfile);
return $this->profileRepository->getOne($profileFilter);
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace PandoraFMS\Modules\Profiles\Services;
use PandoraFMS\Modules\Profiles\Entities\ProfileFilter;
use PandoraFMS\Modules\Profiles\Repositories\ProfileRepository;
final class ListProfileService
{
public function __construct(
private ProfileRepository $profileRepository,
) {
}
public function __invoke(ProfileFilter $profileFilter): array
{
return $this->profileRepository->list($profileFilter);
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace PandoraFMS\Modules\Profiles\Services;
use PandoraFMS\Modules\Profiles\Entities\Profile;
use PandoraFMS\Modules\Profiles\Repositories\ProfileRepository;
use PandoraFMS\Modules\Profiles\Validations\ProfileValidation;
use PandoraFMS\Modules\Shared\Services\Audit;
final class UpdateProfileService
{
public function __construct(
private Audit $audit,
private ProfileRepository $profileRepository,
private ProfileValidation $profileValidation
) {
}
public function __invoke(Profile $profile, Profile $oldProfile): Profile
{
$this->profileValidation->__invoke($profile, $oldProfile);
$profile = $this->profileRepository->update($profile);
$this->audit->write(
AUDIT_LOG_USER_MANAGEMENT,
'Update profile '.$profile->getName(),
json_encode($profile->toArray())
);
return $profile;
}
}

View File

@ -0,0 +1,122 @@
<?php
namespace PandoraFMS\Modules\Profiles\Validations;
use PandoraFMS\Modules\Profiles\Entities\Profile;
use PandoraFMS\Modules\Profiles\Services\ExistNameProfileService;
use PandoraFMS\Modules\Shared\Exceptions\BadRequestException;
final class ProfileValidation
{
public function __construct(
private ExistNameProfileService $existNameProfileService
) {
}
public function __invoke(Profile $profile, ?Profile $oldProfile = null): void
{
if (!$profile->getName()) {
throw new BadRequestException(__('Name is missing'));
}
if($oldProfile === null || $oldProfile->getName() !== $profile->getName()) {
if($this->existNameProfileService->__invoke($profile->getName()) === true) {
throw new BadRequestException(
__('Name %s is already exists', $profile->getName())
);
}
}
if($profile->getIsAgentView() === null) {
$profile->setIsAgentView(false);
}
if($profile->getIsAgentEdit() === null) {
$profile->setIsAgentEdit(false);
}
if($profile->getIsAlertEdit() === null) {
$profile->setIsAlertEdit(false);
}
if($profile->getIsUserManagement() === null) {
$profile->setIsUserManagement(false);
}
if($profile->getIsDbManagement() === null) {
$profile->setIsDbManagement(false);
}
if($profile->getIsAlertManagement() === null) {
$profile->setIsAlertManagement(false);
}
if($profile->getIsPandoraManagement() === null) {
$profile->setIsPandoraManagement(false);
}
if($profile->getIsReportView() === null) {
$profile->setIsReportView(false);
}
if($profile->getIsReportEdit() === null) {
$profile->setIsReportEdit(false);
}
if($profile->getIsReportManagement() === null) {
$profile->setIsReportManagement(false);
}
if($profile->getIsEventView() === null) {
$profile->setIsEventView(false);
}
if($profile->getIsEventEdit() === null) {
$profile->setIsEventEdit(false);
}
if($profile->getIsEventManagement() === null) {
$profile->setIsEventManagement(false);
}
if($profile->getIsAgentDisable() === null) {
$profile->setIsAgentDisable(false);
}
if($profile->getIsMapView() === null) {
$profile->setIsMapView(false);
}
if($profile->getIsMapEdit() === null) {
$profile->setIsMapEdit(false);
}
if($profile->getIsMapManagement() === null) {
$profile->setIsMapManagement(false);
}
if($profile->getIsVconsoleView() === null) {
$profile->setIsVconsoleView(false);
}
if($profile->getIsVconsoleEdit() === null) {
$profile->setIsVconsoleEdit(false);
}
if($profile->getIsVconsoleManagement() === null) {
$profile->setIsVconsoleManagement(false);
}
if($profile->getIsNetworkConfigView() === null) {
$profile->setIsNetworkConfigView(false);
}
if($profile->getIsNetworkConfigEdit() === null) {
$profile->setIsNetworkConfigEdit(false);
}
if($profile->getIsNetworkConfigManagement() === null) {
$profile->setIsNetworkConfigManagement(false);
}
}
}

View File

@ -0,0 +1,16 @@
<?php
use PandoraFMS\Modules\Profiles\Controllers\CreateProfileController;
use PandoraFMS\Modules\Profiles\Controllers\DeleteProfileController;
use PandoraFMS\Modules\Profiles\Controllers\GetProfileController;
use PandoraFMS\Modules\Profiles\Controllers\ListProfileController;
use PandoraFMS\Modules\Profiles\Controllers\UpdateProfileController;
use Slim\App;
return function (App $app) {
$app->map(['GET', 'POST'], '/profile/list', ListProfileController::class);
$app->get('/profile/{idProfile}', GetProfileController::class);
$app->post('/profile', CreateProfileController::class);
$app->put('/profile/{idProfile}', UpdateProfileController::class);
$app->delete('/profile/{idProfile}', DeleteProfileController::class);
};

View File

@ -82,7 +82,9 @@ abstract class DataMapperAbstract
public function getStringNameClass(): string
{
$strname = [
'PandoraFMS\\Modules\\Users\\Entities\\User' => 'User',
'PandoraFMS\\Modules\\Users\\Entities\\User' => 'User',
'PandoraFMS\\Modules\\Users\\Entities\\Profile' => 'Profile',
'PandoraFMS\\Modules\\Users\\UserProfiles\\Entities\\UserProfile' => 'UserProfile',
];
$result = ($strname[$this->getClassName()] ?? '');

View File

@ -39,6 +39,10 @@ use OpenApi\Annotations as OA;
* name="Users",
* description="API Endpoints of users"
* ),
* @OA\Tag(
* name="Profiles",
* description="API Endpoints of profiles"
* ),
* @OA\OpenApi(
* x={
* "tagGroups"= {
@ -46,6 +50,10 @@ use OpenApi\Annotations as OA;
* "name"="Users",
* "tags"={"Users"}
* },
* {
* "name"="Profiles",
* "tags"={"Profiles"}
* },
* }
* }
* ),

View File

@ -23,7 +23,7 @@ final class DeleteUserController extends Controller
* @OA\Delete(
* security={{ "bearerAuth": {}}},
* tags={"Users"},
* path="/user/{id}",
* path="/user/{idUser}",
* summary="Deletes an user object.",
* @OA\Parameter(ref="#/components/parameters/parameterIdUser"),
* @OA\Response(response=200, ref="#/components/responses/successfullyDeleted"),
@ -36,7 +36,7 @@ final class DeleteUserController extends Controller
*/
public function __invoke(Request $request, Response $response): Response
{
$idUser = $this->getParam($request, 'id');
$idUser = $this->getParam($request, 'idUser');
$user = $this->getUserAction->__invoke($idUser);
$this->acl->validate(0, 'UM', ' tried to manage user');

View File

@ -20,7 +20,7 @@ final class GetUserController extends Controller
/**
* @OA\Get(
* security={{ "bearerAuth": {}}},
* path="/user/{id}",
* path="/user/{idUser}",
* tags={"Users"},
* summary="show users",
* @OA\Parameter(ref="#/components/parameters/parameterIdUser"),
@ -34,7 +34,7 @@ final class GetUserController extends Controller
*/
public function __invoke(Request $request, Response $response): Response
{
$idUser = $this->getParam($request, 'id');
$idUser = $this->getParam($request, 'idUser');
$result = $this->getUserAction->__invoke($idUser);
return $this->getResponse($response, $result);
}

View File

@ -13,7 +13,7 @@ use Psr\Http\Message\ServerRequestInterface as Request;
/**
* @OA\Put(
* security={{ "bearerAuth": {}}},
* path="/user/{id}",
* path="/user/{idUser}",
* tags={"Users"},
* summary="Updates an user",
* @OA\Parameter(ref="#/components/parameters/parameterIdUser"),
@ -37,7 +37,7 @@ final class UpdateUserController extends Controller
public function __invoke(Request $request, Response $response): Response
{
$idUser = $this->getParam($request, 'id');
$idUser = $this->getParam($request, 'idUser');
$user = $this->getUserAction->__invoke($idUser);
$oldUser = clone $user;

View File

@ -454,7 +454,7 @@ use PandoraFMS\Modules\Users\Validators\UserValidator;
*
* @OA\Parameter(
* parameter="parameterIdUser",
* name="id",
* name="idUser",
* in="path",
* description="User id",
* required=true,

View File

@ -66,7 +66,6 @@ final class UserDataMapper extends DataMapperAbstract
public const AUTH_TOKEN_SECRET = 'auth_token_secret';
public const SESSION_MAX_TIME_EXPIRE = 'session_max_time_expire';
public function __construct(
private Repository $repository,
private Builder $builder,
@ -77,13 +76,11 @@ final class UserDataMapper extends DataMapperAbstract
);
}
public function getClassName(): string
{
return User::class;
}
public function fromDatabase(array $data): User
{
return $this->builder->build(
@ -128,7 +125,7 @@ final class UserDataMapper extends DataMapperAbstract
'defaultEventFilter' => $data[self::DEFAULT_EVENT_FILTER],
'metaconsoleDefaultEventFilter' => $data[self::METACONSOLE_DEFAULT_EVENT_FILTER],
'showTipsStartup' => $data[self::SHOW_TIPS_STARTUP],
'autorefreshWhiteList' => ($data[self::AUTOREFRESH_WHITE_LIST] !== null) ? json_decode($this->repository->safeOutput($data[self::AUTOREFRESH_WHITE_LIST])) : null,
'autorefreshWhiteList' => (empty($data[self::AUTOREFRESH_WHITE_LIST]) === false) ? json_decode($this->repository->safeOutput($data[self::AUTOREFRESH_WHITE_LIST])) : null,
'timeAutorefresh' => $data[self::TIME_AUTOREFRESH],
'defaultCustomView' => $data[self::DEFAULT_CUSTOM_VIEW],
'ehorusUserLevelUser' => $this->repository->safeOutput($data[self::EHORUS_USER_LEVEL_USER]),
@ -190,7 +187,7 @@ final class UserDataMapper extends DataMapperAbstract
self::DEFAULT_EVENT_FILTER => $data->getDefaultEventFilter(),
self::METACONSOLE_DEFAULT_EVENT_FILTER => $data->getMetaconsoleDefaultEventFilter(),
self::SHOW_TIPS_STARTUP => $data->getShowTipsStartup(),
self::AUTOREFRESH_WHITE_LIST => ($data->getAutorefreshWhiteList() !== null) ? $this->repository->safeInput(json_encode($data->getAutorefreshWhiteList())) : null,
self::AUTOREFRESH_WHITE_LIST => (empty($data->getAutorefreshWhiteList()) === false) ? $this->repository->safeInput(json_encode($data->getAutorefreshWhiteList())) : null,
self::TIME_AUTOREFRESH => $data->getTimeAutorefresh(),
self::DEFAULT_CUSTOM_VIEW => $data->getDefaultCustomView(),
self::EHORUS_USER_LEVEL_USER => $this->repository->safeInput($data->getEhorusUserLevelUser()),
@ -205,6 +202,4 @@ final class UserDataMapper extends DataMapperAbstract
self::SESSION_MAX_TIME_EXPIRE => $data->getSessionMaxTimeExpire(),
];
}
}

View File

@ -22,5 +22,4 @@ enum UserAutoRefreshPagesEnum: string
case DASHBOARD = 'operation/dashboard/dashboard';
case VISUAL_CONSOLE = 'operation/visual_console/render_view';
case EVENTS = 'operation/events/events';
}

View File

@ -17,5 +17,4 @@ enum UserHomeScreenEnum: string
case EXTERNAL_LINK = 'external_link';
case OTHER = 'other';
case DASHBOARD = 'dashboard';
}

View File

@ -20,9 +20,7 @@ final class CheckOldPasswordUserService
public function __invoke(User $user): void
{
$userFilter = new UserFilter();
/**
@var User $entityFilter
*/
/** @var User $entityFilter */
$entityFilter = $userFilter->getEntityFilter();
$entityFilter->setIdUser($user->getIdUser());
$entityFilter->setPassword($user->getOldPassword());

View File

@ -17,9 +17,7 @@ final class GetUserService
{
$userFilter = new UserFilter();
/**
@var User $entityFilter
*/
/** @var User $entityFilter */
$entityFilter = $userFilter->getEntityFilter();
$entityFilter->setIdUser($idUser);

View File

@ -23,8 +23,7 @@ final class ValidatePasswordUserService
);
}
// Si es una actualizacion, revisas el o los antiguos paswords,
// que no se pueda repetir.
// Si es una actualizacion, revisas el o los antiguos paswords, que no se pueda repetir.
if ($oldUser !== null) {
$newPass = password_hash($user->getPassword(), PASSWORD_BCRYPT);
if ((bool) $this->config->get('enable_pass_history') === true) {

View File

@ -7,18 +7,13 @@ use PandoraFMS\Modules\Users\UserProfiles\Services\CreateUserProfileService;
final class CreateUserProfileAction
{
public function __construct(
private CreateUserProfileService $createUserProfileService
) {
}
public function __invoke(UserProfile $userProfile): UserProfile
{
return $this->createUserProfileService->__invoke($userProfile);
}
}

View File

@ -7,18 +7,13 @@ use PandoraFMS\Modules\Users\UserProfiles\Services\DeleteUserProfileService;
final class DeleteUserProfileAction
{
public function __construct(
private DeleteUserProfileService $deleteService
) {
}
public function __invoke(UserProfile $userProfile): void
{
$this->deleteService->__invoke($userProfile);
}
}

View File

@ -7,18 +7,13 @@ use PandoraFMS\Modules\Users\UserProfiles\Services\GetUserProfileService;
final class GetUserProfileAction
{
public function __construct(
private GetUserProfileService $getUserProfileService
) {
}
public function __invoke(string $idUser, int $idProfile): UserProfile
{
return $this->getUserProfileService->__invoke($idUser, $idProfile);
}
}

View File

@ -2,22 +2,19 @@
namespace PandoraFMS\Modules\Users\UserProfiles\Actions;
use PandoraFMS\Modules\Shared\Entities\PaginationData;
use PandoraFMS\Modules\Users\UserProfiles\Entities\UserProfileFilter;
use PandoraFMS\Modules\Users\UserProfiles\Services\CountUserProfileService;
use PandoraFMS\Modules\Users\UserProfiles\Services\ListUserProfileService;
use PandoraFMS\Modules\Shared\Entities\PaginationData;
final class ListUserProfileAction
{
public function __construct(
private ListUserProfileService $listUserProfileService,
private CountUserProfileService $countUserProfileService
) {
}
public function __invoke(UserProfileFilter $userProfileFilter): array
{
return (new PaginationData(
@ -27,6 +24,4 @@ final class ListUserProfileAction
$this->listUserProfileService->__invoke($userProfileFilter)
))->toArray();
}
}

View File

@ -2,19 +2,18 @@
namespace PandoraFMS\Modules\Users\UserProfiles\Controllers;
use PandoraFMS\Modules\Users\UserProfiles\Actions\CreateUserProfileAction;
use PandoraFMS\Modules\Users\UserProfiles\Entities\UserProfile;
use PandoraFMS\Modules\Profiles\Actions\GetProfileAction;
use PandoraFMS\Modules\Shared\Controllers\Controller;
use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use PandoraFMS\Modules\Users\Actions\GetUserAction;
use PandoraFMS\Modules\Users\UserProfiles\Actions\CreateUserProfileAction;
use PandoraFMS\Modules\Users\UserProfiles\Entities\UserProfile;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
final class CreateUserProfileController extends Controller
{
public function __construct(
private CreateUserProfileAction $createUserProfileAction,
private ValidateAclSystem $acl,
@ -23,33 +22,32 @@ final class CreateUserProfileController extends Controller
) {
}
/**
* @OA\Post(
* security={{ "bearerAuth": {}}},
* tags={"Users"},
* path="/user/{id}/profile/{idProfile}",
* path="/user/{idUser}/profile/{idProfile}",
* summary="Create user profile",
* @OA\Parameter(ref="#/components/parameters/parameterIdUser"),
* @OA\Parameter(ref="#/components/parameters/parameterProfileId"),
* @OA\RequestBody(ref="#/components/requestBodies/requestBodyUserProfile"),
* @OA\Response(response=200, ref="#/components/responses/ResponseUserProfile"),
* @OA\Response(response=400, ref="#/components/responses/BadRequest"),
* @OA\Response(response=401, ref="#/components/responses/Unauthorized"),
* @OA\Response(response=403, ref="#/components/responses/Forbidden"),
* @OA\Response(response=404, ref="#/components/responses/NotFound"),
* @OA\Response(response=500, ref="#/components/responses/InternalServerError")
* @OA\Parameter(ref="#/components/parameters/parameterIdUser"),
* @OA\Parameter(ref="#/components/parameters/parameterIdProfile"),
* @OA\RequestBody(ref="#/components/requestBodies/requestBodyUserProfile"),
* @OA\Response(response=200, ref="#/components/responses/ResponseUserProfile"),
* @OA\Response(response=400, ref="#/components/responses/BadRequest"),
* @OA\Response(response=401, ref="#/components/responses/Unauthorized"),
* @OA\Response(response=403, ref="#/components/responses/Forbidden"),
* @OA\Response(response=404, ref="#/components/responses/NotFound"),
* @OA\Response(response=500, ref="#/components/responses/InternalServerError")
* )
*/
public function __invoke(Request $request, Response $response): Response
{
$idUser = $this->getParam($request, 'id');
$user = $this->getUserAction->__invoke($idUser);
$idUser = $this->getParam($request, 'idUser');
$this->getUserAction->__invoke($idUser);
$this->acl->validate(0, 'UM', ' tried to manage user');
$idProfile = $this->getParam($request, 'idProfile');
$profile = $this->getProfileAction->__invoke($idProfile);
$this->getProfileAction->__invoke($idProfile);
// @var UserProfile $userProfile.
$userProfile = $this->fromRequest($request, UserProfile::class);
@ -59,6 +57,4 @@ final class CreateUserProfileController extends Controller
$result = $this->createUserProfileAction->__invoke($userProfile);
return $this->getResponse($response, $result);
}
}

View File

@ -8,13 +8,12 @@ use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use PandoraFMS\Modules\Users\Actions\GetUserAction;
use PandoraFMS\Modules\Users\UserProfiles\Actions\DeleteUserProfileAction;
use PandoraFMS\Modules\Users\UserProfiles\Actions\GetUserProfileAction;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
final class DeleteUserProfileController extends Controller
{
public function __construct(
private DeleteUserProfileAction $deleteUserProfileAction,
private ValidateAclSystem $acl,
@ -24,26 +23,25 @@ final class DeleteUserProfileController extends Controller
) {
}
/**
* @OA\Delete(
* security={{ "bearerAuth": {}}},
* tags={"Users"},
* path="/user/{id}/profile/{idProfile}",
* path="/user/{idUser}/profile/{idProfile}",
* summary="Deletes user profile.",
* @OA\Parameter(ref="#/components/parameters/parameterIdUser"),
* @OA\Parameter(ref="#/components/parameters/parameterProfileId"),
* @OA\Response(response=200, ref="#/components/responses/successfullyDeleted"),
* @OA\Response(response=400, ref="#/components/responses/BadRequest"),
* @OA\Response(response=401, ref="#/components/responses/Unauthorized"),
* @OA\Response(response=403, ref="#/components/responses/Forbidden"),
* @OA\Response(response=404, ref="#/components/responses/NotFound"),
* @OA\Response(response=500, ref="#/components/responses/InternalServerError")
* @OA\Parameter(ref="#/components/parameters/parameterIdUser"),
* @OA\Parameter(ref="#/components/parameters/parameterIdProfile"),
* @OA\Response(response=200, ref="#/components/responses/successfullyDeleted"),
* @OA\Response(response=400, ref="#/components/responses/BadRequest"),
* @OA\Response(response=401, ref="#/components/responses/Unauthorized"),
* @OA\Response(response=403, ref="#/components/responses/Forbidden"),
* @OA\Response(response=404, ref="#/components/responses/NotFound"),
* @OA\Response(response=500, ref="#/components/responses/InternalServerError")
* )
*/
public function __invoke(Request $request, Response $response): Response
{
$idUser = $this->getParam($request, 'id');
$idUser = $this->getParam($request, 'idUser');
$user = $this->getUserAction->__invoke($idUser);
$idProfile = $this->getParam($request, 'idProfile');
@ -53,6 +51,4 @@ final class DeleteUserProfileController extends Controller
$result = $this->deleteUserProfileAction->__invoke($userProfile);
return $this->getResponse($response, $result);
}
}

View File

@ -13,8 +13,6 @@ use Psr\Http\Message\ServerRequestInterface as Request;
final class GetUserProfileController extends Controller
{
public function __construct(
private GetUserProfileAction $getUserProfileAction,
private GetUserAction $getUserAction,
@ -23,26 +21,25 @@ final class GetUserProfileController extends Controller
) {
}
/**
* @OA\Get(
* security={{ "bearerAuth": {}}},
* path="/user/{id}/profile/{idProfile}",
* path="/user/{idUser}/profile/{idProfile}",
* tags={"Users"},
* summary="show data field user profile",
* @OA\Parameter(ref="#/components/parameters/parameterIdUser"),
* @OA\Parameter(ref="#/components/parameters/parameterProfileId"),
* @OA\Response(response=200, ref="#/components/responses/ResponseUserProfile"),
* @OA\Response(response=400, ref="#/components/responses/BadRequest"),
* @OA\Response(response=401, ref="#/components/responses/Unauthorized"),
* @OA\Response(response=403, ref="#/components/responses/Forbidden"),
* @OA\Response(response=404, ref="#/components/responses/NotFound"),
* @OA\Response(response=500, ref="#/components/responses/InternalServerError")
* @OA\Parameter(ref="#/components/parameters/parameterIdUser"),
* @OA\Parameter(ref="#/components/parameters/parameterIdProfile"),
* @OA\Response(response=200, ref="#/components/responses/ResponseUserProfile"),
* @OA\Response(response=400, ref="#/components/responses/BadRequest"),
* @OA\Response(response=401, ref="#/components/responses/Unauthorized"),
* @OA\Response(response=403, ref="#/components/responses/Forbidden"),
* @OA\Response(response=404, ref="#/components/responses/NotFound"),
* @OA\Response(response=500, ref="#/components/responses/InternalServerError")
* )
*/
public function __invoke(Request $request, Response $response): Response
{
$idUser = $this->getParam($request, 'id');
$idUser = $this->getParam($request, 'idUser');
$user = $this->getUserAction->__invoke($idUser);
$idProfile = $this->getParam($request, 'idProfile');
@ -51,6 +48,4 @@ final class GetUserProfileController extends Controller
$result = $this->getUserProfileAction->__invoke($idUser, $idProfile);
return $this->getResponse($response, $result);
}
}

View File

@ -7,13 +7,12 @@ use PandoraFMS\Modules\Shared\Services\ValidateAclSystem;
use PandoraFMS\Modules\Users\Actions\GetUserAction;
use PandoraFMS\Modules\Users\UserProfiles\Actions\ListUserProfileAction;
use PandoraFMS\Modules\Users\UserProfiles\Entities\UserProfileFilter;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
final class ListUserProfileController extends Controller
{
public function __construct(
private ListUserProfileAction $listUserProfileAction,
private GetUserAction $getUserAction,
@ -21,55 +20,54 @@ final class ListUserProfileController extends Controller
) {
}
/**
* @OA\Post(
* security={{ "bearerAuth": {}}},
* tags={"Users"},
* path="/user/{id}/profiles",
* path="/user/{idUser}/profiles",
* summary="List user profiles",
* @OA\Parameter(ref="#/components/parameters/parameterIdUser"),
* @OA\Parameter(ref="#/components/parameters/parameterPage"),
* @OA\Parameter(ref="#/components/parameters/parameterSizePage"),
* @OA\Parameter(ref="#/components/parameters/parameterSortField"),
* @OA\Parameter(ref="#/components/parameters/parameterSortDirection"),
* @OA\RequestBody(ref="#/components/requestBodies/requestBodyUserProfile"),
* @OA\Response(
* response="200",
* description="List data profiles user object",
* content={
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(
* property="paginationData",
* type="object",
* ref="#/components/schemas/paginationData",
* description="Page object",
* @OA\Parameter(ref="#/components/parameters/parameterIdUser"),
* @OA\Parameter(ref="#/components/parameters/parameterPage"),
* @OA\Parameter(ref="#/components/parameters/parameterSizePage"),
* @OA\Parameter(ref="#/components/parameters/parameterSortField"),
* @OA\Parameter(ref="#/components/parameters/parameterSortDirection"),
* @OA\RequestBody(ref="#/components/requestBodies/requestBodyUserProfile"),
* @OA\Response(
* response="200",
* description="List data profiles user object",
* content={
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(
* property="paginationData",
* type="object",
* ref="#/components/schemas/paginationData",
* description="Page object",
* ),
* @OA\Property(
* property="data",
* type="array",
* @OA\Items(
* ref="#/components/schemas/UserProfile",
* description="Array of profiles"
* )
* ),
* ),
* @OA\Property(
* property="data",
* type="array",
* @OA\Items(
* ref="#/components/schemas/UserProfile",
* description="Array of profiles"
* )
* ),
* ),
* )
* }
* ),
* @OA\Response(response=400, ref="#/components/responses/BadRequest"),
* @OA\Response(response=401, ref="#/components/responses/Unauthorized"),
* @OA\Response(response=403, ref="#/components/responses/Forbidden"),
* @OA\Response(response=404, ref="#/components/responses/NotFound"),
* @OA\Response(response=500, ref="#/components/responses/InternalServerError")
* )
* }
* ),
* @OA\Response(response=400, ref="#/components/responses/BadRequest"),
* @OA\Response(response=401, ref="#/components/responses/Unauthorized"),
* @OA\Response(response=403, ref="#/components/responses/Forbidden"),
* @OA\Response(response=404, ref="#/components/responses/NotFound"),
* @OA\Response(response=500, ref="#/components/responses/InternalServerError")
* )
*/
public function __invoke(Request $request, Response $response): Response
{
$idUser = $this->getParam($request, 'id');
$user = $this->getUserAction->__invoke($idUser);
$idUser = $this->getParam($request, 'idUser');
$this->getUserAction->__invoke($idUser);
// @var UserProfileFilter $userProfileFilter.
$userProfileFilter = $this->fromRequest($request, UserProfileFilter::class);
@ -78,6 +76,4 @@ final class ListUserProfileController extends Controller
$result = $this->listUserProfileAction->__invoke($userProfileFilter);
return $this->getResponse($response, $result);
}
}

View File

@ -37,13 +37,42 @@ use PandoraFMS\Modules\Shared\Validators\Validator;
* description="Id Group"
* ),
* @OA\Property(
* property="isNoHierarchy",
* type="boolean",
* nullable=true,
* default=false,
* description="No hierarchy"
* ),
* @OA\Property(
* property="assignedBy",
* type="string",
* nullable=false,
* default=null,
* readOnly=true,
* description="Create user profile by"
* )
* ),
* @OA\Property(
* property="idPolicy",
* type="integer",
* nullable=false,
* description="Id Policy"
* ),
* @OA\Property(
* property="tags",
* type="array",
* nullable=true,
* default=null,
* description="Tags to which a user belongs",
* @OA\Items(
* @OA\Property(
* property="idTags",
* type="integer",
* nullable=true,
* default=null,
* description="Tags id",
* )
* )
* ),
* )
*
* @OA\Response(
@ -62,10 +91,10 @@ use PandoraFMS\Modules\Shared\Validators\Validator;
* )
*
* @OA\Parameter(
* parameter="parameterProfileId",
* name="idProfile",
* parameter="parameterIdUserProfile",
* name="idUserProfile",
* in="path",
* description="Profile id",
* description="User profile id",
* required=true,
* @OA\Schema(
* type="integer",
@ -84,29 +113,24 @@ use PandoraFMS\Modules\Shared\Validators\Validator;
*/
final class UserProfile extends Entity
{
private ?int $idUserProfile = null;
private ?string $idUser = null;
private ?int $idProfile = null;
private ?int $idGroup = null;
private ?bool $isNoHierarchy = null;
private ?string $assignedBy = null;
private ?int $idPolicy = null;
private ?array $tags = null;
public function __construct()
{
}
public function fieldsReadOnly(): array
{
return ['idUserProfile' => 1];
}
public function jsonSerialize(): mixed
{
return [
@ -114,11 +138,13 @@ final class UserProfile extends Entity
'idUser' => $this->getIdUser(),
'idProfile' => $this->getIdProfile(),
'idGroup' => $this->getIdGroup(),
'isNoHierarchy' => $this->getIsNoHierarchy(),
'assignedBy' => $this->getAssignedBy(),
'idPolicy' => $this->getIdPolicy(),
'tags' => $this->getTags(),
];
}
public function getValidations(): array
{
return [
@ -126,42 +152,34 @@ final class UserProfile extends Entity
Validator::INTEGER,
Validator::GREATEREQUALTHAN,
],
'idUser' => Validator::STRING,
'idProfile' => [
'idUser' => Validator::STRING,
'idProfile' => [
Validator::INTEGER,
Validator::GREATEREQUALTHAN,
],
'idGroup' => [
'idGroup' => [
Validator::INTEGER,
Validator::GREATEREQUALTHAN,
],
'isNoHierarchy' => Validator::BOOLEAN,
'assignedBy' => Validator::STRING,
'idPolicy' => [
Validator::INTEGER,
Validator::GREATEREQUALTHAN,
],
'tags' => Validator::ARRAY,
];
}
public function validateFields(array $filters): array
{
return (new Validator())->validate($filters);
}
/**
* Get the value of idUserProfile.
*
* @return ?int
*/
public function getIdUserProfile(): ?int
{
return $this->idUserProfile;
}
/**
* Set the value of idUserProfile.
*
* @param integer $idUserProfile
*/
public function setIdUserProfile(?int $idUserProfile): self
{
$this->idUserProfile = $idUserProfile;
@ -169,23 +187,10 @@ final class UserProfile extends Entity
return $this;
}
/**
* Get the value of idUser.
*
* @return ?string
*/
public function getIdUser(): ?string
{
return $this->idUser;
}
/**
* Set the value of idUser.
*
* @param string $idUser
*/
public function setIdUser(?string $idUser): self
{
$this->idUser = $idUser;
@ -193,23 +198,10 @@ final class UserProfile extends Entity
return $this;
}
/**
* Get the value of idProfile.
*
* @return ?int
*/
public function getIdProfile(): ?int
{
return $this->idProfile;
}
/**
* Set the value of idProfile.
*
* @param integer $idProfile
*/
public function setIdProfile(?int $idProfile): self
{
$this->idProfile = $idProfile;
@ -217,23 +209,10 @@ final class UserProfile extends Entity
return $this;
}
/**
* Get the value of idGroup.
*
* @return ?int
*/
public function getIdGroup(): ?int
{
return $this->idGroup;
}
/**
* Set the value of idGroup.
*
* @param integer $idGroup
*/
public function setIdGroup(?int $idGroup): self
{
$this->idGroup = $idGroup;
@ -241,23 +220,10 @@ final class UserProfile extends Entity
return $this;
}
/**
* Get the value of assignedBy.
*
* @return ?string
*/
public function getAssignedBy(): ?string
{
return $this->assignedBy;
}
/**
* Set the value of assignedBy.
*
* @param string $assignedBy
*/
public function setAssignedBy(?string $assignedBy): self
{
$this->assignedBy = $assignedBy;
@ -265,5 +231,38 @@ final class UserProfile extends Entity
return $this;
}
public function getIsNoHierarchy(): ?bool
{
return $this->isNoHierarchy;
}
public function setIsNoHierarchy(?bool $isNoHierarchy): self
{
$this->isNoHierarchy = $isNoHierarchy;
return $this;
}
public function getIdPolicy(): ?int
{
return $this->idPolicy;
}
public function setIdPolicy(?int $idPolicy): self
{
$this->idPolicy = $idPolicy;
return $this;
}
public function getTags(): ?array
{
return $this->tags;
}
public function setTags(array|string|null $tags): self
{
if (is_string($tags) === true) {
$tags = json_decode($tags);
}
$this->tags = $tags;
return $this;
}
}

View File

@ -14,8 +14,10 @@ final class UserProfileDataMapper extends DataMapperAbstract
public const ID_USER = 'id_usuario';
public const ID_PROFILE = 'id_perfil';
public const ID_GROUP = 'id_grupo';
public const IS_NO_HIERARCHY = 'no_hierarchy';
public const ASSIGNED_BY = 'assigned_by';
public const ID_POLICY = 'id_policy';
public const TAGS = 'tags';
public function __construct(
private Repository $repository,
@ -27,13 +29,11 @@ final class UserProfileDataMapper extends DataMapperAbstract
);
}
public function getClassName(): string
{
return UserProfile::class;
}
public function fromDatabase(array $data): UserProfile
{
return $this->builder->build(
@ -43,25 +43,26 @@ final class UserProfileDataMapper extends DataMapperAbstract
'idUser' => $data[self::ID_USER],
'idProfile' => $data[self::ID_PROFILE],
'idGroup' => $data[self::ID_GROUP],
'isNoHierarchy' => $data[self::IS_NO_HIERARCHY],
'assignedBy' => $data[self::ASSIGNED_BY],
'idPolicy' => $data[self::ID_POLICY],
'tags' => (empty($data[self::TAGS]) === false) ? explode(',', $data[self::TAGS]) : null,
]
);
}
public function toDatabase(MappeableInterface $data): array
{
/*
@var UserProfile $data
*/
/** @var UserProfile $data */
return [
self::ID_USER_PROFILE => $data->getIdUserProfile(),
self::ID_USER => $data->getIdUser(),
self::ID_PROFILE => $data->getIdProfile(),
self::ID_GROUP => $data->getIdGroup(),
self::IS_NO_HIERARCHY => $data->getIsNoHierarchy(),
self::ASSIGNED_BY => $data->getAssignedBy(),
self::ID_POLICY => $data->getIdPolicy(),
self::TAGS => (empty($data->getTags()) === false) ? implode(',', $data->getTags()) : null,
];
}
}

View File

@ -32,8 +32,6 @@ use PandoraFMS\Modules\Shared\Validators\Validator;
*/
final class UserProfileFilter extends FilterAbstract
{
public function __construct()
{
$this->setDefaultFieldOrder(UserProfileDataMapper::ID_USER_PROFILE);
@ -41,7 +39,6 @@ final class UserProfileFilter extends FilterAbstract
$this->setEntityFilter(new UserProfile());
}
public function fieldsTranslate(): array
{
return [
@ -49,19 +46,16 @@ final class UserProfileFilter extends FilterAbstract
];
}
public function fieldsReadOnly(): array
{
return [];
}
public function jsonSerialize(): mixed
{
return [];
}
public function getValidations(): array
{
$validations = [];
@ -72,11 +66,8 @@ final class UserProfileFilter extends FilterAbstract
return $validations;
}
public function validateFields(array $filters): array
{
return (new Validator())->validate($filters);
}
}

View File

@ -2,26 +2,21 @@
namespace PandoraFMS\Modules\Users\UserProfiles\Repositories;
use PandoraFMS\Modules\Shared\Exceptions\BadRequestException;
use PandoraFMS\Modules\Shared\Repositories\Repository;
use PandoraFMS\Modules\Users\UserProfiles\Entities\UserProfile;
use PandoraFMS\Modules\Users\UserProfiles\Entities\UserProfileDataMapper;
use PandoraFMS\Modules\Users\UserProfiles\Entities\UserProfileFilter;
use PandoraFMS\Modules\Shared\Exceptions\BadRequestException;
use PandoraFMS\Modules\Shared\Repositories\Repository;
class UserProfileRepository
{
public function __construct(
private Repository $repository,
private UserProfileDataMapper $userProfileDataMapper
) {
}
/**
* @return UserProfile[],
*/
/** @return UserProfile[] */
public function list(UserProfileFilter $userProfileFilter): array
{
return $this->repository->__list(
@ -30,7 +25,6 @@ class UserProfileRepository
);
}
public function count(UserProfileFilter $userProfileFilter): int
{
return $this->repository->__count(
@ -39,7 +33,6 @@ class UserProfileRepository
);
}
public function getOne(UserProfileFilter $userProfileFilter): UserProfile
{
return $this->repository->__getOne(
@ -48,7 +41,6 @@ class UserProfileRepository
);
}
public function create(UserProfile $userProfile): UserProfile
{
try {
@ -59,7 +51,6 @@ class UserProfileRepository
}
}
public function update(UserProfile $userProfile): UserProfile
{
return $this->repository->__update(
@ -69,11 +60,8 @@ class UserProfileRepository
);
}
public function delete(int $id, ?string $key=null): void
public function delete(int $id, ?string $key = null): void
{
$this->repository->__delete($id, $this->userProfileDataMapper, $key);
}
}

View File

@ -7,18 +7,13 @@ use PandoraFMS\Modules\Users\UserProfiles\Repositories\UserProfileRepository;
final class CountUserProfileService
{
public function __construct(
private UserProfileRepository $userProfileRepository,
) {
}
public function __invoke(UserProfileFilter $userProfileFilter): int
{
return $this->userProfileRepository->count($userProfileFilter);
}
}

View File

@ -2,16 +2,13 @@
namespace PandoraFMS\Modules\Users\UserProfiles\Services;
use PandoraFMS\Modules\Shared\Services\Audit;
use PandoraFMS\Modules\Users\UserProfiles\Entities\UserProfile;
use PandoraFMS\Modules\Users\UserProfiles\Repositories\UserProfileRepository;
use PandoraFMS\Modules\Users\UserProfiles\Validations\UserProfileValidation;
use PandoraFMS\Modules\IncidenceTypes\Fields\Entities\IncidenceTypeField;
use PandoraFMS\Modules\Shared\Services\Audit;
final class CreateUserProfileService
{
public function __construct(
private UserProfileRepository $userProfileRepository,
private UserProfileValidation $userProfileValidation,
@ -19,7 +16,6 @@ final class CreateUserProfileService
) {
}
public function __invoke(UserProfile $userProfile): UserProfile
{
$this->userProfileValidation->__invoke($userProfile);
@ -33,6 +29,4 @@ final class CreateUserProfileService
return $userProfile;
}
}

View File

@ -2,16 +2,13 @@
namespace PandoraFMS\Modules\Users\UserProfiles\Services;
use PandoraFMS\Modules\Shared\Services\Audit;
use PandoraFMS\Modules\Shared\Services\Config;
use PandoraFMS\Modules\Users\UserProfiles\Entities\UserProfile;
use PandoraFMS\Modules\Users\UserProfiles\Repositories\UserProfileRepository;
use PandoraFMS\Modules\Shared\Services\Audit;
use PandoraFMS\Modules\Shared\Services\Config;
final class DeleteUserProfileService
{
public function __construct(
private Config $config,
private Audit $audit,
@ -19,7 +16,6 @@ final class DeleteUserProfileService
) {
}
public function __invoke(UserProfile $userProfile): void
{
$id = $userProfile->getIdUserProfile();
@ -31,6 +27,4 @@ final class DeleteUserProfileService
' Deleted field incidence type #'.$id
);
}
}

View File

@ -9,20 +9,15 @@ use PandoraFMS\Modules\Users\UserProfiles\Repositories\UserProfileRepository;
final class ExistUserProfileService
{
public function __construct(
private UserProfileRepository $userProfileRepository,
) {
}
public function __invoke(UserProfile $userProfile): bool
{
$groupFilter = new UserProfileFilter();
/*
@var UserProfile $entityFilter
*/
/** @var UserProfile $entityFilter */
$entityFilter = $groupFilter->getEntityFilter();
$entityFilter->setIdUser($userProfile->getIdUser());
$entityFilter->setIdProfile($userProfile->getIdProfile());
@ -35,6 +30,4 @@ final class ExistUserProfileService
return false;
}
}
}

View File

@ -8,26 +8,19 @@ use PandoraFMS\Modules\Users\UserProfiles\Repositories\UserProfileRepository;
final class GetUserProfileService
{
public function __construct(
private UserProfileRepository $userProfileRepository,
) {
}
public function __invoke(string $idUser, int $idProfile): UserProfile
{
$userProfileFilter = new UserProfileFilter();
/*
@var UserProfile $entityFilter
*/
/** @var UserProfile $entityFilter */
$entityFilter = $userProfileFilter->getEntityFilter();
$entityFilter->setIdUser($idUser);
$entityFilter->setIdProfile($idProfile);
return $this->userProfileRepository->getOne($userProfileFilter);
}
}

View File

@ -7,18 +7,13 @@ use PandoraFMS\Modules\Users\UserProfiles\Repositories\UserProfileRepository;
final class ListUserProfileService
{
public function __construct(
private UserProfileRepository $userProfileRepository,
) {
}
public function __invoke(UserProfileFilter $userProfileFilter): array
{
return $this->userProfileRepository->list($userProfileFilter);
}
}

View File

@ -2,7 +2,7 @@
namespace PandoraFMS\Modules\Users\UserProfiles\Validations;
use PandoraFMS\Modules\Groups\Services\GetGroupService;
//use PandoraFMS\Modules\Groups\Services\GetGroupService;
use PandoraFMS\Modules\Profiles\Services\GetProfileService;
use PandoraFMS\Modules\Shared\Exceptions\BadRequestException;
use PandoraFMS\Modules\Shared\Services\Config;
@ -13,10 +13,8 @@ use PandoraFMS\Modules\Users\UserProfiles\Services\ExistUserProfileService;
final class UserProfileValidation
{
public function __construct(
private GetGroupService $getGroupService,
//private GetGroupService $getGroupService,
private GetUserService $getUserService,
private GetProfileService $getProfileService,
private ExistUserProfileService $existUserProfileService,
@ -25,7 +23,6 @@ final class UserProfileValidation
) {
}
public function __invoke(UserProfile $userProfile): void
{
if (!$userProfile->getIdUser()) {
@ -36,7 +33,7 @@ final class UserProfileValidation
throw new BadRequestException(__('Id profile is missing'));
}
if (!$userProfile->getIdGroup()) {
if ($userProfile->getIdGroup() === null || $userProfile->getIdGroup() === '') {
throw new BadRequestException(__('Id group is missing'));
}
@ -46,16 +43,10 @@ final class UserProfileValidation
if (empty($userProfile->getIdProfile()) === false) {
$this->validateProfile($userProfile->getIdProfile());
$this->acl->validateUserProfile($userProfile->getIdProfile());
}
if (empty($userProfile->getIdGroup()) === false) {
$this->validateGroup($userProfile->getIdGroup());
$this->acl->validateUserGroups(
$userProfile->getIdGroup(),
'UM',
' tried to manage groups'
);
}
if ($this->existUserProfileService->__invoke($userProfile) === true) {
@ -63,25 +54,54 @@ final class UserProfileValidation
}
$userProfile->setAssignedBy($this->config->get('id_user'));
}
if ($userProfile->getIsNoHierarchy() === null) {
$userProfile->setIsNoHierarchy(false);
}
if ($userProfile->getIdPolicy() === null) {
$userProfile->setIdPolicy(0);
}
if (empty($userProfile->getIdPolicy()) === false) {
$this->validatePolicy($userProfile->getIdPolicy());
}
if (empty($userProfile->getTags()) === false) {
$this->validateTags($userProfile->getTags());
}
}
private function validateUser(string $idUser): void
{
$this->getUserService->__invoke($idUser);
}
private function validateProfile(int $idProfile): void
{
$this->getProfileService->__invoke($idProfile);
}
private function validateGroup(int $idGroup): void
{
$this->getGroupService->__invoke($idGroup);
//$this->getGroupService->__invoke($idGroup);
}
protected function validatePolicy(int $idPolicy): void
{
// TODO: create new service for this.
if (! (bool) \policies_get_policy($idPolicy)) {
throw new BadRequestException(__('Invalid id policy'));
}
}
protected function validateTags(array $tags): void
{
// TODO: create new service for this.
foreach ($tags as $tag) {
if (! (bool) \tags_get_name($tag)) {
throw new BadRequestException(__('Invalid id tag:, %', $tag));
}
}
}
}

View File

@ -13,13 +13,13 @@ use Slim\App;
return function (App $app) {
$app->map(['GET', 'POST'], '/user/list', ListUserController::class);
$app->get('/user/{id}', GetUserController::class);
$app->get('/user/{idUser}', GetUserController::class);
$app->post('/user', CreateUserController::class);
$app->put('/user/{id}', UpdateUserController::class);
$app->delete('/user/{id}', DeleteUserController::class);
$app->put('/user/{idUser}', UpdateUserController::class);
$app->delete('/user/{idUser}', DeleteUserController::class);
$app->map(['GET', 'POST'], '/user/{id}/profiles', ListUserProfileController::class);
$app->get('/user/{id}/profile/{idProfile}', GetUserProfileController::class);
$app->post('/user/{id}/profile/{idProfile}', CreateUserProfileController::class);
$app->delete('/user/{id}/profile/{idProfile}', DeleteUserProfileController::class);
$app->map(['GET', 'POST'], '/user/{idUser}/profiles', ListUserProfileController::class);
$app->get('/user/{idUser}/profile/{idProfile}', GetUserProfileController::class);
$app->post('/user/{idUser}/profile/{idProfile}', CreateUserProfileController::class);
$app->delete('/user/{idUser}/profile/{idProfile}', DeleteUserProfileController::class);
};