Updates for the api review (#5861)
* update nemaspace usage * updated based on PR comments
This commit is contained in:
parent
34c2441523
commit
20e3bd3ff4
@ -21,9 +21,20 @@
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
using namespace Azure::Security::KeyVault::Administration::Models;
|
||||
|
||||
namespace Azure { namespace Security { namespace KeyVault { namespace Administration {
|
||||
/**
|
||||
* @brief Define the options to create an SDK Keys client.
|
||||
*
|
||||
*/
|
||||
struct BackupClientOptions final : public Azure::Core::_internal::ClientOptions
|
||||
{
|
||||
/**
|
||||
* @brief Service Version used.
|
||||
*
|
||||
*/
|
||||
const std::string ApiVersion{"7.5"};
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Backup restore client.
|
||||
*
|
||||
@ -62,7 +73,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Administra
|
||||
*/
|
||||
Response<BackupOperation> FullBackup(
|
||||
Azure::Core::Url const& blobContainerUrl,
|
||||
SasTokenParameter const& sasToken,
|
||||
Models::SasTokenParameter const& sasToken,
|
||||
Core::Context const& context = {});
|
||||
|
||||
/**
|
||||
@ -72,7 +83,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Administra
|
||||
* @param context The context for the operation can be used for request cancellation.
|
||||
* @return Backup restore operation status.
|
||||
*/
|
||||
Response<BackupOperationStatus> FullBackupStatus(
|
||||
Response<Models::BackupOperationStatus> FullBackupStatus(
|
||||
std::string const& jobId = "",
|
||||
Core::Context const& context = {});
|
||||
|
||||
@ -91,7 +102,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Administra
|
||||
Response<BackupOperation> FullRestore(
|
||||
Azure::Core::Url const& blobContainerUrl,
|
||||
std::string folderToRestore,
|
||||
SasTokenParameter const& sasToken,
|
||||
Models::SasTokenParameter const& sasToken,
|
||||
Core::Context const& context = {});
|
||||
|
||||
/**
|
||||
@ -101,7 +112,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Administra
|
||||
* @param context The context for the operation can be used for request cancellation.
|
||||
* @return A backup restore operation status.
|
||||
*/
|
||||
Response<BackupOperationStatus> RestoreStatus(
|
||||
Response<Models::BackupOperationStatus> RestoreStatus(
|
||||
std::string const& jobId = "",
|
||||
Core::Context const& context = {});
|
||||
|
||||
@ -122,16 +133,16 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Administra
|
||||
std::string const& keyName,
|
||||
Azure::Core::Url const& blobContainerUrl,
|
||||
std::string folderToRestore,
|
||||
SasTokenParameter const& sasToken,
|
||||
Models::SasTokenParameter const& sasToken,
|
||||
Core::Context const& context = {});
|
||||
|
||||
private:
|
||||
std::shared_ptr<Core::Http::_internal::HttpPipeline> m_pipeline;
|
||||
Azure::Core::Url m_vaultBaseUrl;
|
||||
std::string m_apiVersion;
|
||||
KeyVaultServiceError DeserializeKeyVaultServiceError(
|
||||
Models::KeyVaultServiceError DeserializeKeyVaultServiceError(
|
||||
Azure::Core::Json::_internal::json errorFragment);
|
||||
BackupOperationStatus DeserializeBackupOperationStatus(
|
||||
Models::BackupOperationStatus DeserializeBackupOperationStatus(
|
||||
Azure::Core::Http::RawResponse const& rawResponse);
|
||||
};
|
||||
|
||||
|
||||
@ -16,8 +16,6 @@
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
using namespace Azure::Security::KeyVault::Administration::Models;
|
||||
|
||||
namespace Azure { namespace Security { namespace KeyVault { namespace Administration {
|
||||
class BackupClient;
|
||||
|
||||
@ -26,21 +24,21 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Administra
|
||||
* @remark Used to handle both backup and restore operations due to the similarity in patterns
|
||||
* and return values.
|
||||
*/
|
||||
class BackupOperation final : public Azure::Core::Operation<BackupOperationStatus> {
|
||||
class BackupOperation final : public Azure::Core::Operation<Models::BackupOperationStatus> {
|
||||
private:
|
||||
/* BackupOperation can be constructed only by friends classes (internal
|
||||
* creation). The constructor is private and requires internal components.*/
|
||||
friend class Azure::Security::KeyVault::Administration::BackupClient;
|
||||
|
||||
std::shared_ptr<BackupClient> m_backupClient;
|
||||
BackupOperationStatus m_value;
|
||||
Models::BackupOperationStatus m_value;
|
||||
std::string m_continuationToken;
|
||||
bool m_isBackupOperation = true;
|
||||
|
||||
std::unique_ptr<Azure::Core::Http::RawResponse> PollInternal(
|
||||
Azure::Core::Context const& context) override;
|
||||
|
||||
Azure::Response<BackupOperationStatus> PollUntilDoneInternal(
|
||||
Azure::Response<Models::BackupOperationStatus> PollUntilDoneInternal(
|
||||
std::chrono::milliseconds period,
|
||||
Azure::Core::Context& context) override;
|
||||
|
||||
@ -55,7 +53,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Administra
|
||||
*/
|
||||
BackupOperation(
|
||||
std::shared_ptr<BackupClient> const& backupClient,
|
||||
BackupOperationStatus const& status,
|
||||
Models::BackupOperationStatus const& status,
|
||||
bool isBackupOperation)
|
||||
: m_backupClient{backupClient}, m_value{status}, m_continuationToken{status.JobId},
|
||||
m_isBackupOperation{isBackupOperation} {};
|
||||
@ -82,7 +80,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Administra
|
||||
*
|
||||
* @return A BackupOperationStatus object.
|
||||
*/
|
||||
BackupOperationStatus Value() const override { return m_value; }
|
||||
Models::BackupOperationStatus Value() const override { return m_value; }
|
||||
|
||||
/**
|
||||
* @brief Get the continuation token used for further status inquiries
|
||||
|
||||
@ -74,19 +74,6 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Administra
|
||||
std::vector<Setting> Value;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Define the options to create an SDK Keys client.
|
||||
*
|
||||
*/
|
||||
struct BackupClientOptions final : public Azure::Core::_internal::ClientOptions
|
||||
{
|
||||
/**
|
||||
* @brief Service Version used.
|
||||
*
|
||||
*/
|
||||
const std::string ApiVersion{"7.5"};
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief KeyVault Service Error model.
|
||||
*
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace Azure::Security::KeyVault::Administration;
|
||||
using namespace Azure::Security::KeyVault::Administration::Models;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
int main()
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
#include <thread>
|
||||
|
||||
using namespace Azure::Security::KeyVault::Administration;
|
||||
using namespace Azure::Security::KeyVault::Administration::Models;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
int main()
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
#include <thread>
|
||||
|
||||
using namespace Azure::Security::KeyVault::Administration;
|
||||
using namespace Azure::Security::KeyVault::Administration::Models;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
int main()
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#include <utility>
|
||||
|
||||
using namespace Azure::Security::KeyVault::Administration;
|
||||
using namespace Azure::Security::KeyVault::Administration::Models;
|
||||
using namespace Azure::Core::Http;
|
||||
using namespace Azure::Core::Http::Policies;
|
||||
using namespace Azure::Core::Http::Policies::_internal;
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "azure/keyvault/administration/backup_client.hpp"
|
||||
|
||||
using namespace Azure::Security::KeyVault::Administration;
|
||||
using namespace Azure::Security::KeyVault::Administration::Models;
|
||||
|
||||
std::unique_ptr<Azure::Core::Http::RawResponse> BackupOperation::PollInternal(
|
||||
Azure::Core::Context const& context)
|
||||
|
||||
@ -32,13 +32,13 @@ namespace Azure {
|
||||
BackupClientOptions options;
|
||||
m_client = InitTestClient<
|
||||
Azure::Security::KeyVault::Administration::BackupClient,
|
||||
Azure::Security::KeyVault::Administration::Models::BackupClientOptions>(
|
||||
BackupClientOptions>(
|
||||
hsmUrl.length() == 0 ? m_keyVaultHsmUrl : hsmUrl, m_credential, options);
|
||||
}
|
||||
|
||||
SasTokenParameter GetSasTokenBackup(bool managedIdentity = false)
|
||||
Models::SasTokenParameter GetSasTokenBackup(bool managedIdentity = false)
|
||||
{
|
||||
SasTokenParameter sasTokenParameter;
|
||||
Models::SasTokenParameter sasTokenParameter;
|
||||
// the backup/restore needs a SAS token to access the storage account
|
||||
sasTokenParameter.Token = GetEnv("AZURE_KEYVAULT_BACKUP_TOKEN");
|
||||
// the backup/restore needs a url to a blob storage resource
|
||||
@ -90,8 +90,7 @@ namespace Azure {
|
||||
// `InitTestClient` takes care of setting up Record&Playback.
|
||||
m_client = InitTestClient<
|
||||
Azure::Security::KeyVault::Administration::BackupClient,
|
||||
Azure::Security::KeyVault::Administration::Models::BackupClientOptions>(
|
||||
m_keyVaultUrl, m_credential, options);
|
||||
BackupClientOptions>(m_keyVaultUrl, m_credential, options);
|
||||
|
||||
UpdateWaitingTime(m_testPollingIntervalMs);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user