Api review (#3004)
* operator != * moved download , make protected private * structs and classes * comments * change std::vector into struct * optional structs * get version * api signature changes * remove the options structs where not necessary , they are extremelly ugly * fix issue * small sample readme update * simplify certificate creation
This commit is contained in:
parent
871b9e8d6d
commit
08947edfc8
@ -82,13 +82,6 @@ CertificateCreateParameters params;
|
||||
// start the create process
|
||||
auto response = certificateClient.StartCreateCertificate(certificateName, params);
|
||||
auto result = response.PollUntilDone(defaultWait);
|
||||
|
||||
// check that the operation completed
|
||||
while (!response.IsCompleted())
|
||||
{
|
||||
response.UpdateProperties();
|
||||
std::this_thread::sleep_for(defaultWait);
|
||||
}
|
||||
```
|
||||
|
||||
### Getting a Certificate
|
||||
|
||||
@ -64,19 +64,13 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Get the #Azure::Security::KeyVault::Certificates::KeyVaultCertificateWithPolicy
|
||||
* @brief Get the #Azure::Security::KeyVault::Certificates::CertificateOperationProperties
|
||||
* object.
|
||||
*
|
||||
* @return A certificate object.
|
||||
* @return A CertificateOperationProperties object.
|
||||
*/
|
||||
CertificateOperationProperties Value() const override { return m_value; }
|
||||
|
||||
/**
|
||||
* @brief Get the properties of the pending certificate operation.
|
||||
*
|
||||
*/
|
||||
CertificateOperationProperties Properties;
|
||||
|
||||
/**
|
||||
* @brief Get an Url as string which can be used to get the status of the
|
||||
* operation.
|
||||
@ -103,15 +97,6 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
|
||||
CertificateClient const& client,
|
||||
Azure::Core::Context const& context = Azure::Core::Context());
|
||||
|
||||
/**
|
||||
* @brief Updates the properties of the operation by querying the key vault.
|
||||
*
|
||||
* @param context A #Azure::Core::Context controlling the request lifetime.
|
||||
* @return updated properties
|
||||
*/
|
||||
CertificateOperationProperties UpdateProperties(
|
||||
Azure::Core::Context const& context = Azure::Core::Context());
|
||||
|
||||
/**
|
||||
* @brief Cancels the operation.
|
||||
*
|
||||
|
||||
@ -43,13 +43,6 @@ auto params = CertificateCreateParameters();
|
||||
// start the create process
|
||||
auto response = certificateClient.StartCreateCertificate(certificateName, params);
|
||||
auto result = response.PollUntilDone(defaultWait);
|
||||
|
||||
// check that the operation completed
|
||||
while (!response.IsCompleted())
|
||||
{
|
||||
response.UpdateProperties();
|
||||
std::this_thread::sleep_for(defaultWait);
|
||||
}
|
||||
```
|
||||
|
||||
## Getting properties of Certificates
|
||||
|
||||
@ -159,13 +159,6 @@ KeyVaultCertificateWithPolicy CreateCertificate(
|
||||
auto response = certificateClient.StartCreateCertificate(certificateName, params);
|
||||
auto result = response.PollUntilDone(defaultWait);
|
||||
|
||||
// check that the operation completed
|
||||
while (!response.IsCompleted())
|
||||
{
|
||||
response.UpdateProperties();
|
||||
std::this_thread::sleep_for(defaultWait);
|
||||
}
|
||||
|
||||
// get the certificate
|
||||
auto certificate = certificateClient.GetCertificate(certificateName).Value;
|
||||
|
||||
|
||||
@ -42,13 +42,6 @@ CertificateCreateParameters params;
|
||||
// start the create process
|
||||
auto response = certificateClient.StartCreateCertificate(certificateName, params);
|
||||
auto result = response.PollUntilDone(defaultWait);
|
||||
|
||||
// check that the operation completed
|
||||
while (!response.IsCompleted())
|
||||
{
|
||||
response.UpdateProperties();
|
||||
std::this_thread::sleep_for(defaultWait);
|
||||
}
|
||||
```
|
||||
|
||||
## Getting a Certificate
|
||||
|
||||
@ -69,13 +69,6 @@ int main()
|
||||
auto response = certificateClient.StartCreateCertificate(certificateName, params);
|
||||
auto result = response.PollUntilDone(defaultWait);
|
||||
|
||||
// check that the operation completed
|
||||
while (!response.IsCompleted())
|
||||
{
|
||||
response.UpdateProperties();
|
||||
std::this_thread::sleep_for(defaultWait);
|
||||
}
|
||||
|
||||
// get the certificate
|
||||
certificate = certificateClient.GetCertificate(certificateName).Value;
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ Azure::Response<CertificateOperationProperties> CreateCertificateOperation::Poll
|
||||
while (true)
|
||||
{
|
||||
Poll(context);
|
||||
if (IsDone())
|
||||
if (IsDone() && IsCompleted())
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -70,9 +70,9 @@ CreateCertificateOperation::CreateCertificateOperation(
|
||||
Azure::Response<CertificateOperationProperties> response)
|
||||
: m_certificateClient(certificateClient)
|
||||
{
|
||||
Properties = response.Value;
|
||||
m_value = response.Value;
|
||||
m_rawResponse = std::move(response.RawResponse);
|
||||
m_continuationToken = Properties.Name;
|
||||
m_continuationToken = m_value.Name;
|
||||
|
||||
if (!m_value.Name.empty())
|
||||
{
|
||||
@ -97,43 +97,30 @@ CreateCertificateOperation CreateCertificateOperation::CreateFromResumeToken(
|
||||
return operation;
|
||||
}
|
||||
|
||||
CertificateOperationProperties CreateCertificateOperation::UpdateProperties(
|
||||
Azure::Core::Context const& context)
|
||||
{
|
||||
if (IsCompleted())
|
||||
{
|
||||
return Properties;
|
||||
}
|
||||
|
||||
auto response = m_certificateClient->GetPendingCertificateOperation(m_continuationToken, context);
|
||||
Properties = response.Value;
|
||||
return Properties;
|
||||
}
|
||||
|
||||
void CreateCertificateOperation::Cancel(Azure::Core::Context const& context)
|
||||
{
|
||||
auto response
|
||||
= m_certificateClient->CancelPendingCertificateOperation(m_continuationToken, context);
|
||||
Properties = response.Value;
|
||||
m_value = response.Value;
|
||||
}
|
||||
void CreateCertificateOperation::Delete(Azure::Core::Context const& context)
|
||||
{
|
||||
auto response
|
||||
= m_certificateClient->DeletePendingCertificateOperation(m_continuationToken, context);
|
||||
Properties = response.Value;
|
||||
m_value = response.Value;
|
||||
}
|
||||
|
||||
bool CreateCertificateOperation::IsCompleted() const
|
||||
{
|
||||
bool completed = false;
|
||||
|
||||
if (Properties.Status.HasValue()
|
||||
&& (Properties.Status.Value() == _detail::CompletedValue
|
||||
|| Properties.Status.Value() == _detail::DeletedValue))
|
||||
if (m_value.Status
|
||||
&& (m_value.Status.Value() == _detail::CompletedValue
|
||||
|| m_value.Status.Value() == _detail::DeletedValue))
|
||||
{
|
||||
completed = true;
|
||||
}
|
||||
if (Properties.Error.HasValue())
|
||||
if (m_value.Error.HasValue())
|
||||
{
|
||||
completed = true;
|
||||
}
|
||||
|
||||
@ -261,12 +261,6 @@ namespace Azure {
|
||||
auto response = client.StartCreateCertificate(name, params);
|
||||
auto result = response.PollUntilDone(defaultWait);
|
||||
|
||||
while (!response.IsCompleted())
|
||||
{
|
||||
response.UpdateProperties();
|
||||
std::this_thread::sleep_for(defaultWait);
|
||||
}
|
||||
|
||||
auto cert = client.GetCertificate(name);
|
||||
|
||||
EXPECT_EQ(cert.Value.Name(), params.Properties.Name);
|
||||
|
||||
@ -68,11 +68,6 @@ TEST_F(KeyVaultCertificateClientTest, CreateCertificateResumeToken)
|
||||
= CreateCertificateOperation::CreateFromResumeToken(response.GetResumeToken(), client);
|
||||
|
||||
auto result = fromToken.PollUntilDone(m_defaultWait);
|
||||
while (!response.IsCompleted())
|
||||
{
|
||||
response.UpdateProperties();
|
||||
std::this_thread::sleep_for(m_defaultWait);
|
||||
}
|
||||
|
||||
auto cert = client.GetCertificate(certificateName);
|
||||
EXPECT_EQ(cert.Value.Name(), params.Properties.Name);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user