33 lines
1.4 KiB
C#
33 lines
1.4 KiB
C#
using PostFundManagement.Application.Abstractions.Services;
|
|
using PostFundManagement.Application.Extensions;
|
|
using PostFundManagement.Domain.Abstractions;
|
|
using PostFundManagement.Domain.Entities;
|
|
using PostFundManagement.Domain.Extensions;
|
|
using PostFundManagement.Domain.Security;
|
|
using Problems = Microsoft.AspNetCore.Mvc.ProblemDetails;
|
|
|
|
namespace PostFundManagement.Api.Endpoints.Governance;
|
|
|
|
[ApiVersionTarget(1)]
|
|
public sealed class GetTenantsEndpoint : IEndpoint
|
|
{
|
|
public void Map(IEndpointRouteBuilder builder)
|
|
{
|
|
builder.MapGet("api/governance/tenants", async (IGovernanceService service,
|
|
CancellationToken cancellationToken = default) =>
|
|
await service.GetTenantsAsync(cancellationToken) switch
|
|
{
|
|
{ IsSuccess: true, Value: var tenants } => Results.Ok(tenants),
|
|
var r => Results.InternalServerError(r.Errors.ToProblems())
|
|
})
|
|
.WithDescription("Gets system tenants")
|
|
.RequireAuthorization(Constants.MainScope)
|
|
.WithName(typeof(GetTenantsEndpoint).ToEndpointName("Retrieval"))
|
|
.MapToApiVersion(new ApiVersion(1))
|
|
.Produces<Tenant[]>(StatusCodes.Status200OK)
|
|
.Produces(StatusCodes.Status401Unauthorized)
|
|
.Produces<Problems>(StatusCodes.Status500InternalServerError)
|
|
.WithTags(EndpointTags.Governance);
|
|
}
|
|
}
|