Rename paged models from key vault (#2160)
rename pageable APIs and models from keyvault
This commit is contained in:
parent
c1b958a598
commit
c82f0e8efc
@ -13,7 +13,7 @@
|
||||
#include <string>
|
||||
|
||||
namespace Azure { namespace Security { namespace KeyVault { namespace _internal {
|
||||
struct GetSinglePageOptions
|
||||
struct GetPageResultOptions
|
||||
{
|
||||
Azure::Nullable<std::string> NextPageToken;
|
||||
Azure::Nullable<uint32_t> MaxPageResults;
|
||||
|
||||
@ -8,13 +8,21 @@
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- Renamed `GetPropertiesOfKeysSinglePage()` to `GetPropertiesOfKeys()`.
|
||||
- Renamed `GetPropertiesOfKeyVersionsSinglePage()` to `GetPropertiesOfKeyVersions()`.
|
||||
- Renamed `GetDeletedKeysSinglePage()` to `GetDeletedKeys()`.
|
||||
- Renamed `KeyPropertiesSinglePage` to `KeyPropertiesPageResult`.
|
||||
- Renamed `DeletedKeySinglePage` to `DeletedKeyPageResult`.
|
||||
- Renamed `GetPropertiesOfKeysSinglePageOptions` to `GetPropertiesOfKeysOptions`.
|
||||
- Renamed `GetPropertiesOfKeyVersionsSinglePageOptions` to `GetPropertiesOfKeyVersionsOptions`.
|
||||
- Renamed `GetDeletedKeysSinglePageOptions` to `GetDeletedKeysOptions`.
|
||||
- Removed `Azure::Security::KeyVault::Keys::JsonWebKey::to_json`.
|
||||
- Replaced static functions from `KeyOperation` and `KeyCurveName` with static const members.
|
||||
- Replaced the enum `JsonWebKeyType` for a class with static const members as an extensible enum called `KeyVaultKeyType`.
|
||||
- Renamed `MaxResults` to `MaxPageResults` for `GetSinglePageOptions`.
|
||||
- Changed the returned type for list keys, key versions, and deleted keys from `Response<T>` to `PagedResponse<T>` affecting:
|
||||
- `GetPropertiesOfKeysSinglePage()` and `GetPropertiesOfKeyVersionsSinglePage()` now returns `KeyPropertiesSinglePage`.
|
||||
- `GetDeletedKeysSinglePage()` now returns `DeletedKeySinglePage`.
|
||||
- `GetPropertiesOfKeysSinglePage()` and `GetPropertiesOfKeyVersionsSinglePage()` now returns `KeyProperties`.
|
||||
- `GetDeletedKeysSinglePage()` now returns `DeletedKey`.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
||||
@ -96,12 +96,12 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys { nam
|
||||
static std::string ImportKeyOptionsSerialize(ImportKeyOptions const& importKeyOptions);
|
||||
};
|
||||
|
||||
/**************** Key Properties Single Page ************/
|
||||
struct KeyPropertiesSinglePageSerializer
|
||||
/**************** Key Properties ************/
|
||||
struct KeyPropertiesPageResultSerializer
|
||||
{
|
||||
static KeyPropertiesSinglePage KeyPropertiesSinglePageDeserialize(
|
||||
static KeyPropertiesPageResult KeyPropertiesPageResultDeserialize(
|
||||
Azure::Core::Http::RawResponse const& rawResponse);
|
||||
static DeletedKeySinglePage DeletedKeySinglePageDeserialize(
|
||||
static DeletedKeyPageResult DeletedKeyPageResultDeserialize(
|
||||
Azure::Core::Http::RawResponse const& rawResponse);
|
||||
};
|
||||
|
||||
|
||||
@ -174,17 +174,16 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
|
||||
* are not listed in the response. This operation requires the keys/list permission.
|
||||
*
|
||||
* @remark Use \p options to control which page to get. If
|
||||
* #GetPropertiesOfKeysSinglePageOptions.NextLink is not set, the operation will get the first
|
||||
* page and it will set the `NextPageToken` from the #KeyPropertiesSinglePage as the next
|
||||
* #GetPropertiesOfKeysOptions.NextLink is not set, the operation will get the first
|
||||
* page and it will set the `NextPageToken` from the #KeyPropertiesPageResult as the next
|
||||
* page of the response if there is a next page.
|
||||
*
|
||||
* @param options The #GetPropertiesOfKeysSinglePageOptions object to for setting the operation
|
||||
* @param options The #GetPropertiesOfKeysOptions object to for setting the operation
|
||||
* up.
|
||||
* @param context A #Azure::Core::Context controlling the request lifetime.
|
||||
*/
|
||||
KeyPropertiesSinglePage GetPropertiesOfKeysSinglePage(
|
||||
GetPropertiesOfKeysSinglePageOptions const& options
|
||||
= GetPropertiesOfKeysSinglePageOptions(),
|
||||
KeyPropertiesPageResult GetPropertiesOfKeys(
|
||||
GetPropertiesOfKeysOptions const& options = GetPropertiesOfKeysOptions(),
|
||||
Azure::Core::Context const& context = Azure::Core::Context()) const;
|
||||
|
||||
/**
|
||||
@ -196,19 +195,18 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
|
||||
* operation requires the keys/list permission.
|
||||
*
|
||||
* @remark Use \p options to control which page to get. If
|
||||
* #GetPropertiesOfKeyVersionsSinglePageOptions.NextLink is not set, the operation will get the
|
||||
* first page and it will set the `NextPageToken` from the #KeyPropertiesSinglePage as the
|
||||
* #GetPropertiesOfKeyVersionsOptions.NextLink is not set, the operation will get the
|
||||
* first page and it will set the `NextPageToken` from the #KeyPropertiesPageResult as the
|
||||
* next page of the response if there is a next page.
|
||||
*
|
||||
* @param name The name of the key.
|
||||
* @param options The #GetPropertiesOfKeyVersionsSinglePageOptions object to for setting the
|
||||
* @param options The #GetPropertiesOfKeyVersionsOptions object to for setting the
|
||||
* operation up.
|
||||
* @param context A #Azure::Core::Context controlling the request lifetime.
|
||||
*/
|
||||
KeyPropertiesSinglePage GetPropertiesOfKeyVersionsSinglePage(
|
||||
KeyPropertiesPageResult GetPropertiesOfKeyVersions(
|
||||
std::string const& name,
|
||||
GetPropertiesOfKeyVersionsSinglePageOptions const& options
|
||||
= GetPropertiesOfKeyVersionsSinglePageOptions(),
|
||||
GetPropertiesOfKeyVersionsOptions const& options = GetPropertiesOfKeyVersionsOptions(),
|
||||
Azure::Core::Context const& context = Azure::Core::Context()) const;
|
||||
|
||||
/**
|
||||
@ -258,25 +256,25 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
|
||||
Azure::Core::Context const& context = Azure::Core::Context()) const;
|
||||
|
||||
/**
|
||||
* @brief Get on page listing the deleted keys in the specified vault.
|
||||
* @brief Get a page listing the deleted keys in the specified vault.
|
||||
*
|
||||
* @remark Retrieves a list of the keys in the Key Vault that contains the public part od the
|
||||
* @remark Retrieves the list of the keys in the Key Vault that contains the public part of the
|
||||
* deleted key. This operation includes deletion-specific information. This operation is
|
||||
* applicable for vaults enabled fr soft-delete. While the operation can be invoked on any
|
||||
* applicable for vaults enabled for soft-delete. While the operation can be invoked on any
|
||||
* vault, it will return error if invoked on a non soft-delete enabled vault. This operation
|
||||
* requires the keys/list permission.
|
||||
*
|
||||
* @remark Use \p options to control which page to get. If
|
||||
* #GetPropertiesOfKeyVersionsSinglePageOptions.NextPageToken is not set, the operation will get
|
||||
* the first page and it will set the `NextPageToken` from the #KeyPropertiesSinglePage as the
|
||||
* #GetPropertiesOfKeyVersionsOptions.NextPageToken is not set, the operation will get
|
||||
* the first page and it will set the `NextPageToken` from the #KeyPropertiesPageResult as the
|
||||
* next page of the response if there is a next page.
|
||||
*
|
||||
* @param options The #GetDeletedKeysSinglePageOptions object to for setting the operation up.
|
||||
* @param options The #GetDeletedKeysOptions object to for setting the operation up.
|
||||
* @param context A #Azure::Core::Context controlling the request lifetime.
|
||||
* @return Azure::Response<DeletedKeySinglePage>
|
||||
* @return Azure::Response<DeletedKeyPageResult>
|
||||
*/
|
||||
DeletedKeySinglePage GetDeletedKeysSinglePage(
|
||||
GetDeletedKeysSinglePageOptions const& options = GetDeletedKeysSinglePageOptions(),
|
||||
DeletedKeyPageResult GetDeletedKeys(
|
||||
GetDeletedKeysOptions const& options = GetDeletedKeysOptions(),
|
||||
Azure::Core::Context const& context = Azure::Core::Context()) const;
|
||||
|
||||
/**
|
||||
|
||||
@ -28,10 +28,10 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
|
||||
* @brief Define a single page to list the keys from the Key Vault.
|
||||
*
|
||||
*/
|
||||
class KeyPropertiesSinglePage : public Azure::Core::PagedResponse<KeyPropertiesSinglePage> {
|
||||
class KeyPropertiesPageResult : public Azure::Core::PagedResponse<KeyPropertiesPageResult> {
|
||||
private:
|
||||
friend class KeyClient;
|
||||
friend class Azure::Core::PagedResponse<KeyPropertiesSinglePage>;
|
||||
friend class Azure::Core::PagedResponse<KeyPropertiesPageResult>;
|
||||
|
||||
std::string m_keyName;
|
||||
std::shared_ptr<KeyClient> m_keyClient;
|
||||
@ -42,15 +42,15 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
|
||||
*
|
||||
* @remark The constructor is private and only a key client or PagedResponse can init this.
|
||||
*
|
||||
* @param keyProperties A previously created #KeyPropertiesSinglePage that is used to init this
|
||||
* @param keyProperties A previously created #KeyPropertiesPageResult that is used to init this
|
||||
* instance.
|
||||
* @param rawResponse The Http raw response from where the #KeyPropertiesSinglePage was parsed.
|
||||
* @param rawResponse The Http raw response from where the #KeyPropertiesPageResult was parsed.
|
||||
* @param keyClient A key client required for getting the next pages.
|
||||
* @param keyName When \p keyName is set, the response is listing key versions. Otherwise, the
|
||||
* response is for listing keys from the Key Vault.
|
||||
*/
|
||||
KeyPropertiesSinglePage(
|
||||
KeyPropertiesSinglePage&& keyProperties,
|
||||
KeyPropertiesPageResult(
|
||||
KeyPropertiesPageResult&& keyProperties,
|
||||
std::unique_ptr<Azure::Core::Http::RawResponse> rawResponse,
|
||||
std::shared_ptr<KeyClient> keyClient,
|
||||
std::string const& keyName = std::string())
|
||||
@ -64,7 +64,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
|
||||
* @brief Construct a new key properties object.
|
||||
*
|
||||
*/
|
||||
KeyPropertiesSinglePage() = default;
|
||||
KeyPropertiesPageResult() = default;
|
||||
|
||||
/**
|
||||
* @brief Each #KeyProperties represent a Key in the Key Vault.
|
||||
@ -77,10 +77,10 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
|
||||
* @brief Define a single page containing the deleted keys from the Key Vault.
|
||||
*
|
||||
*/
|
||||
class DeletedKeySinglePage : public Azure::Core::PagedResponse<DeletedKeySinglePage> {
|
||||
class DeletedKeyPageResult : public Azure::Core::PagedResponse<DeletedKeyPageResult> {
|
||||
private:
|
||||
friend class KeyClient;
|
||||
friend class Azure::Core::PagedResponse<DeletedKeySinglePage>;
|
||||
friend class Azure::Core::PagedResponse<DeletedKeyPageResult>;
|
||||
|
||||
std::shared_ptr<KeyClient> m_keyClient;
|
||||
void OnNextPage(const Azure::Core::Context& context);
|
||||
@ -90,15 +90,15 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
|
||||
*
|
||||
* @remark The constructor is private and only a key client or PagedResponse can init this.
|
||||
*
|
||||
* @param deletedKeyProperties A previously created #DeletedKeySinglePage that is used to init
|
||||
* @param deletedKeyProperties A previously created #DeletedKeyPageResult that is used to init
|
||||
* this new instance.
|
||||
* @param rawResponse The Http raw response from where the #DeletedKeySinglePage was parsed.
|
||||
* @param rawResponse The Http raw response from where the #DeletedKeyPageResult was parsed.
|
||||
* @param keyClient A key client required for getting the next pages.
|
||||
* @param keyName When \p keyName is set, the response is listing key versions. Otherwise, the
|
||||
* response is for listing keys from the Key Vault.
|
||||
*/
|
||||
DeletedKeySinglePage(
|
||||
DeletedKeySinglePage&& deletedKeyProperties,
|
||||
DeletedKeyPageResult(
|
||||
DeletedKeyPageResult&& deletedKeyProperties,
|
||||
std::unique_ptr<Azure::Core::Http::RawResponse> rawResponse,
|
||||
std::shared_ptr<KeyClient> keyClient)
|
||||
: m_keyClient(keyClient), Items(std::move(deletedKeyProperties.Items))
|
||||
@ -111,7 +111,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
|
||||
* @brief Construct a new Deleted Key Single Page object
|
||||
*
|
||||
*/
|
||||
DeletedKeySinglePage() = default;
|
||||
DeletedKeyPageResult() = default;
|
||||
|
||||
/**
|
||||
* @brief Each #DeletedKey represent a deleted key in the Key Vault.
|
||||
@ -121,29 +121,28 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The options for calling an operation #GetPropertiesOfKeysSinglePage.
|
||||
* @brief The options for calling an operation #GetPropertiesOfKeys.
|
||||
*
|
||||
*/
|
||||
struct GetPropertiesOfKeysSinglePageOptions
|
||||
: public Azure::Security::KeyVault::_internal::GetSinglePageOptions
|
||||
struct GetPropertiesOfKeysOptions
|
||||
: public Azure::Security::KeyVault::_internal::GetPageResultOptions
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The options for calling an operation #GetPropertiesOfKeyVersionsSinglePage.
|
||||
* @brief The options for calling an operation #GetPropertiesOfKeyVersions.
|
||||
*
|
||||
*/
|
||||
struct GetPropertiesOfKeyVersionsSinglePageOptions
|
||||
: public Azure::Security::KeyVault::_internal::GetSinglePageOptions
|
||||
struct GetPropertiesOfKeyVersionsOptions
|
||||
: public Azure::Security::KeyVault::_internal::GetPageResultOptions
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The options for calling an operation #GetDeletedKeysSinglePage.
|
||||
* @brief The options for calling an operation #GetDeletedKeys.
|
||||
*
|
||||
*/
|
||||
struct GetDeletedKeysSinglePageOptions
|
||||
: public Azure::Security::KeyVault::_internal::GetSinglePageOptions
|
||||
struct GetDeletedKeysOptions : public Azure::Security::KeyVault::_internal::GetPageResultOptions
|
||||
{
|
||||
};
|
||||
}}}} // namespace Azure::Security::KeyVault::Keys
|
||||
|
||||
@ -51,9 +51,9 @@ Let's list the keys and print their types. List operations don't return the actu
|
||||
So, for each returned key we call GetKey to get the actual key.
|
||||
|
||||
```cpp Snippet:KeysSample3ListKeys
|
||||
for (auto keysSinglePage = keyClient.GetPropertiesOfKeysSinglePage().ExtractValue();;)
|
||||
for (auto keys = keyClient.GetPropertiesOfKeys().ExtractValue();;)
|
||||
{
|
||||
for (auto const& key : keysSinglePage.Items)
|
||||
for (auto const& key : keys.Items)
|
||||
{
|
||||
if (key.Managed)
|
||||
{
|
||||
@ -65,16 +65,16 @@ for (auto keysSinglePage = keyClient.GetPropertiesOfKeysSinglePage().ExtractValu
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
if (!keysSinglePage.ContinuationToken.HasValue())
|
||||
if (!keys.ContinuationToken.HasValue())
|
||||
{
|
||||
// No more pages for the response, break the loop
|
||||
break;
|
||||
}
|
||||
|
||||
// Get the next page
|
||||
GetPropertiesOfKeysSinglePageOptions options;
|
||||
options.ContinuationToken = keysSinglePage.ContinuationToken.GetValue();
|
||||
keysSinglePage = keyClient.GetPropertiesOfKeysSinglePage(options).ExtractValue();
|
||||
GetPropertiesOfKeysOptions options;
|
||||
options.ContinuationToken = keys.ContinuationToken.GetValue();
|
||||
keys = keyClient.GetPropertiesOfKeys(options).ExtractValue();
|
||||
}
|
||||
```
|
||||
|
||||
@ -97,26 +97,26 @@ You need to check all the different versions cloud RSA key had previously.
|
||||
Lets print all the versions of this key.
|
||||
|
||||
```cpp Snippet:KeysSample3ListKeyVersions
|
||||
for (auto keyVersionsSinglePage
|
||||
= keyClient.GetPropertiesOfKeyVersionsSinglePage(rsaKeyName).ExtractValue();
|
||||
for (auto keyVersions
|
||||
= keyClient.GetPropertiesOfKeyVersions(rsaKeyName).ExtractValue();
|
||||
;)
|
||||
{
|
||||
for (auto const& key : keyVersionsSinglePage.Items)
|
||||
for (auto const& key : keyVersions.Items)
|
||||
{
|
||||
std::cout << "Key's version: " << key.Version << " with name: " << key.Name << std::endl;
|
||||
}
|
||||
|
||||
if (!keyVersionsSinglePage.ContinuationToken.HasValue())
|
||||
if (!keyVersions.ContinuationToken.HasValue())
|
||||
{
|
||||
// No more pages for the response, break the loop
|
||||
break;
|
||||
}
|
||||
|
||||
// Get the next page
|
||||
GetPropertiesOfKeyVersionsSinglePageOptions options;
|
||||
options.ContinuationToken = keyVersionsSinglePage.ContinuationToken.GetValue();
|
||||
keyVersionsSinglePage
|
||||
= keyClient.GetPropertiesOfKeyVersionsSinglePage(rsaKeyName, options).ExtractValue();
|
||||
GetPropertiesOfKeyVersionsOptions options;
|
||||
options.ContinuationToken = keyVersions.ContinuationToken.GetValue();
|
||||
keyVersions
|
||||
= keyClient.GetPropertiesOfKeyVersions(rsaKeyName, options).ExtractValue();
|
||||
}
|
||||
```
|
||||
|
||||
@ -140,7 +140,7 @@ You can list all the deleted and non-purged keys, assuming Azure Key Vault is so
|
||||
|
||||
```cpp Snippet:KeysSample3ListDeletedKeys
|
||||
nextPage = true;
|
||||
for (auto keysDeletedPage = keyClient.GetDeletedKeysSinglePage().ExtractValue();;)
|
||||
for (auto keysDeletedPage = keyClient.GetDeletedKeys().ExtractValue();;)
|
||||
{
|
||||
for (auto const& key : keysDeletedPage.Items)
|
||||
{
|
||||
@ -156,9 +156,9 @@ for (auto keysDeletedPage = keyClient.GetDeletedKeysSinglePage().ExtractValue();
|
||||
}
|
||||
|
||||
// Get the next page
|
||||
GetDeletedKeysSinglePageOptions options;
|
||||
GetDeletedKeysOptions options;
|
||||
options.ContinuationToken = keysDeletedPage.ContinuationToken.GetValue();
|
||||
keysDeletedPage = keyClient.GetDeletedKeysSinglePage(options).ExtractValue();
|
||||
keysDeletedPage = keyClient.GetDeletedKeys(options).ExtractValue();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ struct RequestWithContinuationToken
|
||||
};
|
||||
|
||||
static inline RequestWithContinuationToken BuildRequestFromContinuationToken(
|
||||
Azure::Security::KeyVault::_internal::GetSinglePageOptions const& options,
|
||||
Azure::Security::KeyVault::_internal::GetPageResultOptions const& options,
|
||||
std::vector<std::string>&& defaultPath)
|
||||
{
|
||||
RequestWithContinuationToken request;
|
||||
@ -155,45 +155,45 @@ Azure::Response<KeyVaultKey> KeyClient::CreateOctKey(
|
||||
{_detail::KeysPath, keyName, "create"});
|
||||
}
|
||||
|
||||
KeyPropertiesSinglePage KeyClient::GetPropertiesOfKeysSinglePage(
|
||||
GetPropertiesOfKeysSinglePageOptions const& options,
|
||||
KeyPropertiesPageResult KeyClient::GetPropertiesOfKeys(
|
||||
GetPropertiesOfKeysOptions const& options,
|
||||
Azure::Core::Context const& context) const
|
||||
{
|
||||
auto const request = BuildRequestFromContinuationToken(options, {_detail::KeysPath});
|
||||
auto response = m_pipeline->SendRequest<KeyPropertiesSinglePage>(
|
||||
auto response = m_pipeline->SendRequest<KeyPropertiesPageResult>(
|
||||
context,
|
||||
Azure::Core::Http::HttpMethod::Get,
|
||||
[](Azure::Core::Http::RawResponse const& rawResponse) {
|
||||
return _detail::KeyPropertiesSinglePageSerializer::KeyPropertiesSinglePageDeserialize(
|
||||
return _detail::KeyPropertiesPageResultSerializer::KeyPropertiesPageResultDeserialize(
|
||||
rawResponse);
|
||||
},
|
||||
request.Path,
|
||||
request.Query);
|
||||
|
||||
return KeyPropertiesSinglePage(
|
||||
return KeyPropertiesPageResult(
|
||||
std::move(response.Value),
|
||||
std::move(response.RawResponse),
|
||||
std::make_unique<KeyClient>(*this));
|
||||
}
|
||||
|
||||
KeyPropertiesSinglePage KeyClient::GetPropertiesOfKeyVersionsSinglePage(
|
||||
KeyPropertiesPageResult KeyClient::GetPropertiesOfKeyVersions(
|
||||
std::string const& name,
|
||||
GetPropertiesOfKeyVersionsSinglePageOptions const& options,
|
||||
GetPropertiesOfKeyVersionsOptions const& options,
|
||||
Azure::Core::Context const& context) const
|
||||
{
|
||||
auto const request
|
||||
= BuildRequestFromContinuationToken(options, {_detail::KeysPath, name, "versions"});
|
||||
auto response = m_pipeline->SendRequest<KeyPropertiesSinglePage>(
|
||||
auto response = m_pipeline->SendRequest<KeyPropertiesPageResult>(
|
||||
context,
|
||||
Azure::Core::Http::HttpMethod::Get,
|
||||
[](Azure::Core::Http::RawResponse const& rawResponse) {
|
||||
return _detail::KeyPropertiesSinglePageSerializer::KeyPropertiesSinglePageDeserialize(
|
||||
return _detail::KeyPropertiesPageResultSerializer::KeyPropertiesPageResultDeserialize(
|
||||
rawResponse);
|
||||
},
|
||||
request.Path,
|
||||
request.Query);
|
||||
|
||||
return KeyPropertiesSinglePage(
|
||||
return KeyPropertiesPageResult(
|
||||
std::move(response.Value),
|
||||
std::move(response.RawResponse),
|
||||
std::make_unique<KeyClient>(*this),
|
||||
@ -265,22 +265,22 @@ Azure::Response<DeletedKey> KeyClient::GetDeletedKey(
|
||||
{_detail::DeletedKeysPath, name});
|
||||
}
|
||||
|
||||
DeletedKeySinglePage KeyClient::GetDeletedKeysSinglePage(
|
||||
GetDeletedKeysSinglePageOptions const& options,
|
||||
DeletedKeyPageResult KeyClient::GetDeletedKeys(
|
||||
GetDeletedKeysOptions const& options,
|
||||
Azure::Core::Context const& context) const
|
||||
{
|
||||
auto const request = BuildRequestFromContinuationToken(options, {_detail::DeletedKeysPath});
|
||||
auto response = m_pipeline->SendRequest<DeletedKeySinglePage>(
|
||||
auto response = m_pipeline->SendRequest<DeletedKeyPageResult>(
|
||||
context,
|
||||
Azure::Core::Http::HttpMethod::Get,
|
||||
[](Azure::Core::Http::RawResponse const& rawResponse) {
|
||||
return _detail::KeyPropertiesSinglePageSerializer::DeletedKeySinglePageDeserialize(
|
||||
return _detail::KeyPropertiesPageResultSerializer::DeletedKeyPageResultDeserialize(
|
||||
rawResponse);
|
||||
},
|
||||
request.Path,
|
||||
request.Query);
|
||||
|
||||
return DeletedKeySinglePage(
|
||||
return DeletedKeyPageResult(
|
||||
std::move(response.Value),
|
||||
std::move(response.RawResponse),
|
||||
std::make_unique<KeyClient>(*this));
|
||||
|
||||
@ -17,11 +17,11 @@ using namespace Azure::Security::KeyVault::Keys;
|
||||
using namespace Azure::Core::Json::_internal;
|
||||
using Azure::Security::KeyVault::_internal::UnixTimeConverter;
|
||||
|
||||
KeyPropertiesSinglePage
|
||||
_detail::KeyPropertiesSinglePageSerializer::KeyPropertiesSinglePageDeserialize(
|
||||
KeyPropertiesPageResult
|
||||
_detail::KeyPropertiesPageResultSerializer::KeyPropertiesPageResultDeserialize(
|
||||
Azure::Core::Http::RawResponse const& rawResponse)
|
||||
{
|
||||
KeyPropertiesSinglePage result;
|
||||
KeyPropertiesPageResult result;
|
||||
auto const& body = rawResponse.GetBody();
|
||||
auto jsonParser = json::parse(body);
|
||||
|
||||
@ -84,15 +84,15 @@ _detail::KeyPropertiesSinglePageSerializer::KeyPropertiesSinglePageDeserialize(
|
||||
return result;
|
||||
}
|
||||
|
||||
DeletedKeySinglePage _detail::KeyPropertiesSinglePageSerializer::DeletedKeySinglePageDeserialize(
|
||||
DeletedKeyPageResult _detail::KeyPropertiesPageResultSerializer::DeletedKeyPageResultDeserialize(
|
||||
Azure::Core::Http::RawResponse const& rawResponse)
|
||||
{
|
||||
auto const& body = rawResponse.GetBody();
|
||||
auto jsonParser = Azure::Core::Json::_internal::json::parse(body);
|
||||
|
||||
DeletedKeySinglePage deletedKeySinglePage;
|
||||
DeletedKeyPageResult deletedKeyPageResult;
|
||||
|
||||
JsonOptional::SetIfExists(deletedKeySinglePage.NextPageToken, jsonParser, "nextLink");
|
||||
JsonOptional::SetIfExists(deletedKeyPageResult.NextPageToken, jsonParser, "nextLink");
|
||||
|
||||
auto deletedKeys = jsonParser["value"];
|
||||
for (auto const& key : deletedKeys)
|
||||
@ -122,44 +122,44 @@ DeletedKeySinglePage _detail::KeyPropertiesSinglePageSerializer::DeletedKeySingl
|
||||
_detail::ScheduledPurgeDatePropertyName,
|
||||
UnixTimeConverter::UnixTimeToDatetime);
|
||||
|
||||
deletedKeySinglePage.Items.emplace_back(deletedKey);
|
||||
deletedKeyPageResult.Items.emplace_back(deletedKey);
|
||||
}
|
||||
|
||||
return deletedKeySinglePage;
|
||||
return deletedKeyPageResult;
|
||||
}
|
||||
|
||||
void DeletedKeySinglePage::OnNextPage(const Azure::Core::Context& context)
|
||||
void DeletedKeyPageResult::OnNextPage(const Azure::Core::Context& context)
|
||||
{
|
||||
// Before calling `OnNextPage` pagedResponse validates there is a next page, so we are sure
|
||||
// NextPageToken is valid.
|
||||
GetDeletedKeysSinglePageOptions options;
|
||||
GetDeletedKeysOptions options;
|
||||
options.NextPageToken = NextPageToken;
|
||||
*this = m_keyClient->GetDeletedKeysSinglePage(options, context);
|
||||
*this = m_keyClient->GetDeletedKeys(options, context);
|
||||
CurrentPageToken = options.NextPageToken.Value();
|
||||
}
|
||||
|
||||
void KeyPropertiesSinglePage::OnNextPage(const Azure::Core::Context& context)
|
||||
void KeyPropertiesPageResult::OnNextPage(const Azure::Core::Context& context)
|
||||
{
|
||||
// Notes
|
||||
// - Before calling `OnNextPage` pagedResponse validates there is a next page, so we are sure
|
||||
// NextPageToken is valid.
|
||||
// - KeyPropertiesSinglePage is used to list keys from a Key Vault and also to list the key
|
||||
// versions from a specific key. When KeyPropertiesSinglePage is listing keys, the `m_keyName`
|
||||
// fields will be empty, but for listing the key versions, the KeyPropertiesSinglePage needs to
|
||||
// - KeyPropertiesPageResult is used to list keys from a Key Vault and also to list the key
|
||||
// versions from a specific key. When KeyPropertiesPageResult is listing keys, the `m_keyName`
|
||||
// fields will be empty, but for listing the key versions, the KeyPropertiesPageResult needs to
|
||||
// keep the name of the key in `m_keyName` because it is required to get more pages.
|
||||
//
|
||||
if (m_keyName.empty())
|
||||
{
|
||||
GetPropertiesOfKeysSinglePageOptions options;
|
||||
GetPropertiesOfKeysOptions options;
|
||||
options.NextPageToken = NextPageToken;
|
||||
*this = m_keyClient->GetPropertiesOfKeysSinglePage(options, context);
|
||||
*this = m_keyClient->GetPropertiesOfKeys(options, context);
|
||||
CurrentPageToken = options.NextPageToken.Value();
|
||||
}
|
||||
else
|
||||
{
|
||||
GetPropertiesOfKeyVersionsSinglePageOptions options;
|
||||
GetPropertiesOfKeyVersionsOptions options;
|
||||
options.NextPageToken = NextPageToken;
|
||||
*this = m_keyClient->GetPropertiesOfKeyVersionsSinglePage(m_keyName, options, context);
|
||||
*this = m_keyClient->GetPropertiesOfKeyVersions(m_keyName, options, context);
|
||||
CurrentPageToken = options.NextPageToken.Value();
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,10 +56,9 @@ int main()
|
||||
keyClient.CreateEcKey(ecKey);
|
||||
|
||||
std::cout << "\t-List Keys" << std::endl;
|
||||
for (auto keysSinglePage = keyClient.GetPropertiesOfKeysSinglePage(); keysSinglePage.HasPage();
|
||||
keysSinglePage.MoveToNextPage())
|
||||
for (auto keys = keyClient.GetPropertiesOfKeys(); keys.HasPage(); keys.MoveToNextPage())
|
||||
{
|
||||
for (auto const& key : keysSinglePage.Items)
|
||||
for (auto const& key : keys.Items)
|
||||
{
|
||||
if (key.Managed)
|
||||
{
|
||||
@ -80,11 +79,10 @@ int main()
|
||||
|
||||
// List key versions
|
||||
std::cout << "\t-List Key versions" << std::endl;
|
||||
for (auto keyVersionsSinglePage = keyClient.GetPropertiesOfKeyVersionsSinglePage(rsaKeyName);
|
||||
keyVersionsSinglePage.HasPage();
|
||||
keyVersionsSinglePage.MoveToNextPage())
|
||||
for (auto keyVersions = keyClient.GetPropertiesOfKeyVersions(rsaKeyName); keyVersions.HasPage();
|
||||
keyVersions.MoveToNextPage())
|
||||
{
|
||||
for (auto const& key : keyVersionsSinglePage.Items)
|
||||
for (auto const& key : keyVersions.Items)
|
||||
{
|
||||
std::cout << "Key's version: " << key.Version << " with name: " << key.Name << std::endl;
|
||||
}
|
||||
@ -101,7 +99,7 @@ int main()
|
||||
std::cout << "\t-List Deleted Keys" << std::endl;
|
||||
|
||||
// Start getting the first page.
|
||||
for (auto keysDeletedPage = keyClient.GetDeletedKeysSinglePage(); keysDeletedPage.HasPage();
|
||||
for (auto keysDeletedPage = keyClient.GetDeletedKeys(); keysDeletedPage.HasPage();
|
||||
keysDeletedPage.MoveToNextPage())
|
||||
{
|
||||
for (auto const& key : keysDeletedPage.Items)
|
||||
|
||||
@ -70,7 +70,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys { nam
|
||||
static inline void CleanUpKeyVault(KeyClient const& keyClient)
|
||||
{
|
||||
std::vector<DeletedKey> deletedKeys;
|
||||
for (auto keyResponse = keyClient.GetDeletedKeysSinglePage(); keyResponse.HasPage();
|
||||
for (auto keyResponse = keyClient.GetDeletedKeys(); keyResponse.HasPage();
|
||||
keyResponse.MoveToNextPage())
|
||||
{
|
||||
for (auto& key : keyResponse.Items)
|
||||
@ -92,8 +92,8 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys { nam
|
||||
static inline void RemoveAllKeysFromVault(KeyClient const& keyClient, bool waitForPurge = true)
|
||||
{
|
||||
std::vector<DeleteKeyOperation> deletedKeys;
|
||||
GetPropertiesOfKeysSinglePageOptions options;
|
||||
for (auto keyResponse = keyClient.GetPropertiesOfKeysSinglePage(); keyResponse.HasPage();
|
||||
GetPropertiesOfKeysOptions options;
|
||||
for (auto keyResponse = keyClient.GetPropertiesOfKeys(); keyResponse.HasPage();
|
||||
keyResponse.MoveToNextPage())
|
||||
{
|
||||
for (auto& key : keyResponse.Items)
|
||||
|
||||
@ -52,8 +52,8 @@ TEST_F(KeyVaultClientTest, GetPropertiesOfKeysOnePage)
|
||||
}
|
||||
// Get Key properties
|
||||
std::vector<KeyProperties> keyPropertiesList;
|
||||
GetPropertiesOfKeysSinglePageOptions options;
|
||||
for (auto keyResponse = keyClient.GetPropertiesOfKeysSinglePage(options); keyResponse.HasPage();
|
||||
GetPropertiesOfKeysOptions options;
|
||||
for (auto keyResponse = keyClient.GetPropertiesOfKeys(options); keyResponse.HasPage();
|
||||
keyResponse.MoveToNextPage())
|
||||
{
|
||||
for (auto& key : keyResponse.Items)
|
||||
@ -89,9 +89,8 @@ TEST_F(KeyVaultClientTest, GetKeysVersionsOnePage)
|
||||
}
|
||||
// Get Key versions
|
||||
std::vector<KeyProperties> keyPropertiesList;
|
||||
GetPropertiesOfKeyVersionsSinglePageOptions getKeyOptions;
|
||||
for (auto keyResponse = keyClient.GetPropertiesOfKeyVersionsSinglePage(keyName);
|
||||
keyResponse.HasPage();
|
||||
GetPropertiesOfKeyVersionsOptions getKeyOptions;
|
||||
for (auto keyResponse = keyClient.GetPropertiesOfKeyVersions(keyName); keyResponse.HasPage();
|
||||
keyResponse.MoveToNextPage())
|
||||
{
|
||||
for (auto& key : keyResponse.Items)
|
||||
@ -141,7 +140,7 @@ TEST_F(KeyVaultClientTest, GetDeletedKeysOnePage)
|
||||
|
||||
// Get all deleted Keys
|
||||
std::vector<DeletedKey> deletedKeys;
|
||||
for (auto keyResponse = keyClient.GetDeletedKeysSinglePage(); keyResponse.HasPage();
|
||||
for (auto keyResponse = keyClient.GetDeletedKeys(); keyResponse.HasPage();
|
||||
keyResponse.MoveToNextPage())
|
||||
{
|
||||
for (auto& key : keyResponse.Items)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user