diff --git a/CHANGELOG b/CHANGELOG index 83032b4d6..0a35122a8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2020-06-30 Version: 1.36.487 +- Add ListMetrics API. + 2020-06-29 Version: 1.36.486 - Supported Rotate. diff --git a/VERSION b/VERSION index dffcd1d47..a06b817f7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.36.486 \ No newline at end of file +1.36.487 \ No newline at end of file diff --git a/vcs/CMakeLists.txt b/vcs/CMakeLists.txt index cd221f847..b0b0c4a9d 100644 --- a/vcs/CMakeLists.txt +++ b/vcs/CMakeLists.txt @@ -49,6 +49,8 @@ set(vcs_public_header_model include/alibabacloud/vcs/model/ListCorpsResult.h include/alibabacloud/vcs/model/ListDevicesRequest.h include/alibabacloud/vcs/model/ListDevicesResult.h + include/alibabacloud/vcs/model/ListMetricsRequest.h + include/alibabacloud/vcs/model/ListMetricsResult.h include/alibabacloud/vcs/model/ListPersonsRequest.h include/alibabacloud/vcs/model/ListPersonsResult.h include/alibabacloud/vcs/model/RecognizeFaceQualityRequest.h @@ -98,6 +100,8 @@ set(vcs_src src/model/ListCorpsResult.cc src/model/ListDevicesRequest.cc src/model/ListDevicesResult.cc + src/model/ListMetricsRequest.cc + src/model/ListMetricsResult.cc src/model/ListPersonsRequest.cc src/model/ListPersonsResult.cc src/model/RecognizeFaceQualityRequest.cc diff --git a/vcs/include/alibabacloud/vcs/VcsClient.h b/vcs/include/alibabacloud/vcs/VcsClient.h index d86490447..e330e75df 100644 --- a/vcs/include/alibabacloud/vcs/VcsClient.h +++ b/vcs/include/alibabacloud/vcs/VcsClient.h @@ -50,6 +50,8 @@ #include "model/ListCorpsResult.h" #include "model/ListDevicesRequest.h" #include "model/ListDevicesResult.h" +#include "model/ListMetricsRequest.h" +#include "model/ListMetricsResult.h" #include "model/ListPersonsRequest.h" #include "model/ListPersonsResult.h" #include "model/RecognizeFaceQualityRequest.h" @@ -119,6 +121,9 @@ namespace AlibabaCloud typedef Outcome ListDevicesOutcome; typedef std::future ListDevicesOutcomeCallable; typedef std::function&)> ListDevicesAsyncHandler; + typedef Outcome ListMetricsOutcome; + typedef std::future ListMetricsOutcomeCallable; + typedef std::function&)> ListMetricsAsyncHandler; typedef Outcome ListPersonsOutcome; typedef std::future ListPersonsOutcomeCallable; typedef std::function&)> ListPersonsAsyncHandler; @@ -193,6 +198,9 @@ namespace AlibabaCloud ListDevicesOutcome listDevices(const Model::ListDevicesRequest &request)const; void listDevicesAsync(const Model::ListDevicesRequest& request, const ListDevicesAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; ListDevicesOutcomeCallable listDevicesCallable(const Model::ListDevicesRequest& request) const; + ListMetricsOutcome listMetrics(const Model::ListMetricsRequest &request)const; + void listMetricsAsync(const Model::ListMetricsRequest& request, const ListMetricsAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + ListMetricsOutcomeCallable listMetricsCallable(const Model::ListMetricsRequest& request) const; ListPersonsOutcome listPersons(const Model::ListPersonsRequest &request)const; void listPersonsAsync(const Model::ListPersonsRequest& request, const ListPersonsAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; ListPersonsOutcomeCallable listPersonsCallable(const Model::ListPersonsRequest& request) const; diff --git a/vcs/include/alibabacloud/vcs/model/ListMetricsRequest.h b/vcs/include/alibabacloud/vcs/model/ListMetricsRequest.h new file mode 100644 index 000000000..78719a3e3 --- /dev/null +++ b/vcs/include/alibabacloud/vcs/model/ListMetricsRequest.h @@ -0,0 +1,66 @@ +/* + * 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. + */ + +#ifndef ALIBABACLOUD_VCS_MODEL_LISTMETRICSREQUEST_H_ +#define ALIBABACLOUD_VCS_MODEL_LISTMETRICSREQUEST_H_ + +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Vcs + { + namespace Model + { + class ALIBABACLOUD_VCS_EXPORT ListMetricsRequest : public RpcServiceRequest + { + + public: + ListMetricsRequest(); + ~ListMetricsRequest(); + + std::string getCorpId()const; + void setCorpId(const std::string& corpId); + std::string getEndTime()const; + void setEndTime(const std::string& endTime); + std::string getStartTime()const; + void setStartTime(const std::string& startTime); + std::string getPageNumber()const; + void setPageNumber(const std::string& pageNumber); + std::string getTagCode()const; + void setTagCode(const std::string& tagCode); + std::string getPageSize()const; + void setPageSize(const std::string& pageSize); + std::string getAggregateType()const; + void setAggregateType(const std::string& aggregateType); + + private: + std::string corpId_; + std::string endTime_; + std::string startTime_; + std::string pageNumber_; + std::string tagCode_; + std::string pageSize_; + std::string aggregateType_; + + }; + } + } +} +#endif // !ALIBABACLOUD_VCS_MODEL_LISTMETRICSREQUEST_H_ \ No newline at end of file diff --git a/vcs/include/alibabacloud/vcs/model/ListMetricsResult.h b/vcs/include/alibabacloud/vcs/model/ListMetricsResult.h new file mode 100644 index 000000000..fd54921fb --- /dev/null +++ b/vcs/include/alibabacloud/vcs/model/ListMetricsResult.h @@ -0,0 +1,70 @@ +/* + * 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. + */ + +#ifndef ALIBABACLOUD_VCS_MODEL_LISTMETRICSRESULT_H_ +#define ALIBABACLOUD_VCS_MODEL_LISTMETRICSRESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Vcs + { + namespace Model + { + class ALIBABACLOUD_VCS_EXPORT ListMetricsResult : public ServiceResult + { + public: + struct Data + { + struct RecordsItem + { + std::string tagMetric; + std::string tagCode; + std::string tagValue; + std::string dateTime; + }; + int totalCount; + int pageSize; + int totalPage; + int pageNumber; + std::vector records; + }; + + + ListMetricsResult(); + explicit ListMetricsResult(const std::string &payload); + ~ListMetricsResult(); + std::string getMessage()const; + Data getData()const; + std::string getCode()const; + + protected: + void parse(const std::string &payload); + private: + std::string message_; + Data data_; + std::string code_; + + }; + } + } +} +#endif // !ALIBABACLOUD_VCS_MODEL_LISTMETRICSRESULT_H_ \ No newline at end of file diff --git a/vcs/src/VcsClient.cc b/vcs/src/VcsClient.cc index cc83b159a..46d7c782c 100644 --- a/vcs/src/VcsClient.cc +++ b/vcs/src/VcsClient.cc @@ -555,6 +555,42 @@ VcsClient::ListDevicesOutcomeCallable VcsClient::listDevicesCallable(const ListD return task->get_future(); } +VcsClient::ListMetricsOutcome VcsClient::listMetrics(const ListMetricsRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return ListMetricsOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return ListMetricsOutcome(ListMetricsResult(outcome.result())); + else + return ListMetricsOutcome(outcome.error()); +} + +void VcsClient::listMetricsAsync(const ListMetricsRequest& request, const ListMetricsAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, listMetrics(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +VcsClient::ListMetricsOutcomeCallable VcsClient::listMetricsCallable(const ListMetricsRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->listMetrics(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + VcsClient::ListPersonsOutcome VcsClient::listPersons(const ListPersonsRequest &request) const { auto endpointOutcome = endpointProvider_->getEndpoint(); diff --git a/vcs/src/model/ListMetricsRequest.cc b/vcs/src/model/ListMetricsRequest.cc new file mode 100644 index 000000000..3846ae8b7 --- /dev/null +++ b/vcs/src/model/ListMetricsRequest.cc @@ -0,0 +1,106 @@ +/* + * 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 + +using AlibabaCloud::Vcs::Model::ListMetricsRequest; + +ListMetricsRequest::ListMetricsRequest() : + RpcServiceRequest("vcs", "2020-05-15", "ListMetrics") +{ + setMethod(HttpRequest::Method::Post); +} + +ListMetricsRequest::~ListMetricsRequest() +{} + +std::string ListMetricsRequest::getCorpId()const +{ + return corpId_; +} + +void ListMetricsRequest::setCorpId(const std::string& corpId) +{ + corpId_ = corpId; + setBodyParameter("CorpId", corpId); +} + +std::string ListMetricsRequest::getEndTime()const +{ + return endTime_; +} + +void ListMetricsRequest::setEndTime(const std::string& endTime) +{ + endTime_ = endTime; + setBodyParameter("EndTime", endTime); +} + +std::string ListMetricsRequest::getStartTime()const +{ + return startTime_; +} + +void ListMetricsRequest::setStartTime(const std::string& startTime) +{ + startTime_ = startTime; + setBodyParameter("StartTime", startTime); +} + +std::string ListMetricsRequest::getPageNumber()const +{ + return pageNumber_; +} + +void ListMetricsRequest::setPageNumber(const std::string& pageNumber) +{ + pageNumber_ = pageNumber; + setBodyParameter("PageNumber", pageNumber); +} + +std::string ListMetricsRequest::getTagCode()const +{ + return tagCode_; +} + +void ListMetricsRequest::setTagCode(const std::string& tagCode) +{ + tagCode_ = tagCode; + setBodyParameter("TagCode", tagCode); +} + +std::string ListMetricsRequest::getPageSize()const +{ + return pageSize_; +} + +void ListMetricsRequest::setPageSize(const std::string& pageSize) +{ + pageSize_ = pageSize; + setBodyParameter("PageSize", pageSize); +} + +std::string ListMetricsRequest::getAggregateType()const +{ + return aggregateType_; +} + +void ListMetricsRequest::setAggregateType(const std::string& aggregateType) +{ + aggregateType_ = aggregateType; + setBodyParameter("AggregateType", aggregateType); +} + diff --git a/vcs/src/model/ListMetricsResult.cc b/vcs/src/model/ListMetricsResult.cc new file mode 100644 index 000000000..ed38b8c21 --- /dev/null +++ b/vcs/src/model/ListMetricsResult.cc @@ -0,0 +1,86 @@ +/* + * 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 +#include + +using namespace AlibabaCloud::Vcs; +using namespace AlibabaCloud::Vcs::Model; + +ListMetricsResult::ListMetricsResult() : + ServiceResult() +{} + +ListMetricsResult::ListMetricsResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +ListMetricsResult::~ListMetricsResult() +{} + +void ListMetricsResult::parse(const std::string &payload) +{ + Json::Reader reader; + Json::Value value; + reader.parse(payload, value); + setRequestId(value["RequestId"].asString()); + auto dataNode = value["Data"]; + if(!dataNode["PageNumber"].isNull()) + data_.pageNumber = std::stoi(dataNode["PageNumber"].asString()); + if(!dataNode["PageSize"].isNull()) + data_.pageSize = std::stoi(dataNode["PageSize"].asString()); + if(!dataNode["TotalCount"].isNull()) + data_.totalCount = std::stoi(dataNode["TotalCount"].asString()); + if(!dataNode["TotalPage"].isNull()) + data_.totalPage = std::stoi(dataNode["TotalPage"].asString()); + auto allRecordsNode = dataNode["Records"]["RecordsItem"]; + for (auto dataNodeRecordsRecordsItem : allRecordsNode) + { + Data::RecordsItem recordsItemObject; + if(!dataNodeRecordsRecordsItem["DateTime"].isNull()) + recordsItemObject.dateTime = dataNodeRecordsRecordsItem["DateTime"].asString(); + if(!dataNodeRecordsRecordsItem["TagCode"].isNull()) + recordsItemObject.tagCode = dataNodeRecordsRecordsItem["TagCode"].asString(); + if(!dataNodeRecordsRecordsItem["TagValue"].isNull()) + recordsItemObject.tagValue = dataNodeRecordsRecordsItem["TagValue"].asString(); + if(!dataNodeRecordsRecordsItem["TagMetric"].isNull()) + recordsItemObject.tagMetric = dataNodeRecordsRecordsItem["TagMetric"].asString(); + data_.records.push_back(recordsItemObject); + } + if(!value["Code"].isNull()) + code_ = value["Code"].asString(); + if(!value["Message"].isNull()) + message_ = value["Message"].asString(); + +} + +std::string ListMetricsResult::getMessage()const +{ + return message_; +} + +ListMetricsResult::Data ListMetricsResult::getData()const +{ + return data_; +} + +std::string ListMetricsResult::getCode()const +{ + return code_; +} +