Ver Fonte

Add ListMetrics API.

sdk-team há 6 anos atrás
pai
commit
db4bd7ae11

+ 3 - 0
CHANGELOG

@@ -1,3 +1,6 @@
+2020-06-30 Version: 1.36.487
+- Add ListMetrics API.
+
 2020-06-29 Version: 1.36.486
 - Supported Rotate.
 

+ 1 - 1
VERSION

@@ -1 +1 @@
-1.36.486
+1.36.487

+ 4 - 0
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

+ 8 - 0
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<Error, Model::ListDevicesResult> ListDevicesOutcome;
 			typedef std::future<ListDevicesOutcome> ListDevicesOutcomeCallable;
 			typedef std::function<void(const VcsClient*, const Model::ListDevicesRequest&, const ListDevicesOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ListDevicesAsyncHandler;
+			typedef Outcome<Error, Model::ListMetricsResult> ListMetricsOutcome;
+			typedef std::future<ListMetricsOutcome> ListMetricsOutcomeCallable;
+			typedef std::function<void(const VcsClient*, const Model::ListMetricsRequest&, const ListMetricsOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ListMetricsAsyncHandler;
 			typedef Outcome<Error, Model::ListPersonsResult> ListPersonsOutcome;
 			typedef std::future<ListPersonsOutcome> ListPersonsOutcomeCallable;
 			typedef std::function<void(const VcsClient*, const Model::ListPersonsRequest&, const ListPersonsOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> 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<const AsyncCallerContext>& 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<const AsyncCallerContext>& 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<const AsyncCallerContext>& context = nullptr) const;
 			ListPersonsOutcomeCallable listPersonsCallable(const Model::ListPersonsRequest& request) const;

+ 66 - 0
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 <string>
+#include <vector>
+#include <alibabacloud/core/RpcServiceRequest.h>
+#include <alibabacloud/vcs/VcsExport.h>
+
+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_

+ 70 - 0
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 <string>
+#include <vector>
+#include <utility>
+#include <alibabacloud/core/ServiceResult.h>
+#include <alibabacloud/vcs/VcsExport.h>
+
+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<RecordsItem> 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_

+ 36 - 0
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<const AsyncCallerContext>& 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<std::packaged_task<ListMetricsOutcome()>>(
+			[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();

+ 106 - 0
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 <alibabacloud/vcs/model/ListMetricsRequest.h>
+
+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);
+}
+

+ 86 - 0
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 <alibabacloud/vcs/model/ListMetricsResult.h>
+#include <json/json.h>
+
+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_;
+}
+