Support sg for region.
This commit is contained in:
@@ -87,3 +87,39 @@ SafClient::ExecuteRequestOutcomeCallable SafClient::executeRequestCallable(const
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
SafClient::ExecuteRequestSGOutcome SafClient::executeRequestSG(const ExecuteRequestSGRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
if (!endpointOutcome.isSuccess())
|
||||
return ExecuteRequestSGOutcome(endpointOutcome.error());
|
||||
|
||||
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return ExecuteRequestSGOutcome(ExecuteRequestSGResult(outcome.result()));
|
||||
else
|
||||
return ExecuteRequestSGOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void SafClient::executeRequestSGAsync(const ExecuteRequestSGRequest& request, const ExecuteRequestSGAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
handler(this, request, executeRequestSG(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
SafClient::ExecuteRequestSGOutcomeCallable SafClient::executeRequestSGCallable(const ExecuteRequestSGRequest &request) const
|
||||
{
|
||||
auto task = std::make_shared<std::packaged_task<ExecuteRequestSGOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
return this->executeRequestSG(request);
|
||||
});
|
||||
|
||||
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
using AlibabaCloud::Saf::Model::ExecuteRequestRequest;
|
||||
|
||||
ExecuteRequestRequest::ExecuteRequestRequest() :
|
||||
RpcServiceRequest("saf", "2018-09-19", "ExecuteRequest")
|
||||
RpcServiceRequest("saf", "2019-05-21", "ExecuteRequest")
|
||||
{
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
@@ -39,17 +39,12 @@ void ExecuteRequestResult::parse(const std::string &payload)
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
auto dataNode = value["Data"];
|
||||
if(!dataNode["Tags"].isNull())
|
||||
data_.tags = dataNode["Tags"].asString();
|
||||
if(!dataNode["Score"].isNull())
|
||||
data_.score = dataNode["Score"].asString();
|
||||
if(!dataNode["Extend"].isNull())
|
||||
data_.extend = dataNode["Extend"].asString();
|
||||
if(!value["Code"].isNull())
|
||||
code_ = std::stoi(value["Code"].asString());
|
||||
if(!value["Message"].isNull())
|
||||
message_ = value["Message"].asString();
|
||||
if(!value["Data"].isNull())
|
||||
data_ = value["Data"].asString();
|
||||
|
||||
}
|
||||
|
||||
@@ -58,7 +53,7 @@ std::string ExecuteRequestResult::getMessage()const
|
||||
return message_;
|
||||
}
|
||||
|
||||
ExecuteRequestResult::Data ExecuteRequestResult::getData()const
|
||||
std::string ExecuteRequestResult::getData()const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
51
saf/src/model/ExecuteRequestSGRequest.cc
Normal file
51
saf/src/model/ExecuteRequestSGRequest.cc
Normal 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/saf/model/ExecuteRequestSGRequest.h>
|
||||
|
||||
using AlibabaCloud::Saf::Model::ExecuteRequestSGRequest;
|
||||
|
||||
ExecuteRequestSGRequest::ExecuteRequestSGRequest() :
|
||||
RpcServiceRequest("saf", "2019-05-21", "ExecuteRequestSG")
|
||||
{
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
ExecuteRequestSGRequest::~ExecuteRequestSGRequest()
|
||||
{}
|
||||
|
||||
std::string ExecuteRequestSGRequest::getServiceParameters()const
|
||||
{
|
||||
return serviceParameters_;
|
||||
}
|
||||
|
||||
void ExecuteRequestSGRequest::setServiceParameters(const std::string& serviceParameters)
|
||||
{
|
||||
serviceParameters_ = serviceParameters;
|
||||
setParameter("ServiceParameters", serviceParameters);
|
||||
}
|
||||
|
||||
std::string ExecuteRequestSGRequest::getService()const
|
||||
{
|
||||
return service_;
|
||||
}
|
||||
|
||||
void ExecuteRequestSGRequest::setService(const std::string& service)
|
||||
{
|
||||
service_ = service;
|
||||
setParameter("Service", service);
|
||||
}
|
||||
|
||||
65
saf/src/model/ExecuteRequestSGResult.cc
Normal file
65
saf/src/model/ExecuteRequestSGResult.cc
Normal 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.
|
||||
*/
|
||||
|
||||
#include <alibabacloud/saf/model/ExecuteRequestSGResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Saf;
|
||||
using namespace AlibabaCloud::Saf::Model;
|
||||
|
||||
ExecuteRequestSGResult::ExecuteRequestSGResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
ExecuteRequestSGResult::ExecuteRequestSGResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
ExecuteRequestSGResult::~ExecuteRequestSGResult()
|
||||
{}
|
||||
|
||||
void ExecuteRequestSGResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
if(!value["Code"].isNull())
|
||||
code_ = std::stoi(value["Code"].asString());
|
||||
if(!value["Message"].isNull())
|
||||
message_ = value["Message"].asString();
|
||||
if(!value["Data"].isNull())
|
||||
data_ = value["Data"].asString();
|
||||
|
||||
}
|
||||
|
||||
std::string ExecuteRequestSGResult::getMessage()const
|
||||
{
|
||||
return message_;
|
||||
}
|
||||
|
||||
std::string ExecuteRequestSGResult::getData()const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
int ExecuteRequestSGResult::getCode()const
|
||||
{
|
||||
return code_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user