45 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| 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<IActionResult> CreateSecret([FromBody] KeyVaultRequest newSecret, CancellationToken cancellationToken)
 | |
|         {
 | |
|             var result = await service.CreateSecretAsync(newSecret, cancellationToken);
 | |
|             return Ok(result);
 | |
|         }
 | |
| 
 | |
|         [HttpGet("{secretName}/GetSecret")]
 | |
|         public async Task<IActionResult> GetSecret([FromRoute] string secretName, CancellationToken cancellationToken)
 | |
|         {
 | |
|             var result = await service.GetSecretAsync(secretName, cancellationToken);
 | |
|             return Ok(result);
 | |
|         }
 | |
| 
 | |
|         [HttpPut("UpdateSecret")]
 | |
|         public async Task<IActionResult> UpdateSecret([FromBody] KeyVaultRequest newSecret, CancellationToken cancellationToken)
 | |
|         {
 | |
|             var result = await service.UpdateSecretAsync(newSecret, cancellationToken);
 | |
|             return Ok(result);
 | |
|         }
 | |
| 
 | |
|         [HttpDelete("{secretName}/DeleteSecret")]
 | |
|         public async Task<IActionResult> DeleteSecret([FromRoute] string secretName, CancellationToken cancellationToken)
 | |
|         {
 | |
|             var result = await service.DeleteSecretAsync(secretName, cancellationToken);
 | |
|             return Ok(result);
 | |
|         }
 | |
|     }
 | |
| }
 | 
