Compare commits
	
		
			16 Commits
		
	
	
		
			6a055bc3db
			...
			developmen
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 9634e06fbf | |||
| 0affc6ebf4 | |||
| 21f5945272 | |||
| 8b0a0c6bc8 | |||
| 95e64b8431 | |||
|   | 574d0fb5ba | ||
| 5434f292c6 | |||
| c4f6972aa2 | |||
| 4a3fb91ffe | |||
|   | 3673febe93 | ||
| 263bcc7649 | |||
| 3e935aa006 | |||
| ee01415ebe | |||
| 69f0590e8d | |||
| 42f213e09d | |||
| 69e21e276c | 
							
								
								
									
										17
									
								
								.dockerignore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								.dockerignore
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| **/bin/ | ||||
| **/obj/ | ||||
| **/.vs/ | ||||
| **/.idea/ | ||||
| **/.vscode/ | ||||
| **/*.user | ||||
| **/*.suo | ||||
| **/*.swp | ||||
| **/*.csproj.user | ||||
| **/*.log | ||||
| **/Properties/launchSettings.json | ||||
| **/appsettings.Local.json | ||||
| **/appsettings.*.Development.json | ||||
| .git/ | ||||
| .gitignore | ||||
| Dockerfile | ||||
| docker-compose*.yml | ||||
| @@ -19,19 +19,8 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|     public class AuthenticationController( | ||||
|     IThalosServiceClient thalosServiceClient, | ||||
|     ILogger<AuthenticationController> logger, | ||||
|     ITokenService tokenService, | ||||
|     IGoogleAuthorization googleAuthorization) : BaseController(logger) | ||||
|     ITokenService tokenService) : BaseController(logger) | ||||
|     { | ||||
|         [HttpGet] | ||||
|         public IActionResult Authorize() => Ok(googleAuthorization.GetAuthorizationUrl()); | ||||
|  | ||||
|         [HttpGet("callback")] | ||||
|         public async Task<IActionResult> Callback(string code) | ||||
|         { | ||||
|             var userCredential = await googleAuthorization.ExchangeCodeForToken(code); | ||||
|  | ||||
|             return Ok(new { Token = userCredential!.Token.IdToken }); | ||||
|         } | ||||
|         /// <summary> | ||||
|         /// Get token for user. | ||||
|         /// </summary> | ||||
| @@ -93,7 +82,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         [HttpGet] | ||||
|         [Route(Routes.RefreshToken)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         //[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|         public async Task<IActionResult> RefreshCustomTokenAsync(CancellationToken cancellationToken) | ||||
|         { | ||||
|             var tokenAdapter = new TokenAdapter(); | ||||
|   | ||||
| @@ -21,10 +21,10 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|     public class ModuleController(IThalosServiceClient thalosServiceClient, ILogger<ModuleController> logger) : BaseController(logger) | ||||
|     { | ||||
|         /// <summary> | ||||
|         /// Gets all the modules. | ||||
|         /// Gets all modules. | ||||
|         /// </summary> | ||||
|         [HttpGet("GetAll")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(IEnumerable<ModuleAdapter>), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -47,7 +47,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Gets all the modules by module identifiers. | ||||
|         /// Gets all modules by module identifiers. | ||||
|         /// </summary> | ||||
|         /// <param name="request">The request containing the list of module identifiers.</param> | ||||
|         /// <param name="cancellationToken">Cancellation token for the asynchronous operation.</param> | ||||
| @@ -90,7 +90,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// Creates a new module. | ||||
|         /// </summary> | ||||
|         [HttpPost("Create")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(ModuleAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -124,7 +124,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// Gets the module by identifier. | ||||
|         /// </summary> | ||||
|         [HttpPost("GetById")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(ModuleAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -137,7 +137,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(GetModuleByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request.Id)) return BadRequest("Invalid module identifier"); | ||||
|                 if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid module identifier"); | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.GetModuleByIdService(request, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
| @@ -152,7 +152,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// Updates a full module by identifier. | ||||
|         /// </summary> | ||||
|         [HttpPut("Update")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(ModuleAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -187,7 +187,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// </summary> | ||||
|         [HttpPatch] | ||||
|         [Route("ChangeStatus")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(ModuleAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
| @@ -201,7 +201,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(ChangeModuleStatusService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid module identifier"); } | ||||
|                 if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid module identifier"); } | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.ChangeModuleStatusService(request, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
| @@ -212,6 +212,32 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Deletes the Module by identifier. | ||||
|         /// </summary> | ||||
|         [HttpDelete("Delete")] | ||||
|         [ProducesResponseType(typeof(ModuleAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Permission("ModuleManagement.Write")] | ||||
|         public async Task<IActionResult> DeleteModuleByIdService(DeleteModuleRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(DeleteModuleByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid Module identifier"); | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.DeleteModuleByIdService(request, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 logger.LogError($"{nameof(DeleteModuleByIdService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); | ||||
|                 throw; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -5,7 +5,6 @@ using Lib.Architecture.BuildingBlocks; | ||||
| using LSA.Dashboard.External.Clients.Dashboard; | ||||
| using Microsoft.AspNetCore.Authorization; | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
| using Microsoft.Graph; | ||||
| using System.Text.Json; | ||||
|  | ||||
| namespace Core.Thalos.BFF.Api.Controllers | ||||
| @@ -22,10 +21,10 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|     public class PermissionController(IThalosServiceClient thalosServiceClient, ILogger<PermissionController> logger) : BaseController(logger) | ||||
|     { | ||||
|         /// <summary> | ||||
|         /// Gets all the permissions. | ||||
|         /// Gets all permissions. | ||||
|         /// </summary> | ||||
|         [HttpGet("GetAll")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(IEnumerable<PermissionAdapter>), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -48,7 +47,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Gets all the permissions by permission identifiers. | ||||
|         /// Gets all permissions by permission identifiers. | ||||
|         /// </summary> | ||||
|         /// <param name="request">The request containing the list of permission identifiers.</param> | ||||
|         /// <param name="cancellationToken">Cancellation token for the asynchronous operation.</param> | ||||
| @@ -91,7 +90,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// Creates a new permission. | ||||
|         /// </summary> | ||||
|         [HttpPost("Create")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(PermissionAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -123,7 +122,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// Gets the permission by identifier. | ||||
|         /// </summary> | ||||
|         [HttpPost("GetById")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(PermissionAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -136,7 +135,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(GetPermissionByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request.Id)) return BadRequest("Invalid permission identifier"); | ||||
|                 if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid permission identifier"); | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.GetPermissionByIdService(request, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
| @@ -151,7 +150,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// Updates a full permission by identifier. | ||||
|         /// </summary> | ||||
|         [HttpPut("Update")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(PermissionAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -184,7 +183,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// </summary> | ||||
|         [HttpPatch] | ||||
|         [Route("ChangeStatus")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(PermissionAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
| @@ -198,7 +197,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(ChangePermissionStatusService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid permission identifier"); } | ||||
|                 if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid permission identifier"); } | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.ChangePermissionStatusService(request, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
| @@ -209,6 +208,32 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Deletes the Permission by identifier. | ||||
|         /// </summary> | ||||
|         [HttpDelete("Delete")] | ||||
|         [ProducesResponseType(typeof(PermissionAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Permission("PermissionManagement.Write")] | ||||
|         public async Task<IActionResult> DeletePermissionByIdService(DeletePermissionRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(DeletePermissionByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid Permission identifier"); | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.DeletePermissionByIdService(request, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 logger.LogError($"{nameof(DeletePermissionByIdService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); | ||||
|                 throw; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -21,10 +21,10 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|     public class RoleController(IThalosServiceClient thalosServiceClient, ILogger<RoleController> logger) : BaseController(logger) | ||||
|     { | ||||
|         /// <summary> | ||||
|         /// Gets all the roles. | ||||
|         /// Gets all roles. | ||||
|         /// </summary> | ||||
|         [HttpGet("GetAll")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(IEnumerable<RoleAdapter>), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -50,7 +50,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// Creates a new role. | ||||
|         /// </summary> | ||||
|         [HttpPost("Create")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -88,7 +88,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// Gets the role by identifier. | ||||
|         /// </summary> | ||||
|         [HttpPost("GetById")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -101,7 +101,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(GetRoleByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request.Id)) return BadRequest("Invalid role identifier"); | ||||
|                 if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid role identifier"); | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.GetRoleByIdService(request, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
| @@ -116,7 +116,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// Updates a full role by identifier. | ||||
|         /// </summary> | ||||
|         [HttpPut("Update")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -133,7 +133,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request.Name)) return BadRequest("Invalid role name"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request.Id)) return BadRequest("Invalid role identifier"); | ||||
|                 if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid role identifier"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request.Description)) return BadRequest("Invalid role description"); | ||||
|  | ||||
| @@ -158,7 +158,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// </summary> | ||||
|         [HttpPatch] | ||||
|         [Route("ChangeStatus")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
| @@ -172,7 +172,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(ChangeRoleStatusService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid role identifier"); } | ||||
|                 if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid role identifier"); } | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.ChangeRoleStatusService(request, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
| @@ -188,7 +188,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// </summary> | ||||
|         [HttpPost] | ||||
|         [Route("AddApplication")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
| @@ -218,7 +218,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// </summary> | ||||
|         [HttpDelete] | ||||
|         [Route("RemoveApplication")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
| @@ -242,5 +242,33 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|                 throw; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Deletes the Role by identifier. | ||||
|         /// </summary> | ||||
|         [HttpDelete("Delete")] | ||||
|         [ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Permission("RoleManagement.Write")] | ||||
|         public async Task<IActionResult> DeleteRoleByIdService(DeleteRoleRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(DeleteRoleByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid Role identifier"); | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.DeleteRoleByIdService(request, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 logger.LogError($"{nameof(DeleteRoleByIdService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); | ||||
|                 throw; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
							
								
								
									
										196
									
								
								Core.Thalos.BFF.Api/Controllers/TenantController.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										196
									
								
								Core.Thalos.BFF.Api/Controllers/TenantController.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,196 @@ | ||||
| using Asp.Versioning; | ||||
| using Core.Thalos.BuildingBlocks; | ||||
| using Core.Thalos.External.Clients.Thalos.Requests.Tenants; | ||||
| using Lib.Architecture.BuildingBlocks; | ||||
| using LSA.Dashboard.External.Clients.Dashboard; | ||||
| using Microsoft.AspNetCore.Authorization; | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
| using System.Text.Json; | ||||
|  | ||||
| namespace Core.Thalos.BFF.Api.Controllers | ||||
| { | ||||
|     /// <summary> | ||||
|     /// Handles all requests for Tenant authentication. | ||||
|     /// </summary> | ||||
|     [ApiVersion("1.0")] | ||||
|     [Route("api/v{version:apiVersion}/[controller]")] | ||||
|     [Consumes("application/json")] | ||||
|     [Produces("application/json")] | ||||
|     [ApiController] | ||||
|     [Authorize(AuthenticationSchemes = Schemes.DefaultScheme)] | ||||
|     public class TenantController(IThalosServiceClient thalosServiceClient, ILogger<TenantController> logger) : BaseController(logger) | ||||
|     { | ||||
|         /// <summary> | ||||
|         /// Gets all Tenants. | ||||
|         /// </summary> | ||||
|         [HttpGet("GetAll")] | ||||
|         [ProducesResponseType(typeof(IEnumerable<TenantAdapter>), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Permission("TenantManagement.Read, RoleManagement.Read")] | ||||
|         public async Task<IActionResult> GetAllTenantsService(CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(GetAllTenantsService)} - Request received - Payload: "); | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.GetAllTenantsService(new GetAllTenantsRequest { }, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 logger.LogError($"{nameof(GetAllTenantsService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload"); | ||||
|                 throw; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Creates a new Tenant. | ||||
|         /// </summary> | ||||
|         [HttpPost("Create")] | ||||
|         [ProducesResponseType(typeof(TenantAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Permission("TenantManagement.Write")] | ||||
|         public async Task<IActionResult> CreateTenantService(CreateTenantRequest newTenant, CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(CreateTenantService)} - Request received - Payload: {JsonSerializer.Serialize(newTenant)}"); | ||||
|  | ||||
|                 if (newTenant == null) return BadRequest("Invalid Tenant object"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(newTenant.Name)) return BadRequest("Invalid Tenant name"); | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.CreateTenantService(newTenant, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 logger.LogError($"{nameof(CreateTenantService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(newTenant)}"); | ||||
|                 throw; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Gets the Tenant by identifier. | ||||
|         /// </summary> | ||||
|         [HttpPost("GetById")] | ||||
|         [ProducesResponseType(typeof(TenantAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Permission("TenantManagement.Read")] | ||||
|         public async Task<IActionResult> GetTenantByIdService(GetTenantRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(GetTenantByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid Tenant identifier"); | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.GetTenantByIdService(request, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 logger.LogError($"{nameof(GetTenantByIdService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); | ||||
|                 throw; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Updates a full Tenant by identifier. | ||||
|         /// </summary> | ||||
|         [HttpPut("Update")] | ||||
|         [ProducesResponseType(typeof(TenantAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Permission("TenantManagement.Write")] | ||||
|         public async Task<IActionResult> UpdateTenantService(UpdateTenantRequest newTenant, CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(UpdateTenantService)} - Request received - Payload: {JsonSerializer.Serialize(newTenant)}"); | ||||
|  | ||||
|                 if (newTenant == null) return BadRequest("Invalid Tenant object"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(newTenant.Name)) return BadRequest("Invalid Tenant name"); | ||||
|  | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.UpdateTenantService(newTenant, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 logger.LogError($"{nameof(UpdateTenantService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(newTenant)}"); | ||||
|                 throw; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Changes the status of the Tenant. | ||||
|         /// </summary> | ||||
|         [HttpPatch] | ||||
|         [Route("ChangeStatus")] | ||||
|         [ProducesResponseType(typeof(TenantAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Permission("TenantManagement.Write")] | ||||
|         public async Task<IActionResult> ChangeTenantStatusService([FromBody] ChangeTenantStatusRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(ChangeTenantStatusService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid Tenant identifier"); } | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.ChangeTenantStatusService(request, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 logger.LogError($"{nameof(ChangeTenantStatusService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); | ||||
|                 throw; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Deletes the Tenant by identifier. | ||||
|         /// </summary> | ||||
|         [HttpDelete("Delete")] | ||||
|         [ProducesResponseType(typeof(TenantAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Permission("TenantManagement.Write")] | ||||
|         public async Task<IActionResult> DeleteTenantByIdService(DeleteTenantRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(DeleteTenantByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid Tenant identifier"); | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.DeleteTenantByIdService(request, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 logger.LogError($"{nameof(DeleteTenantByIdService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); | ||||
|                 throw; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -21,10 +21,10 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|     public class UserController(IThalosServiceClient thalosServiceClient, ILogger<UserController> logger) : BaseController(logger) | ||||
|     { | ||||
|         /// <summary> | ||||
|         /// Gets all the users. | ||||
|         /// Gets all users. | ||||
|         /// </summary> | ||||
|         [HttpGet("GetAll")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(IEnumerable<UserAdapter>), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -51,7 +51,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// Creates a new user. | ||||
|         /// </summary> | ||||
|         [HttpPost("Create")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -75,6 +75,8 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(newUser.RoleId)) return BadRequest("Invalid role id"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(newUser.TenantId)) return BadRequest("Invalid tenant id"); | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.CreateUserService(newUser, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
| @@ -88,7 +90,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// Gets the user by identifier. | ||||
|         /// </summary> | ||||
|         [HttpPost("GetById")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -102,7 +104,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(GetUserByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request.Id)) return BadRequest("Invalid user identifier"); | ||||
|                 if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid user identifier"); | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.GetUserByIdService(request, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
| @@ -117,7 +119,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// Gets the user by email. | ||||
|         /// </summary> | ||||
|         [HttpPost("GetByEmail")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -146,7 +148,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// Updates a full user by identifier. | ||||
|         /// </summary> | ||||
|         [HttpPut("Update")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -170,8 +172,6 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request.RoleId)) return BadRequest("Invalid role id"); | ||||
|  | ||||
|                 if (!request.Companies.Any()) return BadRequest("The user must contain at least one company"); | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.UpdateUserService(request, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
| @@ -185,7 +185,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// Logs in the user. | ||||
|         /// </summary> | ||||
|         [HttpPatch("LoginUser")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -213,7 +213,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// Logs out the user. | ||||
|         /// </summary> | ||||
|         [HttpPatch("LogoutUser")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -242,7 +242,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// </summary> | ||||
|         [HttpPatch] | ||||
|         [Route("ChangeStatus")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
| @@ -257,7 +257,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(ChangeUserStatusService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid user identifier"); } | ||||
|                 if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid user identifier"); } | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.ChangeUserStatusService(request, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
| @@ -272,7 +272,7 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|         /// Gets the user by email. | ||||
|         /// </summary> | ||||
|         [HttpPost("ValidateExistence")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
| @@ -295,5 +295,33 @@ namespace Core.Thalos.BFF.Api.Controllers | ||||
|                 throw; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Deletes the User by identifier. | ||||
|         /// </summary> | ||||
|         [HttpDelete("Delete")] | ||||
|         [ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         [Permission("UserManagement.Write")] | ||||
|         public async Task<IActionResult> DeleteUserByIdService(DeleteUserRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(DeleteUserByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid User identifier"); | ||||
|  | ||||
|                 return await Handle(() => thalosServiceClient.DeleteUserByIdService(request, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 logger.LogError($"{nameof(DeleteUserByIdService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); | ||||
|                 throw; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" /> | ||||
|     <PackageReference Include="Core.Blueprint.Logging" Version="1.0.1" /> | ||||
|     <PackageReference Include="Core.Blueprint.Logging" Version="1.0.0" /> | ||||
|   </ItemGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|   | ||||
| @@ -24,7 +24,7 @@ | ||||
|       "dotnetRunMessages": true, | ||||
|       "launchBrowser": true, | ||||
|       "launchUrl": "swagger", | ||||
|       "applicationUrl": "https://localhost:7239;http://localhost:5219", | ||||
|       "applicationUrl": "https://localhost:44320;http://localhost:5219", | ||||
|       "environmentVariables": { | ||||
|         "ASPNETCORE_ENVIRONMENT": "Local" | ||||
|       } | ||||
|   | ||||
| @@ -6,20 +6,20 @@ | ||||
|     } | ||||
|   }, | ||||
|   "LocalGateways": { | ||||
|     "ThalosService": "https://localhost:7253/api" | ||||
|     "ThalosService": "https://localhost:44312/api" | ||||
|   }, | ||||
|   "ServiceSettings": { | ||||
|     "ApplicationName": "thalos", | ||||
|     "LayerName": "bff" | ||||
|   }, | ||||
|   "Vault": { | ||||
|     "Address": "http://100.123.31.103:8200", | ||||
|     "Token": "hvs.e37LQvLuPhTd5ALS5QQ03Cwm", | ||||
|     "SecretMount": "secret" | ||||
|     "Address": "https://vault.dream-views.com/", | ||||
|     "Token": "hvs.TGz6P3AsKpYuODMrs11Msiza", | ||||
|     "SecretMount": "thalos" | ||||
|   }, | ||||
|   "IdentityProviders": { | ||||
|     "Google": true, | ||||
|     "Azure": true | ||||
|     "Azure": false | ||||
|   } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -2,6 +2,7 @@ | ||||
| using Core.Thalos.Application.UseCases.Users.Input; | ||||
| using Core.Thalos.BuildingBlocks; | ||||
| using Core.Thalos.External.Clients.Thalos.Requests.Permissions; | ||||
| using Core.Thalos.External.Clients.Thalos.Requests.Tenants; | ||||
| using Core.Thalos.External.Clients.Thalos.Requests.Users; | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
| using Refit; | ||||
| @@ -31,6 +32,9 @@ namespace LSA.Dashboard.External.Clients.Dashboard | ||||
|         [Put("/v1/User/Update")] | ||||
|         Task<ApiResponse<UserAdapter>> UpdateUserService([Header("TrackingId")][Body] UpdateUserRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Delete("/v1/User/Delete")] | ||||
|         Task<ApiResponse<UserAdapter>> DeleteUserByIdService([Header("TrackingId")][Body] DeleteUserRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Patch("/v1/User/LoginUser")] | ||||
|         Task<ApiResponse<UserAdapter>> LoginUserService([Header("TrackingId")][Body] LoginUserRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
| @@ -61,6 +65,9 @@ namespace LSA.Dashboard.External.Clients.Dashboard | ||||
|         [Patch("/v1/Role/ChangeStatus")] | ||||
|         Task<ApiResponse<RoleAdapter>> ChangeRoleStatusService([Header("TrackingId")][Body] ChangeRoleStatusRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Delete("/v1/Role/Delete")] | ||||
|         Task<ApiResponse<RoleAdapter>> DeleteRoleByIdService([Header("TrackingId")][Body] DeleteRoleRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Post("/v1/Role/AddApplication")] | ||||
|         Task<ApiResponse<RoleAdapter>> AddApplicationToRoleService([Header("TrackingId")][Body] AddApplicationToRoleRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
| @@ -85,6 +92,9 @@ namespace LSA.Dashboard.External.Clients.Dashboard | ||||
|         [Patch("/v1/Permission/ChangeStatus")] | ||||
|         Task<ApiResponse<PermissionAdapter>> ChangePermissionStatusService([Header("TrackingId")][Body] ChangePermissionStatusRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Delete("/v1/Permission/Delete")] | ||||
|         Task<ApiResponse<PermissionAdapter>> DeletePermissionByIdService([Header("TrackingId")][Body] DeletePermissionRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Post("/v1/Module/Create")] | ||||
|         Task<ApiResponse<ModuleAdapter>> CreateModuleService([Header("TrackingId")][Body] CreateModuleRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
| @@ -102,5 +112,27 @@ namespace LSA.Dashboard.External.Clients.Dashboard | ||||
|  | ||||
|         [Patch("/v1/Module/ChangeStatus")] | ||||
|         Task<ApiResponse<ModuleAdapter>> ChangeModuleStatusService([Header("TrackingId")][Body] ChangeModuleStatusRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Delete("/v1/Module/Delete")] | ||||
|         Task<ApiResponse<ModuleAdapter>> DeleteModuleByIdService([Header("TrackingId")][Body] DeleteModuleRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
|  | ||||
|         [Post("/v1/Tenant/Create")] | ||||
|         Task<ApiResponse<TenantAdapter>> CreateTenantService([Header("TrackingId")][Body] CreateTenantRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Post("/v1/Tenant/GetById")] | ||||
|         Task<ApiResponse<TenantAdapter>> GetTenantByIdService([Header("TrackingId")][Body] GetTenantRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Get("/v1/Tenant/GetAll")] | ||||
|         Task<ApiResponse<IEnumerable<TenantAdapter>>> GetAllTenantsService([Header("TrackingId")][Body] GetAllTenantsRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Put("/v1/Tenant/Update")] | ||||
|         Task<ApiResponse<TenantAdapter>> UpdateTenantService([Header("TrackingId")][Body] UpdateTenantRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Patch("/v1/Tenant/ChangeStatus")] | ||||
|         Task<ApiResponse<TenantAdapter>> ChangeTenantStatusService([Header("TrackingId")][Body] ChangeTenantStatusRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Delete("/v1/Tenant/Delete")] | ||||
|         Task<ApiResponse<UserAdapter>> DeleteTenantByIdService([Header("TrackingId")][Body] DeleteTenantRequest request, CancellationToken cancellationToken = default); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -4,7 +4,7 @@ namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | ||||
| { | ||||
|     public class ChangeModuleStatusRequest | ||||
|     { | ||||
|         public string Id { get; set; } | ||||
|         public string _Id { get; set; } | ||||
|         public StatusEnum Status { get; set; } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,7 @@ | ||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | ||||
| { | ||||
|     public class DeleteModuleRequest | ||||
|     { | ||||
|         public string _Id { get; set; } | ||||
|     } | ||||
| } | ||||
| @@ -2,6 +2,6 @@ | ||||
| { | ||||
|     public class GetModuleRequest | ||||
|     { | ||||
|         public string Id { get; set; } | ||||
|         public string _Id { get; set; } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -5,7 +5,7 @@ namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | ||||
| { | ||||
|     public class UpdateModuleRequest | ||||
|     { | ||||
|         public string Id { get; set; } = null!; | ||||
|         public string _Id { get; set; } = null!; | ||||
|         public string Name { get; set; } = null!; | ||||
|         public string? Description { get; set; } | ||||
|         public string? Icon { get; set; } | ||||
|   | ||||
| @@ -4,7 +4,7 @@ namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | ||||
| { | ||||
|     public class ChangePermissionStatusRequest | ||||
|     { | ||||
|         public string Id { get; set; } | ||||
|         public string _Id { get; set; } | ||||
|         public StatusEnum Status { get; set; } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,7 @@ | ||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | ||||
| { | ||||
|     public class DeletePermissionRequest | ||||
|     { | ||||
|         public string _Id { get; set; } | ||||
|     } | ||||
| } | ||||
| @@ -2,6 +2,6 @@ | ||||
| { | ||||
|     public class GetPermissionRequest | ||||
|     { | ||||
|         public string Id { get; set; } | ||||
|         public string _Id { get; set; } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -5,7 +5,7 @@ namespace Core.Thalos.External.Clients.Thalos.Requests.Permissions | ||||
| { | ||||
|     public class UpdatePermissionRequest | ||||
|     { | ||||
|         public string Id { get; set; } = null!; | ||||
|         public string _Id { get; set; } = null!; | ||||
|         public string Name { get; set; } = null!; | ||||
|         public string? Description { get; set; } | ||||
|         public AccessLevelEnum? AccessLevel { get; set; } = null!; | ||||
|   | ||||
| @@ -4,7 +4,7 @@ namespace Core.Thalos.Application.UseCases.Roles.Input | ||||
| { | ||||
|     public class ChangeRoleStatusRequest | ||||
|     { | ||||
|         public string Id { get; set; } | ||||
|         public string _Id { get; set; } | ||||
|         public StatusEnum Status { get; set; } | ||||
|  | ||||
|     } | ||||
|   | ||||
| @@ -0,0 +1,7 @@ | ||||
| namespace Core.Thalos.Application.UseCases.Roles.Input | ||||
| { | ||||
|     public class DeleteRoleRequest | ||||
|     { | ||||
|         public string _Id { get; set; } | ||||
|     } | ||||
| } | ||||
| @@ -2,6 +2,6 @@ | ||||
| { | ||||
|     public class GetRoleRequest | ||||
|     { | ||||
|         public string Id { get; set; } | ||||
|         public string _Id { get; set; } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -6,7 +6,7 @@ namespace Core.Thalos.Application.UseCases.Roles.Input | ||||
| { | ||||
|     public class UpdateRoleRequest | ||||
|     { | ||||
|         public string Id { get; set; } = null!; | ||||
|         public string _Id { get; set; } = null!; | ||||
|         public string Name { get; set; } = null!; | ||||
|         public string? Description { get; set; } | ||||
|         [JsonConverter(typeof(EnumArrayJsonConverter<ApplicationsEnum>))] | ||||
|   | ||||
| @@ -0,0 +1,10 @@ | ||||
| using Core.Blueprint.Mongo; | ||||
|  | ||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Tenants | ||||
| { | ||||
|     public class ChangeTenantStatusRequest | ||||
|     { | ||||
|         public string _Id { get; set; } | ||||
|         public StatusEnum Status { get; set; } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,31 @@ | ||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Tenants | ||||
| { | ||||
|     public class CreateTenantRequest | ||||
|     { | ||||
|         public string Name { get; set; } = null!; | ||||
|  | ||||
|         public string TaxIdentifier { get; set; } = null!; | ||||
|  | ||||
|         public string AddressLine1 { get; set; } = null!; | ||||
|  | ||||
|         public string? AddressLine2 { get; set; } | ||||
|  | ||||
|         public string City { get; set; } = null!; | ||||
|  | ||||
|         public string State { get; set; } = null!; | ||||
|  | ||||
|         public string Country { get; set; } = null!; | ||||
|  | ||||
|         public string PostalCode { get; set; } = null!; | ||||
|  | ||||
|         public string ContactEmail { get; set; } = null!; | ||||
|  | ||||
|         public string ContactPhone { get; set; } = null!; | ||||
|  | ||||
|         public string? Website { get; set; } | ||||
|  | ||||
|         public string? ConnectionString { get; set; } | ||||
|  | ||||
|         public bool Isolated { get; set; } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,7 @@ | ||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Tenants | ||||
| { | ||||
|     public class DeleteTenantRequest | ||||
|     { | ||||
|         public string _Id { get; set; } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,6 @@ | ||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Tenants | ||||
| { | ||||
|     public class GetAllTenantsRequest | ||||
|     { | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,7 @@ | ||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Tenants | ||||
| { | ||||
|     public class GetTenantRequest | ||||
|     { | ||||
|         public string _Id { get; set; } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,39 @@ | ||||
| namespace Core.Thalos.External.Clients.Thalos.Requests.Tenants | ||||
| { | ||||
|     public class UpdateTenantRequest | ||||
|     { | ||||
|         public string Name { get; set; } = null!; | ||||
|  | ||||
|         public string TaxIdentifier { get; set; } = null!; | ||||
|  | ||||
|         public string AddressLine1 { get; set; } = null!; | ||||
|  | ||||
|         public string? AddressLine2 { get; set; } | ||||
|  | ||||
|         public string City { get; set; } = null!; | ||||
|  | ||||
|         public string State { get; set; } = null!; | ||||
|  | ||||
|         public string Country { get; set; } = null!; | ||||
|  | ||||
|         public string PostalCode { get; set; } = null!; | ||||
|  | ||||
|         public string ContactEmail { get; set; } = null!; | ||||
|  | ||||
|         public string ContactPhone { get; set; } = null!; | ||||
|  | ||||
|         public string? Website { get; set; } | ||||
|  | ||||
|         public string? ConnectionString { get; set; } | ||||
|  | ||||
|         public bool Isolated { get; set; } | ||||
|         public string _Id { get; set; } = null!; | ||||
|         public string Id { get; init; } = null!; | ||||
|         public DateTime CreatedAt { get; set; } | ||||
|         public string? CreatedBy { get; set; } | ||||
|         public DateTime? UpdatedAt { get; set; } | ||||
|         public string? UpdatedBy { get; set; } | ||||
|  | ||||
|         public Blueprint.Mongo.StatusEnum Status { get; set; } | ||||
|     } | ||||
| } | ||||
| @@ -4,7 +4,7 @@ namespace Core.Thalos.Application.UseCases.Users.Input | ||||
| { | ||||
|     public class ChangeUserStatusRequest | ||||
|     { | ||||
|         public string Id { get; set; } | ||||
|         public string _Id { get; set; } | ||||
|         public StatusEnum Status { get; set; } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -7,6 +7,7 @@ | ||||
|         public string? MiddleName { get; set; } | ||||
|         public string LastName { get; set; } = null!; | ||||
|         public string RoleId { get; set; } = null!; | ||||
|         public string TenantId { get; set; } = null!; | ||||
|         public bool SendInvitation { get; set; } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,7 @@ | ||||
| namespace Core.Thalos.Application.UseCases.Users.Input | ||||
| { | ||||
|     public class DeleteUserRequest | ||||
|     { | ||||
|         public string _Id { get; set; } | ||||
|     } | ||||
| } | ||||
| @@ -2,6 +2,6 @@ | ||||
| { | ||||
|     public class GetUserRequest | ||||
|     { | ||||
|         public string Id { get; set; } | ||||
|         public string _Id { get; set; } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -4,14 +4,14 @@ namespace Core.Thalos.Application.UseCases.Users.Input | ||||
| { | ||||
|     public class UpdateUserRequest | ||||
|     { | ||||
|         public string Id { get; set; } = null!; | ||||
|         public string _Id { get; set; } = null!; | ||||
|         public string Email { get; set; } = null!; | ||||
|         public string Name { get; set; } = null!; | ||||
|         public string? MiddleName { get; set; } | ||||
|         public string LastName { get; set; } = null!; | ||||
|         public string RoleId { get; set; } = null!; | ||||
|         public string[] Companies { get; set; } = null!; | ||||
|         public string[]? Projects { get; set; } | ||||
|         public string TenantId { get; set; } = null!; | ||||
|  | ||||
|         public StatusEnum Status { get; set; } | ||||
|     } | ||||
| } | ||||
| @@ -7,7 +7,7 @@ | ||||
|   </PropertyGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.0.8" /> | ||||
|     <PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.0.5" /> | ||||
|     <PackageReference Include="Lib.Architecture.BuildingBlocks" Version="1.0.0" /> | ||||
|     <PackageReference Include="Refit" Version="8.0.0" /> | ||||
|   </ItemGroup> | ||||
|   | ||||
							
								
								
									
										38
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| # ============ Build ============ | ||||
| FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||||
| WORKDIR /src | ||||
|  | ||||
| # (opcional) si tienes nuget.config | ||||
| COPY nuget.config* ./ | ||||
|  | ||||
| # Cache de restore por proyecto | ||||
| COPY Core.Thalos.External/Core.Thalos.External.csproj Core.Thalos.External/ | ||||
| COPY Core.Thalos.BFF.Api/Core.Thalos.BFF.Api.csproj Core.Thalos.BFF.Api/ | ||||
|  | ||||
| RUN dotnet restore Core.Thalos.BFF.Api/Core.Thalos.BFF.Api.csproj | ||||
|  | ||||
| # Copia del resto + build | ||||
| COPY . . | ||||
| RUN dotnet build Core.Thalos.BFF.Api/Core.Thalos.BFF.Api.csproj -c Release -o /app/build | ||||
|  | ||||
| # ============ Publish ============ | ||||
| FROM build AS publish | ||||
| RUN dotnet publish Core.Thalos.BFF.Api/Core.Thalos.BFF.Api.csproj -c Release -o /app/publish --no-restore | ||||
|  | ||||
| # ============ Runtime ============ | ||||
| FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final | ||||
| # curl (opcional) si luego cambias a healthcheck HTTP | ||||
| RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/* | ||||
|  | ||||
| WORKDIR /app | ||||
| EXPOSE 8080 | ||||
|  | ||||
| # Usuario no-root | ||||
| RUN useradd -m appuser | ||||
| USER appuser | ||||
|  | ||||
| ENV ASPNETCORE_URLS=http://+:8080 | ||||
| # La app agrega UserSecrets/ENV/KeyVault/Auth en runtime (no hornear secretos). :contentReference[oaicite:9]{index=9} | ||||
|  | ||||
| COPY --from=publish /app/publish ./ | ||||
| ENTRYPOINT ["dotnet", "Core.Thalos.BFF.Api.dll"] | ||||
							
								
								
									
										9
									
								
								nuget.config
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								nuget.config
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <configuration> | ||||
|   <packageSources> | ||||
|     <!-- Tu BaGet primero --> | ||||
|     <add key="BaGet" value="https://nuget.dream-views.com/v3/index.json" protocolVersion="3" /> | ||||
|     <!-- NuGet oficial como fallback (si quieres) --> | ||||
|     <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> | ||||
|   </packageSources> | ||||
| </configuration> | ||||
		Reference in New Issue
	
	Block a user