Support filtering keys and secrets.

This commit is contained in:
sdk-team
2020-09-28 05:07:41 +00:00
parent d4c20caaed
commit 60799e2b22
18 changed files with 483 additions and 11 deletions

View File

@@ -31,21 +31,21 @@ KmsClient::KmsClient(const Credentials &credentials, const ClientConfiguration &
RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(credentials), configuration)
{
auto locationClient = std::make_shared<LocationClient>(credentials, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "kms-service");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "kms");
}
KmsClient::KmsClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration)
{
auto locationClient = std::make_shared<LocationClient>(credentialsProvider, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "kms-service");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "kms");
}
KmsClient::KmsClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(accessKeyId, accessKeySecret), configuration)
{
auto locationClient = std::make_shared<LocationClient>(accessKeyId, accessKeySecret, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "kms-service");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "kms");
}
KmsClient::~KmsClient()
@@ -519,6 +519,42 @@ KmsClient::DeleteSecretOutcomeCallable KmsClient::deleteSecretCallable(const Del
return task->get_future();
}
KmsClient::DescribeAccountKmsStatusOutcome KmsClient::describeAccountKmsStatus(const DescribeAccountKmsStatusRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return DescribeAccountKmsStatusOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return DescribeAccountKmsStatusOutcome(DescribeAccountKmsStatusResult(outcome.result()));
else
return DescribeAccountKmsStatusOutcome(outcome.error());
}
void KmsClient::describeAccountKmsStatusAsync(const DescribeAccountKmsStatusRequest& request, const DescribeAccountKmsStatusAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, describeAccountKmsStatus(request), context);
};
asyncExecute(new Runnable(fn));
}
KmsClient::DescribeAccountKmsStatusOutcomeCallable KmsClient::describeAccountKmsStatusCallable(const DescribeAccountKmsStatusRequest &request) const
{
auto task = std::make_shared<std::packaged_task<DescribeAccountKmsStatusOutcome()>>(
[this, request]()
{
return this->describeAccountKmsStatus(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
KmsClient::DescribeKeyOutcome KmsClient::describeKey(const DescribeKeyRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
@@ -1383,6 +1419,42 @@ KmsClient::ListSecretsOutcomeCallable KmsClient::listSecretsCallable(const ListS
return task->get_future();
}
KmsClient::OpenKmsServiceOutcome KmsClient::openKmsService(const OpenKmsServiceRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return OpenKmsServiceOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return OpenKmsServiceOutcome(OpenKmsServiceResult(outcome.result()));
else
return OpenKmsServiceOutcome(outcome.error());
}
void KmsClient::openKmsServiceAsync(const OpenKmsServiceRequest& request, const OpenKmsServiceAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, openKmsService(request), context);
};
asyncExecute(new Runnable(fn));
}
KmsClient::OpenKmsServiceOutcomeCallable KmsClient::openKmsServiceCallable(const OpenKmsServiceRequest &request) const
{
auto task = std::make_shared<std::packaged_task<OpenKmsServiceOutcome()>>(
[this, request]()
{
return this->openKmsService(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
KmsClient::PutSecretValueOutcome KmsClient::putSecretValue(const PutSecretValueRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();

View File

@@ -0,0 +1,29 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/kms/model/DescribeAccountKmsStatusRequest.h>
using AlibabaCloud::Kms::Model::DescribeAccountKmsStatusRequest;
DescribeAccountKmsStatusRequest::DescribeAccountKmsStatusRequest() :
RpcServiceRequest("kms", "2016-01-20", "DescribeAccountKmsStatus")
{
setMethod(HttpRequest::Method::Post);
}
DescribeAccountKmsStatusRequest::~DescribeAccountKmsStatusRequest()
{}

View File

@@ -0,0 +1,51 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/kms/model/DescribeAccountKmsStatusResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Kms;
using namespace AlibabaCloud::Kms::Model;
DescribeAccountKmsStatusResult::DescribeAccountKmsStatusResult() :
ServiceResult()
{}
DescribeAccountKmsStatusResult::DescribeAccountKmsStatusResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
DescribeAccountKmsStatusResult::~DescribeAccountKmsStatusResult()
{}
void DescribeAccountKmsStatusResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
if(!value["AccountStatus"].isNull())
accountStatus_ = value["AccountStatus"].asString();
}
std::string DescribeAccountKmsStatusResult::getAccountStatus()const
{
return accountStatus_;
}

View File

@@ -38,6 +38,17 @@ void ListKeysRequest::setPageSize(int pageSize)
setParameter("PageSize", std::to_string(pageSize));
}
std::string ListKeysRequest::getFilters()const
{
return filters_;
}
void ListKeysRequest::setFilters(const std::string& filters)
{
filters_ = filters;
setParameter("Filters", filters);
}
int ListKeysRequest::getPageNumber()const
{
return pageNumber_;

View File

@@ -43,18 +43,18 @@ void ListKeysResult::parse(const std::string &payload)
for (auto valueKeysKey : allKeysNode)
{
Key keysObject;
if(!valueKeysKey["KeyId"].isNull())
keysObject.keyId = valueKeysKey["KeyId"].asString();
if(!valueKeysKey["KeyArn"].isNull())
keysObject.keyArn = valueKeysKey["KeyArn"].asString();
if(!valueKeysKey["KeyId"].isNull())
keysObject.keyId = valueKeysKey["KeyId"].asString();
keys_.push_back(keysObject);
}
if(!value["TotalCount"].isNull())
totalCount_ = std::stoi(value["TotalCount"].asString());
if(!value["PageNumber"].isNull())
pageNumber_ = std::stoi(value["PageNumber"].asString());
if(!value["PageSize"].isNull())
pageSize_ = std::stoi(value["PageSize"].asString());
if(!value["TotalCount"].isNull())
totalCount_ = std::stoi(value["TotalCount"].asString());
}

View File

@@ -38,6 +38,17 @@ void ListSecretsRequest::setPageSize(int pageSize)
setParameter("PageSize", std::to_string(pageSize));
}
std::string ListSecretsRequest::getFilters()const
{
return filters_;
}
void ListSecretsRequest::setFilters(const std::string& filters)
{
filters_ = filters;
setParameter("Filters", filters);
}
std::string ListSecretsRequest::getFetchTags()const
{
return fetchTags_;

View File

@@ -43,14 +43,14 @@ void ListSecretsResult::parse(const std::string &payload)
for (auto valueSecretListSecret : allSecretListNode)
{
Secret secretListObject;
if(!valueSecretListSecret["SecretName"].isNull())
secretListObject.secretName = valueSecretListSecret["SecretName"].asString();
if(!valueSecretListSecret["CreateTime"].isNull())
secretListObject.createTime = valueSecretListSecret["CreateTime"].asString();
if(!valueSecretListSecret["UpdateTime"].isNull())
secretListObject.updateTime = valueSecretListSecret["UpdateTime"].asString();
if(!valueSecretListSecret["PlannedDeleteTime"].isNull())
secretListObject.plannedDeleteTime = valueSecretListSecret["PlannedDeleteTime"].asString();
if(!valueSecretListSecret["SecretName"].isNull())
secretListObject.secretName = valueSecretListSecret["SecretName"].asString();
if(!valueSecretListSecret["UpdateTime"].isNull())
secretListObject.updateTime = valueSecretListSecret["UpdateTime"].asString();
auto allTagsNode = allSecretListNode["Tags"]["Tag"];
for (auto allSecretListNodeTagsTag : allTagsNode)
{

View File

@@ -0,0 +1,29 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/kms/model/OpenKmsServiceRequest.h>
using AlibabaCloud::Kms::Model::OpenKmsServiceRequest;
OpenKmsServiceRequest::OpenKmsServiceRequest() :
RpcServiceRequest("kms", "2016-01-20", "OpenKmsService")
{
setMethod(HttpRequest::Method::Post);
}
OpenKmsServiceRequest::~OpenKmsServiceRequest()
{}

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/kms/model/OpenKmsServiceResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Kms;
using namespace AlibabaCloud::Kms::Model;
OpenKmsServiceResult::OpenKmsServiceResult() :
ServiceResult()
{}
OpenKmsServiceResult::OpenKmsServiceResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
OpenKmsServiceResult::~OpenKmsServiceResult()
{}
void OpenKmsServiceResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
}