PurgeDeletedSecret (#2696)

* working

* comment
This commit is contained in:
George Arama 2021-08-05 10:26:57 -07:00 committed by GitHub
parent 87b8a6146b
commit 697f45a454
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 2 deletions

View File

@ -101,6 +101,15 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Secrets {
*/
std::string Version;
};
/**
* @brief Define a model for a purged key.
*
*/
struct PurgedSecret final
{
};
/**
* @brief The SecretClient provides synchronous methods to manage a secret in the Azure Key
* Vault. The client supports creating, retrieving, updating, deleting, purging, backing up,
@ -265,6 +274,21 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Secrets {
Azure::Response<KeyVaultSecret> RestoreSecretBackup(
std::vector<uint8_t> const& backup,
Azure::Core::Context const& context = Azure::Core::Context()) const;
/**
* @brief Permanently deletes the specified secret.
* The purge deleted secret operation removes the secret permanently, without the possibility of
* recovery. This operation can only be enabled on a soft-delete enabled vault. This operation
* requires the secrets/purge permission.
*
* @param name The name of the secret<span class="x x-first x-last">.</span>
* @param context The context for the operation can be used for request cancellation.
*
* @return Response<PurgedSecret> is success.
*/
Azure::Response<PurgedSecret> PurgeDeletedSecret(
std::string const& name,
Azure::Core::Context const& context = Azure::Core::Context()) const;
};
}}}} // namespace Azure::Security::KeyVault::Secrets

View File

@ -164,3 +164,14 @@ Azure::Response<KeyVaultSecret> SecretClient::RestoreSecretBackup(
},
{_detail::SecretPath, _detail::RestoreSecretPath});
}
Azure::Response<PurgedSecret> SecretClient::PurgeDeletedSecret(
std::string const& name,
Azure::Core::Context const& context) const
{
return m_protocolClient->SendRequest<PurgedSecret>(
context,
Azure::Core::Http::HttpMethod::Delete,
[](Azure::Core::Http::RawResponse const&) { return PurgedSecret(); },
{_detail::DeletedSecretPath, name});
}

View File

@ -29,7 +29,10 @@ int main()
// just a response, with a secret
// auto response3 = secretClient.GetDeletedSecret("someSecret");
auto response4 = secretClient.BackupSecret("someSecret2");
auto response5 = secretClient.RestoreSecretBackup(response4.Value.Secret);
// auto response4 = secretClient.BackupSecret("someSecret2");
// auto response5 = secretClient.RestoreSecretBackup(response4.Value.Secret);
auto response = secretClient.PurgeDeletedSecret("someSecret3");
return 0;
}