using Asp.Versioning; using Core.Blueprint.DAL.KeyVault.Contracts; using Core.Blueprint.KeyVault; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Core.Blueprint.DAL.API.Controllers { [ApiVersion("1.0")] [Route("api/v{api-version:apiVersion}/[controller]")] [Produces("application/json")] [ApiController] [AllowAnonymous] public class KeyVaultController(IKeyVaultService service) : ControllerBase { [HttpPost("CreateSecret")] public async Task CreateSecret([FromBody] KeyVaultRequest newSecret, CancellationToken cancellationToken) { var result = await service.CreateSecretAsync(newSecret, cancellationToken); return Ok(result); } [HttpGet("{secretName}/GetSecret")] public async Task GetSecret([FromRoute] string secretName, CancellationToken cancellationToken) { var result = await service.GetSecretAsync(secretName, cancellationToken); return Ok(result); } [HttpPut("UpdateSecret")] public async Task UpdateSecret([FromBody] KeyVaultRequest newSecret, CancellationToken cancellationToken) { var result = await service.UpdateSecretAsync(newSecret, cancellationToken); return Ok(result); } [HttpDelete("{secretName}/DeleteSecret")] public async Task DeleteSecret([FromRoute] string secretName, CancellationToken cancellationToken) { var result = await service.DeleteSecretAsync(secretName, cancellationToken); return Ok(result); } } }