Core.BluePrint.Packages/Core.Blueprint.KeyVault/Contracts/IKeyVaultProvider.cs
2025-07-20 20:42:52 -06:00

49 lines
2.6 KiB
C#

namespace Core.Blueprint.KeyVault
{
/// <summary>
/// Interface for managing secrets in Azure Key Vault.
/// </summary>
public interface IKeyVaultProvider
{
/// <summary>
/// Creates a new secret in Azure Key Vault.
/// </summary>
/// <param name="keyVaultRequest">The request containing the name and value of the secret.</param>
/// <param name="cancellationToken">The cancellation token to cancel the operation.</param>
/// <returns>A <see cref="KeyVaultResponse"/> containing the details of the created secret.</returns>
ValueTask<KeyVaultResponse> CreateSecretAsync(KeyVaultRequest keyVaultRequest, CancellationToken cancellationToken);
/// <summary>
/// Deletes a secret from Azure Key Vault if it exists.
/// </summary>
/// <param name="secretName">The name of the secret to delete.</param>
/// <param name="cancellationToken">The cancellation token to cancel the operation.</param>
/// <returns>
/// A <see cref="Tuple"/> containing a status message and a boolean indicating whether the secret was successfully deleted.
/// </returns>
ValueTask<(string Message, bool Deleted)> DeleteSecretAsync(string secretName, CancellationToken cancellationToken);
/// <summary>
/// Retrieves a secret from Azure Key Vault.
/// </summary>
/// <param name="secretName">The name of the secret to retrieve.</param>
/// <param name="cancellationToken">The cancellation token to cancel the operation.</param>
/// <returns>
/// A <see cref="Tuple"/> containing the <see cref="KeyVaultResponse"/> with secret details
/// and an optional error message if the secret was not found.
/// </returns>
ValueTask<(KeyVaultResponse Secret, string? Message)> GetSecretAsync(string secretName, CancellationToken cancellationToken);
/// <summary>
/// Updates an existing secret in Azure Key Vault. If the secret does not exist, an error is returned.
/// </summary>
/// <param name="newSecret">The updated secret information.</param>
/// <param name="cancellationToken">The cancellation token to cancel the operation.</param>
/// <returns>
/// A <see cref="Tuple"/> containing the updated <see cref="KeyVaultResponse"/> and an optional error message if the secret was not found.
/// </returns>
ValueTask<(KeyVaultResponse Secret, string? Message)> UpdateSecretAsync(KeyVaultRequest newSecret, CancellationToken cancellationToken);
}
}