using PostFundManagement.Application.Abstractions.Services; using PostFundManagement.Application.Extensions; using PostFundManagement.Domain.Abstractions; using PostFundManagement.Domain.Entities; using PostFundManagement.Domain.Extensions; 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(StatusCodes.Status200OK) .Produces(StatusCodes.Status401Unauthorized) .Produces(StatusCodes.Status500InternalServerError) .WithTags(EndpointTags.Governance); } }