Support execute database script via open api.

This commit is contained in:
sdk-team
2020-09-11 03:24:25 +00:00
parent 2d5bf1dbd8
commit 51f047d6f3
12 changed files with 599 additions and 0 deletions

View File

@@ -1,3 +1,6 @@
2020-09-11 Version: patch
- Support execute database script via open api.
2020-09-10 Version: patch
- Add DisableBackupLog.
- Add EnableBackupLog.

View File

@@ -23,6 +23,8 @@ set(dms-enterprise_public_header
set(dms-enterprise_public_header_model
include/alibabacloud/dms-enterprise/model/ApproveOrderRequest.h
include/alibabacloud/dms-enterprise/model/ApproveOrderResult.h
include/alibabacloud/dms-enterprise/model/CheckFinishMissionRequest.h
include/alibabacloud/dms-enterprise/model/CheckFinishMissionResult.h
include/alibabacloud/dms-enterprise/model/CloseOrderRequest.h
include/alibabacloud/dms-enterprise/model/CloseOrderResult.h
include/alibabacloud/dms-enterprise/model/CreateOrderRequest.h
@@ -41,6 +43,8 @@ set(dms-enterprise_public_header_model
include/alibabacloud/dms-enterprise/model/ExecuteDataCorrectResult.h
include/alibabacloud/dms-enterprise/model/ExecuteDataExportRequest.h
include/alibabacloud/dms-enterprise/model/ExecuteDataExportResult.h
include/alibabacloud/dms-enterprise/model/ExecuteScriptRequest.h
include/alibabacloud/dms-enterprise/model/ExecuteScriptResult.h
include/alibabacloud/dms-enterprise/model/GetApprovalDetailRequest.h
include/alibabacloud/dms-enterprise/model/GetApprovalDetailResult.h
include/alibabacloud/dms-enterprise/model/GetDataCorrectBackupFilesRequest.h
@@ -122,6 +126,8 @@ set(dms-enterprise_src
src/Dms-enterpriseClient.cc
src/model/ApproveOrderRequest.cc
src/model/ApproveOrderResult.cc
src/model/CheckFinishMissionRequest.cc
src/model/CheckFinishMissionResult.cc
src/model/CloseOrderRequest.cc
src/model/CloseOrderResult.cc
src/model/CreateOrderRequest.cc
@@ -140,6 +146,8 @@ set(dms-enterprise_src
src/model/ExecuteDataCorrectResult.cc
src/model/ExecuteDataExportRequest.cc
src/model/ExecuteDataExportResult.cc
src/model/ExecuteScriptRequest.cc
src/model/ExecuteScriptResult.cc
src/model/GetApprovalDetailRequest.cc
src/model/GetApprovalDetailResult.cc
src/model/GetDataCorrectBackupFilesRequest.cc

View File

@@ -24,6 +24,8 @@
#include "Dms_enterpriseExport.h"
#include "model/ApproveOrderRequest.h"
#include "model/ApproveOrderResult.h"
#include "model/CheckFinishMissionRequest.h"
#include "model/CheckFinishMissionResult.h"
#include "model/CloseOrderRequest.h"
#include "model/CloseOrderResult.h"
#include "model/CreateOrderRequest.h"
@@ -42,6 +44,8 @@
#include "model/ExecuteDataCorrectResult.h"
#include "model/ExecuteDataExportRequest.h"
#include "model/ExecuteDataExportResult.h"
#include "model/ExecuteScriptRequest.h"
#include "model/ExecuteScriptResult.h"
#include "model/GetApprovalDetailRequest.h"
#include "model/GetApprovalDetailResult.h"
#include "model/GetDataCorrectBackupFilesRequest.h"
@@ -130,6 +134,9 @@ namespace AlibabaCloud
typedef Outcome<Error, Model::ApproveOrderResult> ApproveOrderOutcome;
typedef std::future<ApproveOrderOutcome> ApproveOrderOutcomeCallable;
typedef std::function<void(const Dms_enterpriseClient*, const Model::ApproveOrderRequest&, const ApproveOrderOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ApproveOrderAsyncHandler;
typedef Outcome<Error, Model::CheckFinishMissionResult> CheckFinishMissionOutcome;
typedef std::future<CheckFinishMissionOutcome> CheckFinishMissionOutcomeCallable;
typedef std::function<void(const Dms_enterpriseClient*, const Model::CheckFinishMissionRequest&, const CheckFinishMissionOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> CheckFinishMissionAsyncHandler;
typedef Outcome<Error, Model::CloseOrderResult> CloseOrderOutcome;
typedef std::future<CloseOrderOutcome> CloseOrderOutcomeCallable;
typedef std::function<void(const Dms_enterpriseClient*, const Model::CloseOrderRequest&, const CloseOrderOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> CloseOrderAsyncHandler;
@@ -157,6 +164,9 @@ namespace AlibabaCloud
typedef Outcome<Error, Model::ExecuteDataExportResult> ExecuteDataExportOutcome;
typedef std::future<ExecuteDataExportOutcome> ExecuteDataExportOutcomeCallable;
typedef std::function<void(const Dms_enterpriseClient*, const Model::ExecuteDataExportRequest&, const ExecuteDataExportOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ExecuteDataExportAsyncHandler;
typedef Outcome<Error, Model::ExecuteScriptResult> ExecuteScriptOutcome;
typedef std::future<ExecuteScriptOutcome> ExecuteScriptOutcomeCallable;
typedef std::function<void(const Dms_enterpriseClient*, const Model::ExecuteScriptRequest&, const ExecuteScriptOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ExecuteScriptAsyncHandler;
typedef Outcome<Error, Model::GetApprovalDetailResult> GetApprovalDetailOutcome;
typedef std::future<GetApprovalDetailOutcome> GetApprovalDetailOutcomeCallable;
typedef std::function<void(const Dms_enterpriseClient*, const Model::GetApprovalDetailRequest&, const GetApprovalDetailOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetApprovalDetailAsyncHandler;
@@ -279,6 +289,9 @@ namespace AlibabaCloud
ApproveOrderOutcome approveOrder(const Model::ApproveOrderRequest &request)const;
void approveOrderAsync(const Model::ApproveOrderRequest& request, const ApproveOrderAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
ApproveOrderOutcomeCallable approveOrderCallable(const Model::ApproveOrderRequest& request) const;
CheckFinishMissionOutcome checkFinishMission(const Model::CheckFinishMissionRequest &request)const;
void checkFinishMissionAsync(const Model::CheckFinishMissionRequest& request, const CheckFinishMissionAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
CheckFinishMissionOutcomeCallable checkFinishMissionCallable(const Model::CheckFinishMissionRequest& request) const;
CloseOrderOutcome closeOrder(const Model::CloseOrderRequest &request)const;
void closeOrderAsync(const Model::CloseOrderRequest& request, const CloseOrderAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
CloseOrderOutcomeCallable closeOrderCallable(const Model::CloseOrderRequest& request) const;
@@ -306,6 +319,9 @@ namespace AlibabaCloud
ExecuteDataExportOutcome executeDataExport(const Model::ExecuteDataExportRequest &request)const;
void executeDataExportAsync(const Model::ExecuteDataExportRequest& request, const ExecuteDataExportAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
ExecuteDataExportOutcomeCallable executeDataExportCallable(const Model::ExecuteDataExportRequest& request) const;
ExecuteScriptOutcome executeScript(const Model::ExecuteScriptRequest &request)const;
void executeScriptAsync(const Model::ExecuteScriptRequest& request, const ExecuteScriptAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
ExecuteScriptOutcomeCallable executeScriptCallable(const Model::ExecuteScriptRequest& request) const;
GetApprovalDetailOutcome getApprovalDetail(const Model::GetApprovalDetailRequest &request)const;
void getApprovalDetailAsync(const Model::GetApprovalDetailRequest& request, const GetApprovalDetailAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetApprovalDetailOutcomeCallable getApprovalDetailCallable(const Model::GetApprovalDetailRequest& request) const;

View File

@@ -0,0 +1,48 @@
/*
* 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_DMS_ENTERPRISE_MODEL_CHECKFINISHMISSIONREQUEST_H_
#define ALIBABACLOUD_DMS_ENTERPRISE_MODEL_CHECKFINISHMISSIONREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/dms-enterprise/Dms_enterpriseExport.h>
namespace AlibabaCloud
{
namespace Dms_enterprise
{
namespace Model
{
class ALIBABACLOUD_DMS_ENTERPRISE_EXPORT CheckFinishMissionRequest : public RpcServiceRequest
{
public:
CheckFinishMissionRequest();
~CheckFinishMissionRequest();
std::string getMissionType()const;
void setMissionType(const std::string& missionType);
private:
std::string missionType_;
};
}
}
}
#endif // !ALIBABACLOUD_DMS_ENTERPRISE_MODEL_CHECKFINISHMISSIONREQUEST_H_

View File

@@ -0,0 +1,57 @@
/*
* 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_DMS_ENTERPRISE_MODEL_CHECKFINISHMISSIONRESULT_H_
#define ALIBABACLOUD_DMS_ENTERPRISE_MODEL_CHECKFINISHMISSIONRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/dms-enterprise/Dms_enterpriseExport.h>
namespace AlibabaCloud
{
namespace Dms_enterprise
{
namespace Model
{
class ALIBABACLOUD_DMS_ENTERPRISE_EXPORT CheckFinishMissionResult : public ServiceResult
{
public:
CheckFinishMissionResult();
explicit CheckFinishMissionResult(const std::string &payload);
~CheckFinishMissionResult();
bool getHasFinish()const;
std::string getErrorCode()const;
std::string getErrorMessage()const;
bool getSuccess()const;
protected:
void parse(const std::string &payload);
private:
bool hasFinish_;
std::string errorCode_;
std::string errorMessage_;
bool success_;
};
}
}
}
#endif // !ALIBABACLOUD_DMS_ENTERPRISE_MODEL_CHECKFINISHMISSIONRESULT_H_

View File

@@ -0,0 +1,57 @@
/*
* 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_DMS_ENTERPRISE_MODEL_EXECUTESCRIPTREQUEST_H_
#define ALIBABACLOUD_DMS_ENTERPRISE_MODEL_EXECUTESCRIPTREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/dms-enterprise/Dms_enterpriseExport.h>
namespace AlibabaCloud
{
namespace Dms_enterprise
{
namespace Model
{
class ALIBABACLOUD_DMS_ENTERPRISE_EXPORT ExecuteScriptRequest : public RpcServiceRequest
{
public:
ExecuteScriptRequest();
~ExecuteScriptRequest();
int getDbId()const;
void setDbId(int dbId);
bool getLogic()const;
void setLogic(bool logic);
std::string getScript()const;
void setScript(const std::string& script);
long getTid()const;
void setTid(long tid);
private:
int dbId_;
bool logic_;
std::string script_;
long tid_;
};
}
}
}
#endif // !ALIBABACLOUD_DMS_ENTERPRISE_MODEL_EXECUTESCRIPTREQUEST_H_

View File

@@ -0,0 +1,65 @@
/*
* 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_DMS_ENTERPRISE_MODEL_EXECUTESCRIPTRESULT_H_
#define ALIBABACLOUD_DMS_ENTERPRISE_MODEL_EXECUTESCRIPTRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/dms-enterprise/Dms_enterpriseExport.h>
namespace AlibabaCloud
{
namespace Dms_enterprise
{
namespace Model
{
class ALIBABACLOUD_DMS_ENTERPRISE_EXPORT ExecuteScriptResult : public ServiceResult
{
public:
struct Result
{
std::vector<std::string> columnNames;
std::string message;
long rowCount;
bool success;
std::vector<std::string> rows;
};
ExecuteScriptResult();
explicit ExecuteScriptResult(const std::string &payload);
~ExecuteScriptResult();
std::vector<Result> getResults()const;
std::string getErrorCode()const;
std::string getErrorMessage()const;
bool getSuccess()const;
protected:
void parse(const std::string &payload);
private:
std::vector<Result> results_;
std::string errorCode_;
std::string errorMessage_;
bool success_;
};
}
}
}
#endif // !ALIBABACLOUD_DMS_ENTERPRISE_MODEL_EXECUTESCRIPTRESULT_H_

View File

@@ -87,6 +87,42 @@ Dms_enterpriseClient::ApproveOrderOutcomeCallable Dms_enterpriseClient::approveO
return task->get_future();
}
Dms_enterpriseClient::CheckFinishMissionOutcome Dms_enterpriseClient::checkFinishMission(const CheckFinishMissionRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return CheckFinishMissionOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return CheckFinishMissionOutcome(CheckFinishMissionResult(outcome.result()));
else
return CheckFinishMissionOutcome(outcome.error());
}
void Dms_enterpriseClient::checkFinishMissionAsync(const CheckFinishMissionRequest& request, const CheckFinishMissionAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, checkFinishMission(request), context);
};
asyncExecute(new Runnable(fn));
}
Dms_enterpriseClient::CheckFinishMissionOutcomeCallable Dms_enterpriseClient::checkFinishMissionCallable(const CheckFinishMissionRequest &request) const
{
auto task = std::make_shared<std::packaged_task<CheckFinishMissionOutcome()>>(
[this, request]()
{
return this->checkFinishMission(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
Dms_enterpriseClient::CloseOrderOutcome Dms_enterpriseClient::closeOrder(const CloseOrderRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
@@ -411,6 +447,42 @@ Dms_enterpriseClient::ExecuteDataExportOutcomeCallable Dms_enterpriseClient::exe
return task->get_future();
}
Dms_enterpriseClient::ExecuteScriptOutcome Dms_enterpriseClient::executeScript(const ExecuteScriptRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return ExecuteScriptOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return ExecuteScriptOutcome(ExecuteScriptResult(outcome.result()));
else
return ExecuteScriptOutcome(outcome.error());
}
void Dms_enterpriseClient::executeScriptAsync(const ExecuteScriptRequest& request, const ExecuteScriptAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, executeScript(request), context);
};
asyncExecute(new Runnable(fn));
}
Dms_enterpriseClient::ExecuteScriptOutcomeCallable Dms_enterpriseClient::executeScriptCallable(const ExecuteScriptRequest &request) const
{
auto task = std::make_shared<std::packaged_task<ExecuteScriptOutcome()>>(
[this, request]()
{
return this->executeScript(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
Dms_enterpriseClient::GetApprovalDetailOutcome Dms_enterpriseClient::getApprovalDetail(const GetApprovalDetailRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();

View File

@@ -0,0 +1,40 @@
/*
* 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/dms-enterprise/model/CheckFinishMissionRequest.h>
using AlibabaCloud::Dms_enterprise::Model::CheckFinishMissionRequest;
CheckFinishMissionRequest::CheckFinishMissionRequest() :
RpcServiceRequest("dms-enterprise", "2018-11-01", "CheckFinishMission")
{
setMethod(HttpRequest::Method::Get);
}
CheckFinishMissionRequest::~CheckFinishMissionRequest()
{}
std::string CheckFinishMissionRequest::getMissionType()const
{
return missionType_;
}
void CheckFinishMissionRequest::setMissionType(const std::string& missionType)
{
missionType_ = missionType;
setParameter("MissionType", missionType);
}

View File

@@ -0,0 +1,72 @@
/*
* 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/dms-enterprise/model/CheckFinishMissionResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Dms_enterprise;
using namespace AlibabaCloud::Dms_enterprise::Model;
CheckFinishMissionResult::CheckFinishMissionResult() :
ServiceResult()
{}
CheckFinishMissionResult::CheckFinishMissionResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
CheckFinishMissionResult::~CheckFinishMissionResult()
{}
void CheckFinishMissionResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
if(!value["Success"].isNull())
success_ = value["Success"].asString() == "true";
if(!value["ErrorMessage"].isNull())
errorMessage_ = value["ErrorMessage"].asString();
if(!value["ErrorCode"].isNull())
errorCode_ = value["ErrorCode"].asString();
if(!value["HasFinish"].isNull())
hasFinish_ = value["HasFinish"].asString() == "true";
}
bool CheckFinishMissionResult::getHasFinish()const
{
return hasFinish_;
}
std::string CheckFinishMissionResult::getErrorCode()const
{
return errorCode_;
}
std::string CheckFinishMissionResult::getErrorMessage()const
{
return errorMessage_;
}
bool CheckFinishMissionResult::getSuccess()const
{
return success_;
}

View File

@@ -0,0 +1,73 @@
/*
* 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/dms-enterprise/model/ExecuteScriptRequest.h>
using AlibabaCloud::Dms_enterprise::Model::ExecuteScriptRequest;
ExecuteScriptRequest::ExecuteScriptRequest() :
RpcServiceRequest("dms-enterprise", "2018-11-01", "ExecuteScript")
{
setMethod(HttpRequest::Method::Post);
}
ExecuteScriptRequest::~ExecuteScriptRequest()
{}
int ExecuteScriptRequest::getDbId()const
{
return dbId_;
}
void ExecuteScriptRequest::setDbId(int dbId)
{
dbId_ = dbId;
setParameter("DbId", std::to_string(dbId));
}
bool ExecuteScriptRequest::getLogic()const
{
return logic_;
}
void ExecuteScriptRequest::setLogic(bool logic)
{
logic_ = logic;
setParameter("Logic", logic ? "true" : "false");
}
std::string ExecuteScriptRequest::getScript()const
{
return script_;
}
void ExecuteScriptRequest::setScript(const std::string& script)
{
script_ = script;
setParameter("Script", script);
}
long ExecuteScriptRequest::getTid()const
{
return tid_;
}
void ExecuteScriptRequest::setTid(long tid)
{
tid_ = tid;
setParameter("Tid", std::to_string(tid));
}

View File

@@ -0,0 +1,88 @@
/*
* 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/dms-enterprise/model/ExecuteScriptResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Dms_enterprise;
using namespace AlibabaCloud::Dms_enterprise::Model;
ExecuteScriptResult::ExecuteScriptResult() :
ServiceResult()
{}
ExecuteScriptResult::ExecuteScriptResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
ExecuteScriptResult::~ExecuteScriptResult()
{}
void ExecuteScriptResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
auto allResultsNode = value["Results"]["Result"];
for (auto valueResultsResult : allResultsNode)
{
Result resultsObject;
if(!valueResultsResult["RowCount"].isNull())
resultsObject.rowCount = std::stol(valueResultsResult["RowCount"].asString());
if(!valueResultsResult["Success"].isNull())
resultsObject.success = valueResultsResult["Success"].asString() == "true";
if(!valueResultsResult["Message"].isNull())
resultsObject.message = valueResultsResult["Message"].asString();
auto allColumnNames = value["ColumnNames"]["ColumnNames"];
for (auto value : allColumnNames)
resultsObject.columnNames.push_back(value.asString());
auto allRows = value["Rows"]["Rows"];
for (auto value : allRows)
resultsObject.rows.push_back(value.asString());
results_.push_back(resultsObject);
}
if(!value["Success"].isNull())
success_ = value["Success"].asString() == "true";
if(!value["ErrorMessage"].isNull())
errorMessage_ = value["ErrorMessage"].asString();
if(!value["ErrorCode"].isNull())
errorCode_ = value["ErrorCode"].asString();
}
std::vector<ExecuteScriptResult::Result> ExecuteScriptResult::getResults()const
{
return results_;
}
std::string ExecuteScriptResult::getErrorCode()const
{
return errorCode_;
}
std::string ExecuteScriptResult::getErrorMessage()const
{
return errorMessage_;
}
bool ExecuteScriptResult::getSuccess()const
{
return success_;
}