Add project files.

This commit is contained in:
Sergio Matias Urquin
2025-04-29 18:44:41 -06:00
parent c4ec91852f
commit b2635193dc
133 changed files with 4100 additions and 0 deletions

View File

@@ -0,0 +1,119 @@
using Asp.Versioning;
using Core.Blueprint.Application.UsesCases.BlobStorage.Ports;
using Core.Blueprint.Application.UsesCases.KeyVault.Input;
using Lib.Architecture.BuildingBlocks;
using Microsoft.AspNetCore.Mvc;
namespace Core.Cerberos.Service.API.Controllers
{
/// <summary>
/// Handles all services and business rules related to <see cref="MStorageController"/>.
/// </summary>
[ApiVersion("1.0")]
[Route("api/v{api-version:apiVersion}/[controller]")]
[Produces("application/json")]
[ApiController]
public class BlobStorageController : ControllerBase
{
private readonly IComponentHandler<UploadBlobRequest> uploadBlobHandler;
private readonly IComponentHandler<GetBlobListRequest> getBlobListHandler;
private readonly IComponentHandler<DownloadBlobRequest> downloadBlobHandler;
private readonly IComponentHandler<DeleteBlobRequest> deleteBlobHandler;
private readonly IStoragePort port;
/// <summary>
/// Handles all services and business rules related to <see cref="MStorageController"/>.
/// </summary>
public BlobStorageController(
IComponentHandler<UploadBlobRequest> uploadBlobHandler,
IComponentHandler<GetBlobListRequest> getBlobListHandler,
IComponentHandler<DownloadBlobRequest> downloadBlobHandler,
IComponentHandler<DeleteBlobRequest> deleteBlobHandler,
IStoragePort port
)
{
this.uploadBlobHandler = uploadBlobHandler;
this.getBlobListHandler = getBlobListHandler;
this.downloadBlobHandler = downloadBlobHandler;
this.deleteBlobHandler = deleteBlobHandler;
this.port = port;
}
/// <summary>
/// Uploads a new blob.
/// </summary>
[HttpPost("UploadBlob")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> UploadBlobAsync([FromBody] UploadBlobRequest newBlob, CancellationToken cancellationToken = default)
{
await uploadBlobHandler.ExecuteAsync(newBlob, cancellationToken).ConfigureAwait(false);
return port.ViewModel;
}
/// <summary>
/// Gets all blobs into the container.
/// </summary>
[HttpGet]
[Route("GetBlobList")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> GetBlobList([FromQuery] string? prefix, CancellationToken cancellationToken)
{
await getBlobListHandler.ExecuteAsync(new GetBlobListRequest { Prefix = prefix }, cancellationToken).ConfigureAwait(false);
return port.ViewModel;
}
/// <summary>
/// Downloads a blob by name.
/// </summary>
[HttpPost("DownloadBlob")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> DownloadBlobAsync([FromBody] DownloadBlobRequest request, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(request.BlobName)) { return BadRequest("Invalid blob name"); }
await downloadBlobHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
return port.ViewModel;
}
/// <summary>
/// Deletes a blob by name.
/// </summary>
[HttpDelete]
[Route("DeleteBlob")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> DeleteBlobAsync([FromBody] DeleteBlobRequest request,
CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(request.BlobName)) { return BadRequest("Invalid blob name"); }
await deleteBlobHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
return port.ViewModel;
}
}
}

View File

@@ -0,0 +1,124 @@
using Asp.Versioning;
using Core.Blueprint.Application.UsesCases.KeyVault.Input;
using Core.Blueprint.Application.UsesCases.KeyVault.Ports;
using Lib.Architecture.BuildingBlocks;
using Microsoft.AspNetCore.Mvc;
namespace Core.Cerberos.Service.API.Controllers
{
/// <summary>
/// Handles all services and business rules related to <see cref="MKeyVaultController"/>.
/// </summary>
[ApiVersion("1.0")]
[Route("api/v{api-version:apiVersion}/[controller]")]
[Produces("application/json")]
[ApiController]
public class KeyVaultController : ControllerBase
{
private readonly IComponentHandler<CreateSecretRequest> createSecretHandler;
private readonly IComponentHandler<GetSecretRequest> getSecretHandler;
private readonly IComponentHandler<UpdateSecretRequest> updateSecretHandler;
private readonly IComponentHandler<DeleteSecretRequest> deleteSecretHandler;
private readonly IKeyVaultPort port;
/// <summary>
/// Handles all services and business rules related to <see cref="MKeyVaultController"/>.
/// </summary>
public KeyVaultController(
IComponentHandler<GetSecretRequest> getSecretHandler,
IComponentHandler<CreateSecretRequest> createSecretHandler,
IComponentHandler<UpdateSecretRequest> updateSecretHandler,
IComponentHandler<DeleteSecretRequest> deleteSecretHandler,
IKeyVaultPort port
)
{
this.createSecretHandler = createSecretHandler;
this.updateSecretHandler = updateSecretHandler;
this.deleteSecretHandler = deleteSecretHandler;
this.getSecretHandler = getSecretHandler;
this.port = port;
}
/// <summary>
/// Creates a new secret.
/// </summary>
[HttpPost("CreateSecret")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> CreateSecretAsync([FromBody] CreateSecretRequest newSecret, CancellationToken cancellationToken = default)
{
await createSecretHandler.ExecuteAsync(newSecret, cancellationToken).ConfigureAwait(false);
return port.ViewModel;
}
/// <summary>
/// Gets the secret by name.
/// </summary>
[HttpPost]
[Route("GetSecretByName")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> GetSecretByName([FromBody] GetSecretRequest request, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(request.Name)) { return BadRequest("Invalid secret name"); }
await getSecretHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
return port.ViewModel;
}
/// <summary>
/// Updates a full secret by identifier.
/// </summary>
[HttpPut("UpdateSecret")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> UpdateSecretAsync([FromBody] UpdateSecretRequest request, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(request.Name)) { return BadRequest("Invalid secret name"); }
if (string.IsNullOrEmpty(request.Value)) { return BadRequest("Invalid secret value"); }
await updateSecretHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
return port.ViewModel;
}
/// <summary>
/// Deletes a secret by name.
/// </summary>
[HttpDelete]
[Route("DeleteSecret")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> DeleteSecretAsync([FromBody] DeleteSecretRequest request,
CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(request.Name)) { return BadRequest("Invalid secret name"); }
await deleteSecretHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
return port.ViewModel;
}
}
}

View File

@@ -0,0 +1,142 @@
using Asp.Versioning;
using Core.Blueprint.Application.UsesCases.Mongo.Input;
using Core.Blueprint.Application.UsesCases.Mongo.Ports;
using Lib.Architecture.BuildingBlocks;
using Microsoft.AspNetCore.Mvc;
namespace Core.Cerberos.Service.API.Controllers
{
/// <summary>
/// Handles all services and business rules related to <see cref="MongoBlueprintController"/>.
/// </summary>
[ApiVersion("1.0")]
[Route("api/v{api-version:apiVersion}/[controller]")]
[Produces("application/json")]
[ApiController]
public class MongoBlueprintController : ControllerBase
{
private readonly IComponentHandler<CreateBlueprintRequest> createBlueprintHandler;
private readonly IComponentHandler<GetAllBlueprintsRequest> getAllBlueprintsHandler;
private readonly IComponentHandler<GetBlueprintRequest> getBlueprintHandler;
private readonly IComponentHandler<UpdateBlueprintRequest> updateBlueprintHandler;
private readonly IComponentHandler<DeleteBlueprintRequest> deleteBlueprintHandler;
private readonly IMongoPort port;
/// <summary>
/// Handles all services and business rules related to <see cref="MongoBlueprintController"/>.
/// </summary>
public MongoBlueprintController(
IComponentHandler<GetBlueprintRequest> getBlueprintHandler,
IComponentHandler<GetAllBlueprintsRequest> getAllBlueprintsHandler,
IComponentHandler<CreateBlueprintRequest> createBlueprintHandler,
IComponentHandler<UpdateBlueprintRequest> updateBlueprintHandler,
IComponentHandler<DeleteBlueprintRequest> deleteBlueprintHandler,
IMongoPort port
)
{
this.createBlueprintHandler = createBlueprintHandler;
this.updateBlueprintHandler = updateBlueprintHandler;
this.deleteBlueprintHandler = deleteBlueprintHandler;
this.getAllBlueprintsHandler = getAllBlueprintsHandler;
this.getBlueprintHandler = getBlueprintHandler;
this.port = port;
}
/// <summary>
/// Creates a new blueprint.
/// </summary>
[HttpPost("Create")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> CreateBlueprintAsync([FromBody] CreateBlueprintRequest newBlueprint, CancellationToken cancellationToken = default)
{
await createBlueprintHandler.ExecuteAsync(newBlueprint, cancellationToken).ConfigureAwait(false);
return port.ViewModel;
}
/// <summary>
/// Gets all blueprints.
/// </summary>
[HttpGet("GetAll")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> GetAllBlueprintsAsync(CancellationToken cancellationToken)
{
await getAllBlueprintsHandler.ExecuteAsync(new GetAllBlueprintsRequest { }, cancellationToken).ConfigureAwait(false);
return port.ViewModel;
}
/// <summary>
/// Gets the blueprint by identifier.
/// </summary>
[HttpPost]
[Route("GetById")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> GetBlueprintById([FromBody] GetBlueprintRequest request, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid blueprint identifier"); }
await getBlueprintHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
return port.ViewModel;
}
/// <summary>
/// Updates a full blueprint by identifier.
/// </summary>
[HttpPut("Update")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> UpdateBlueprintAsync([FromBody] UpdateBlueprintRequest request, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid blueprint identifier"); }
await updateBlueprintHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
return port.ViewModel;
}
/// <summary>
/// Deletes a blueprint.
/// </summary>
[HttpDelete]
[Route("Delete")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> DeleteBlueprintAsync([FromBody] DeleteBlueprintRequest request,
CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid blueprint identifier"); }
await deleteBlueprintHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
return port.ViewModel;
}
}
}

View File

@@ -0,0 +1,142 @@
using Asp.Versioning;
using Core.Blueprint.Application.UsesCases.SQL.Input;
using Core.Blueprint.Application.UsesCases.SQL.Ports;
using Lib.Architecture.BuildingBlocks;
using Microsoft.AspNetCore.Mvc;
namespace Core.Cerberos.Service.API.Controllers
{
/// <summary>
/// Handles all services and business rules related to <see cref="SQLUserProjectController"/>.
/// </summary>
[ApiVersion("1.0")]
[Route("api/v{api-version:apiVersion}/[controller]")]
[Produces("application/json")]
[ApiController]
public class SQLUserProjectController : ControllerBase
{
private readonly IComponentHandler<CreateUserProjectRequest> createUserProjectHandler;
private readonly IComponentHandler<GetAllUserProjectsRequest> getAllUserProjectsHandler;
private readonly IComponentHandler<GetUserProjectRequest> getUserProjectHandler;
private readonly IComponentHandler<UpdateUserProjectRequest> updateUserProjectHandler;
private readonly IComponentHandler<DeleteUserProjectRequest> deleteUserProjectStatusHandler;
private readonly ISQLPort port;
/// <summary>
/// Handles all services and business rules related to <see cref="SQLUserProjectController"/>.
/// </summary>
public SQLUserProjectController(
IComponentHandler<GetUserProjectRequest> getUserProjectHandler,
IComponentHandler<GetAllUserProjectsRequest> getAllUserProjectsHandler,
IComponentHandler<CreateUserProjectRequest> createUserProjectHandler,
IComponentHandler<UpdateUserProjectRequest> updateUserProjectHandler,
IComponentHandler<DeleteUserProjectRequest> deleteUserProjectStatusHandler,
ISQLPort port
)
{
this.createUserProjectHandler = createUserProjectHandler;
this.updateUserProjectHandler = updateUserProjectHandler;
this.deleteUserProjectStatusHandler = deleteUserProjectStatusHandler;
this.getAllUserProjectsHandler = getAllUserProjectsHandler;
this.getUserProjectHandler = getUserProjectHandler;
this.port = port;
}
/// <summary>
/// Creates a new UserProject.
/// </summary>
[HttpPost("Create")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> CreateUserProjectAsync([FromBody] CreateUserProjectRequest newUserProject, CancellationToken cancellationToken = default)
{
await createUserProjectHandler.ExecuteAsync(newUserProject, cancellationToken).ConfigureAwait(false);
return port.ViewModel;
}
/// <summary>
/// Gets all UserProjects.
/// </summary>
[HttpGet("GetAll")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> GetAllUserProjectsAsync(CancellationToken cancellationToken)
{
await getAllUserProjectsHandler.ExecuteAsync(new GetAllUserProjectsRequest { }, cancellationToken).ConfigureAwait(false);
return port.ViewModel;
}
/// <summary>
/// Gets the UserProject by identifier.
/// </summary>
[HttpPost]
[Route("GetById")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> GetUserProjectById([FromBody] GetUserProjectRequest request, CancellationToken cancellationToken)
{
if (request.Id <= 0) { return BadRequest("Invalid UserProject identifier"); }
await getUserProjectHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
return port.ViewModel;
}
/// <summary>
/// Updates a full UserProject by identifier.
/// </summary>
[HttpPut("Update")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> UpdateUserProjectAsync([FromBody] UpdateUserProjectRequest request, CancellationToken cancellationToken = default)
{
if (request.Id <= 0) { return BadRequest("Invalid UserProject identifier"); }
await updateUserProjectHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
return port.ViewModel;
}
/// <summary>
/// Deletes a UserProject.
/// </summary>
[HttpDelete]
[Route("Delete")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> DeleteUserProjectStatusAsync([FromBody] DeleteUserProjectRequest request,
CancellationToken cancellationToken)
{
if (request.Id <= 0) { return BadRequest("Invalid UserProject identifier"); }
await deleteUserProjectStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
return port.ViewModel;
}
}
}

View File

@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<UserSecretsId>a776c24d-b2ab-4520-a66b-d1802fb016fb</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
<PackageReference Include="Core.Blueprint.Logging" Version="0.3.0-alpha0034" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.7" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="8.1.0-preview" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core.Blueprint.Application\Core.Blueprint.Application.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,6 @@
@Core.Blueprint.Service.API_HostAddress = http://localhost:5047
GET {{Core.Blueprint.Service.API_HostAddress}}/weatherforecast/
Accept: application/json
###

View File

@@ -0,0 +1,25 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Core.Blueprint.Service.API/Core.Blueprint.Service.API.csproj", "Core.Blueprint.Service.API/"]
RUN dotnet restore "./Core.Blueprint.Service.API/./Core.Blueprint.Service.API.csproj"
COPY . .
WORKDIR "/src/Core.Blueprint.Service.API"
RUN dotnet build "./Core.Blueprint.Service.API.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Core.Blueprint.Service.API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Core.Blueprint.Service.API.dll"]

View File

@@ -0,0 +1,111 @@
using Core.Blueprint.Application.UsesCases.BlobStorage.Adapter;
using Core.Blueprint.Application.UsesCases.BlobStorage.Ports;
using Core.Blueprint.Application.UsesCases.KeyVault.Input;
using Core.Blueprint.Application.UsesCases.KeyVault.Ports;
using Core.Blueprint.Application.UsesCases.Mongo.Input;
using Core.Blueprint.Application.UsesCases.Mongo.Ports;
using Core.Blueprint.Application.UsesCases.MongoStorage.Adapter;
using Core.Blueprint.Application.UsesCases.SQL.Adapter;
using Core.Blueprint.Application.UsesCases.SQL.Input;
using Core.Blueprint.Application.UsesCases.SQL.Ports;
using Core.Cerberos.Application.UseCases.Blueprints;
using Core.Cerberos.Application.UseCases.Blueprints.Validator;
using Core.Cerberos.Application.UseCases.KeyVault;
using Core.Cerberos.Application.UseCases.KeyVault.Validator;
using Core.Cerberos.Application.UseCases.SQL.Validator;
using Core.Cerberos.Application.UseCases.UserProjects;
using FluentValidation;
using Lib.Architecture.BuildingBlocks;
namespace Core.Blueprint.Service.API.Extensions
{
public static class ServiceCollectionExtension
{
public static IServiceCollection AddServiceConfigurationLayer(this IServiceCollection services)
{
#region Mongo Services
services.AddScoped<IMongoPort, MongoPort>();
services.AddValidatorsFromAssemblyContaining<CreateBlueprintValidator>();
services.AddScoped<IValidator<CreateBlueprintRequest>, CreateBlueprintValidator>();
services.AddScoped<IComponentHandler<CreateBlueprintRequest>, MongoHandler>();
services.AddScoped<IComponentHandler<GetAllBlueprintsRequest>, MongoHandler>();
services.AddValidatorsFromAssemblyContaining<GetBlueprintValidator>();
services.AddScoped<IValidator<GetBlueprintRequest>, GetBlueprintValidator>();
services.AddScoped<IComponentHandler<GetBlueprintRequest>, MongoHandler>();
services.AddValidatorsFromAssemblyContaining<UpdateBlueprintValidator>();
services.AddScoped<IValidator<UpdateBlueprintRequest>, UpdateBlueprintValidator>();
services.AddScoped<IComponentHandler<UpdateBlueprintRequest>, MongoHandler>();
services.AddValidatorsFromAssemblyContaining<DeleteBlueprintValidator>();
services.AddScoped<IValidator<DeleteBlueprintRequest>, DeleteBlueprintValidator>();
services.AddScoped<IComponentHandler<DeleteBlueprintRequest>, MongoHandler>();
#endregion
#region SQL Services
services.AddScoped<ISQLPort, SQLPort>();
services.AddValidatorsFromAssemblyContaining<CreateUserProjectValidator>();
services.AddScoped<IValidator<CreateUserProjectRequest>, CreateUserProjectValidator>();
services.AddScoped<IComponentHandler<CreateUserProjectRequest>, SQLHandler>();
services.AddScoped<IComponentHandler<GetAllUserProjectsRequest>, SQLHandler>();
services.AddValidatorsFromAssemblyContaining<GetUserProjectValidator>();
services.AddScoped<IValidator<GetUserProjectRequest>, GetUserProjectValidator>();
services.AddScoped<IComponentHandler<GetUserProjectRequest>, SQLHandler>();
services.AddValidatorsFromAssemblyContaining<UpdateUserProjectValidator>();
services.AddScoped<IValidator<UpdateUserProjectRequest>, UpdateUserProjectValidator>();
services.AddScoped<IComponentHandler<UpdateUserProjectRequest>, SQLHandler>();
services.AddValidatorsFromAssemblyContaining<DeleteUserProjectValidator>();
services.AddScoped<IValidator<DeleteUserProjectRequest>, DeleteUserProjectValidator>();
services.AddScoped<IComponentHandler<DeleteUserProjectRequest>, SQLHandler>();
#endregion
#region KeyVault Services
services.AddScoped<IKeyVaultPort, KeyVaultPort>();
services.AddValidatorsFromAssemblyContaining<CreateSecretValidator>();
services.AddScoped<IValidator<CreateSecretRequest>, CreateSecretValidator>();
services.AddScoped<IComponentHandler<CreateSecretRequest>, KeyVaultHandler>();
services.AddValidatorsFromAssemblyContaining<GetSecretValidator>();
services.AddScoped<IValidator<GetSecretRequest>, GetSecretValidator>();
services.AddScoped<IComponentHandler<GetSecretRequest>, KeyVaultHandler>();
services.AddValidatorsFromAssemblyContaining<UpdateSecretValidator>();
services.AddScoped<IValidator<UpdateSecretRequest>, UpdateSecretValidator>();
services.AddScoped<IComponentHandler<UpdateSecretRequest>, KeyVaultHandler>();
services.AddValidatorsFromAssemblyContaining<DeleteSecretValidator>();
services.AddScoped<IValidator<DeleteSecretRequest>, DeleteSecretValidator>();
services.AddScoped<IComponentHandler<DeleteSecretRequest>, KeyVaultHandler>();
#endregion
#region Storage Services
services.AddScoped<IStoragePort, StoragePort>();
services.AddValidatorsFromAssemblyContaining<UploadBlobValidator>();
services.AddScoped<IValidator<UploadBlobRequest>, UploadBlobValidator>();
services.AddScoped<IComponentHandler<UploadBlobRequest>, StorageHandler>();
services.AddScoped<IComponentHandler<GetBlobListRequest>, StorageHandler>();
services.AddValidatorsFromAssemblyContaining<DownloadBlobValidator>();
services.AddScoped<IValidator<DownloadBlobRequest>, DownloadBlobValidator>();
services.AddScoped<IComponentHandler<DownloadBlobRequest>, StorageHandler>();
services.AddValidatorsFromAssemblyContaining<DeleteBlobValidator>();
services.AddScoped<IValidator<DeleteBlobRequest>, DeleteBlobValidator>();
services.AddScoped<IComponentHandler<DeleteBlobRequest>, StorageHandler>();
#endregion
return services;
}
}
}

View File

@@ -0,0 +1,71 @@
using Asp.Versioning.ApiExplorer;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Any;
using Swashbuckle.AspNetCore.SwaggerGen;
using Swashbuckle.AspNetCore.SwaggerUI;
namespace Core.Blueprint.Service.API.Extensions
{
public static class SwaggerExtensions
{
public static void AddSwagger(this IServiceCollection services)
{
services.AddEndpointsApiExplorer();
services.AddSwaggerGen();
services.AddTransient<IConfigureOptions<SwaggerGenOptions>, ConfigureSwaggerOptions>();
}
public static void ConfigureSwagger(this WebApplication app)
{
app.UseSwagger();
app.UseSwaggerUI(options =>
{
foreach (var version in app.DescribeApiVersions().Select(version => version.GroupName))
options.SwaggerEndpoint($"/swagger/{version}/swagger.json", version);
options.DisplayRequestDuration();
options.EnableTryItOutByDefault();
options.DocExpansion(DocExpansion.None);
});
}
public static IServiceCollection AddVersioning(this IServiceCollection services)
{
services.AddApiVersioning(options => options.ReportApiVersions = true)
.AddApiExplorer(options =>
{
options.GroupNameFormat = "'v'VVV";
options.SubstituteApiVersionInUrl = true;
});
return services;
}
}
public class ConfigureSwaggerOptions : IConfigureOptions<SwaggerGenOptions>
{
private readonly IApiVersionDescriptionProvider _provider;
public ConfigureSwaggerOptions(IApiVersionDescriptionProvider provider)
{
_provider = provider;
}
public void Configure(SwaggerGenOptions options)
{
foreach (var description in _provider.ApiVersionDescriptions)
options.SwaggerDoc(description.GroupName, new()
{
Title = AppDomain.CurrentDomain.FriendlyName,
Version = description.ApiVersion.ToString()
});
//Map ALL Values Format TODO
options.MapType<DateOnly>(() => new()
{
Format = "date",
Example = new OpenApiString(DateOnly.MinValue.ToString())
});
options.CustomSchemaIds(type => type.ToString().Replace("+", "."));
}
}
}

View File

@@ -0,0 +1,98 @@
using Azure.Identity;
using Core.Blueprint.External.ClientConfiguration;
using Core.Blueprint.Logging.Configuration;
using Core.Blueprint.Service.API.Extensions;
using Microsoft.AspNetCore.HttpLogging;
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
using System.Reflection;
using System.Text.Json.Serialization;
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddAzureAppConfiguration(options =>
{
var endpoint = builder.Configuration.GetSection("Endpoints:AppConfigurationURI").Value;
if (string.IsNullOrEmpty(endpoint))
throw new ArgumentException("The app configuration is missing");
options.Connect(new Uri(endpoint), new DefaultAzureCredential())
.Select(KeyFilter.Any, "blueprint_service");
options.ConfigureKeyVault(keyVaultOptions =>
{
keyVaultOptions.SetCredential(new DefaultAzureCredential());
});
});
builder.Services.AddLogs(builder);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Configuration
.AddUserSecrets(Assembly.GetExecutingAssembly())
.AddEnvironmentVariables();
builder.Services.RegisterExternalLayer(builder.Configuration);
builder.Services.AddServiceConfigurationLayer();
builder.Services.AddResponseCompression();
builder.Services.AddProblemDetails();
builder.Services.AddMemoryCache();
builder.Host.ConfigureServices((context, services) =>
{
services.AddLogging();
services.AddControllers();
services.AddProblemDetails();
services.AddCors(options
=> options.AddDefaultPolicy(policyBuilder
=> policyBuilder
.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod()));
builder.Services.Configure<Microsoft.AspNetCore.Http.Json.JsonOptions>(options =>
{
options.SerializerOptions.Converters.Add(new JsonStringEnumConverter());
});
services
.AddEndpointsApiExplorer()
.AddVersioning()
.AddSwagger();
services.AddHealthChecks();
services.AddHttpLogging(options => options.LoggingFields = HttpLoggingFields.All);
builder.Services.AddOutputCache(options =>
{
options.AddBasePolicy(builder =>
builder.Expire(TimeSpan.FromSeconds(10)));
options.AddPolicy("Expire20", builder =>
builder.Expire(TimeSpan.FromSeconds(20)));
options.AddPolicy("Expire30", builder =>
builder.Expire(TimeSpan.FromSeconds(30)));
});
});
var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();
app.MapControllers();
app.UseCors();
app.ConfigureSwagger();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseResponseCompression();
app.UseOutputCache();
app.UseResponseCaching();
app.UseLogging(builder.Configuration);
app.MapHealthChecks("/health");
app.Run();

View File

@@ -0,0 +1,52 @@
{
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Local"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5047"
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Local"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7243;http://localhost:5047"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Local"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"environmentVariables": {
"ASPNETCORE_HTTPS_PORTS": "8081",
"ASPNETCORE_HTTP_PORTS": "8080"
},
"publishAllPorts": true,
"useSSL": true
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:13744",
"sslPort": 44338
}
}
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,12 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"LocalGateways": {
"BlueprintDAL": "https://localhost:7075/api"
}
}

View File

@@ -0,0 +1,12 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"Endpoints": {
"AppConfigurationURI": "https://sandbox-hci-usc-appcg.azconfig.io"
}
}