adding GetUrl to key vault clients (#2761)

* adding GetUrl to key vault clients

* format
This commit is contained in:
Victor Vazquez 2021-08-19 10:23:30 -07:00 committed by GitHub
parent 8db9c0b223
commit beb4a94cb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 46 additions and 1 deletions

View File

@ -4,6 +4,8 @@
### Features Added
- Added `GetUrl()` to `KeyClient`.
### Breaking Changes
### Bugs Fixed

View File

@ -387,6 +387,13 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
ImportKeyOptions const& importKeyOptions,
Azure::Core::Context const& context = Azure::Core::Context()) const;
/**
* @brief Gets the key client's primary URL endpoint.
*
* @return The key client's primary URL endpoint.
*/
std::string GetUrl() const { return m_vaultUrl.GetAbsoluteUrl(); }
private:
std::unique_ptr<Azure::Core::Http::RawResponse> SendRequest(
Azure::Core::Http::Request& request,

View File

@ -43,3 +43,13 @@ TEST(KeyClient, ServiceVersion)
EXPECT_EQ(options.Version.ToString(), "1.0"););
}
}
TEST(KeyClient, GetUrl)
{
auto credential
= std::make_shared<Azure::Identity::ClientSecretCredential>("tenantID", "AppId", "SecretId");
auto url = "vaultUrl";
KeyClient keyClient(url, credential);
EXPECT_EQ(url, keyClient.GetUrl());
}

View File

@ -2,4 +2,4 @@
## 1.0.0-beta.1 (Unreleased)
* initial preview
- initial preview

View File

@ -292,5 +292,12 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Secrets {
DeletedSecretPagedResponse GetDeletedSecrets(
GetDeletedSecretsOptions const& options = GetDeletedSecretsOptions(),
Azure::Core::Context const& context = Azure::Core::Context()) const;
/**
* @brief Gets the secret client's primary URL endpoint.
*
* @return The key secret's primary URL endpoint.
*/
std::string GetUrl() const;
};
}}}} // namespace Azure::Security::KeyVault::Secrets

View File

@ -185,5 +185,12 @@ namespace Azure { namespace Security { namespace KeyVault { namespace _detail {
// Use the core pipeline directly to avoid checking the response code.
return m_pipeline.Send(request, context);
}
/**
* @brief Get the Url used to create the secret client.
*
* @return A constant reference to the Url.
*/
Azure::Core::Url const& GetUrl() const { return m_vaultUrl; }
};
}}}} // namespace Azure::Security::KeyVault::_detail

View File

@ -311,3 +311,5 @@ DeletedSecretPagedResponse SecretClient::GetDeletedSecrets(
std::move(response.RawResponse),
std::make_unique<SecretClient>(*this));
}
std::string SecretClient::GetUrl() const { return m_protocolClient->GetUrl().GetAbsoluteUrl(); }

View File

@ -42,3 +42,13 @@ TEST(SecretClient, ServiceVersion)
EXPECT_EQ(options.Version.ToString(), "1.0"););
}
}
TEST(SecretClient, GetUrl)
{
auto credential
= std::make_shared<Azure::Identity::ClientSecretCredential>("tenantID", "AppId", "SecretId");
auto url = "vaultUrl";
SecretClient secretClient(url, credential);
EXPECT_EQ(url, secretClient.GetUrl());
}