using System.ComponentModel.DataAnnotations;
using Asp.Versioning;
using Baya.Application.Features.System.Queries.Ping;
using Baya.WebFramework.Attributes;
using Baya.WebFramework.BaseController;
using Mediator;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.RateLimiting;
using Baya.WebFramework.ServiceConfiguration;

namespace Baya.Web.Api.Controllers.V1;

[ApiVersion("1")]
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[Display(Description = "Service liveness and pipeline-smoke endpoints")]
public sealed class PingController(ISender sender) : BaseController
{
    [HttpGet("[action]")]
    [ProducesOkApiResponseType<PingQueryResult>]
    public async Task<IActionResult> GetStatus(CancellationToken cancellationToken)
        => OperationResult(await sender.Send(new PingQuery(), cancellationToken));

    [HttpGet("[action]")]
    [EnableRateLimiting(RateLimitingServiceExtension.GlobalPolicy)]
    [ProducesOkApiResponseType<PingQueryResult>]
    public async Task<IActionResult> GetStatusRateLimited(CancellationToken cancellationToken)
        => OperationResult(await sender.Send(new PingQuery(), cancellationToken));
}
