Support execute database script via open api.
This commit is contained in:
@@ -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();
|
||||
|
||||
40
dms-enterprise/src/model/CheckFinishMissionRequest.cc
Normal file
40
dms-enterprise/src/model/CheckFinishMissionRequest.cc
Normal 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);
|
||||
}
|
||||
|
||||
72
dms-enterprise/src/model/CheckFinishMissionResult.cc
Normal file
72
dms-enterprise/src/model/CheckFinishMissionResult.cc
Normal 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_;
|
||||
}
|
||||
|
||||
73
dms-enterprise/src/model/ExecuteScriptRequest.cc
Normal file
73
dms-enterprise/src/model/ExecuteScriptRequest.cc
Normal 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));
|
||||
}
|
||||
|
||||
88
dms-enterprise/src/model/ExecuteScriptResult.cc
Normal file
88
dms-enterprise/src/model/ExecuteScriptResult.cc
Normal 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_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user