Support sg for region.
This commit is contained in:
@@ -22,12 +22,16 @@ set(saf_public_header
|
||||
|
||||
set(saf_public_header_model
|
||||
include/alibabacloud/saf/model/ExecuteRequestRequest.h
|
||||
include/alibabacloud/saf/model/ExecuteRequestResult.h )
|
||||
include/alibabacloud/saf/model/ExecuteRequestResult.h
|
||||
include/alibabacloud/saf/model/ExecuteRequestSGRequest.h
|
||||
include/alibabacloud/saf/model/ExecuteRequestSGResult.h )
|
||||
|
||||
set(saf_src
|
||||
src/SafClient.cc
|
||||
src/model/ExecuteRequestRequest.cc
|
||||
src/model/ExecuteRequestResult.cc )
|
||||
src/model/ExecuteRequestResult.cc
|
||||
src/model/ExecuteRequestSGRequest.cc
|
||||
src/model/ExecuteRequestSGResult.cc )
|
||||
|
||||
add_library(saf ${LIB_TYPE}
|
||||
${saf_public_header}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "SafExport.h"
|
||||
#include "model/ExecuteRequestRequest.h"
|
||||
#include "model/ExecuteRequestResult.h"
|
||||
#include "model/ExecuteRequestSGRequest.h"
|
||||
#include "model/ExecuteRequestSGResult.h"
|
||||
|
||||
|
||||
namespace AlibabaCloud
|
||||
@@ -36,6 +38,9 @@ namespace AlibabaCloud
|
||||
typedef Outcome<Error, Model::ExecuteRequestResult> ExecuteRequestOutcome;
|
||||
typedef std::future<ExecuteRequestOutcome> ExecuteRequestOutcomeCallable;
|
||||
typedef std::function<void(const SafClient*, const Model::ExecuteRequestRequest&, const ExecuteRequestOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ExecuteRequestAsyncHandler;
|
||||
typedef Outcome<Error, Model::ExecuteRequestSGResult> ExecuteRequestSGOutcome;
|
||||
typedef std::future<ExecuteRequestSGOutcome> ExecuteRequestSGOutcomeCallable;
|
||||
typedef std::function<void(const SafClient*, const Model::ExecuteRequestSGRequest&, const ExecuteRequestSGOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ExecuteRequestSGAsyncHandler;
|
||||
|
||||
SafClient(const Credentials &credentials, const ClientConfiguration &configuration);
|
||||
SafClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
|
||||
@@ -44,6 +49,9 @@ namespace AlibabaCloud
|
||||
ExecuteRequestOutcome executeRequest(const Model::ExecuteRequestRequest &request)const;
|
||||
void executeRequestAsync(const Model::ExecuteRequestRequest& request, const ExecuteRequestAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
ExecuteRequestOutcomeCallable executeRequestCallable(const Model::ExecuteRequestRequest& request) const;
|
||||
ExecuteRequestSGOutcome executeRequestSG(const Model::ExecuteRequestSGRequest &request)const;
|
||||
void executeRequestSGAsync(const Model::ExecuteRequestSGRequest& request, const ExecuteRequestSGAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
ExecuteRequestSGOutcomeCallable executeRequestSGCallable(const Model::ExecuteRequestSGRequest& request) const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<EndpointProvider> endpointProvider_;
|
||||
|
||||
@@ -32,26 +32,20 @@ namespace AlibabaCloud
|
||||
class ALIBABACLOUD_SAF_EXPORT ExecuteRequestResult : public ServiceResult
|
||||
{
|
||||
public:
|
||||
struct Data
|
||||
{
|
||||
std::string score;
|
||||
std::string extend;
|
||||
std::string tags;
|
||||
};
|
||||
|
||||
|
||||
ExecuteRequestResult();
|
||||
explicit ExecuteRequestResult(const std::string &payload);
|
||||
~ExecuteRequestResult();
|
||||
std::string getMessage()const;
|
||||
Data getData()const;
|
||||
std::string getData()const;
|
||||
int getCode()const;
|
||||
|
||||
protected:
|
||||
void parse(const std::string &payload);
|
||||
private:
|
||||
std::string message_;
|
||||
Data data_;
|
||||
std::string data_;
|
||||
int code_;
|
||||
|
||||
};
|
||||
|
||||
51
saf/include/alibabacloud/saf/model/ExecuteRequestSGRequest.h
Normal file
51
saf/include/alibabacloud/saf/model/ExecuteRequestSGRequest.h
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.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_SAF_MODEL_EXECUTEREQUESTSGREQUEST_H_
|
||||
#define ALIBABACLOUD_SAF_MODEL_EXECUTEREQUESTSGREQUEST_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <alibabacloud/core/RpcServiceRequest.h>
|
||||
#include <alibabacloud/saf/SafExport.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Saf
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_SAF_EXPORT ExecuteRequestSGRequest : public RpcServiceRequest
|
||||
{
|
||||
|
||||
public:
|
||||
ExecuteRequestSGRequest();
|
||||
~ExecuteRequestSGRequest();
|
||||
|
||||
std::string getServiceParameters()const;
|
||||
void setServiceParameters(const std::string& serviceParameters);
|
||||
std::string getService()const;
|
||||
void setService(const std::string& service);
|
||||
|
||||
private:
|
||||
std::string serviceParameters_;
|
||||
std::string service_;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_SAF_MODEL_EXECUTEREQUESTSGREQUEST_H_
|
||||
55
saf/include/alibabacloud/saf/model/ExecuteRequestSGResult.h
Normal file
55
saf/include/alibabacloud/saf/model/ExecuteRequestSGResult.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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_SAF_MODEL_EXECUTEREQUESTSGRESULT_H_
|
||||
#define ALIBABACLOUD_SAF_MODEL_EXECUTEREQUESTSGRESULT_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <alibabacloud/core/ServiceResult.h>
|
||||
#include <alibabacloud/saf/SafExport.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Saf
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_SAF_EXPORT ExecuteRequestSGResult : public ServiceResult
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
ExecuteRequestSGResult();
|
||||
explicit ExecuteRequestSGResult(const std::string &payload);
|
||||
~ExecuteRequestSGResult();
|
||||
std::string getMessage()const;
|
||||
std::string getData()const;
|
||||
int getCode()const;
|
||||
|
||||
protected:
|
||||
void parse(const std::string &payload);
|
||||
private:
|
||||
std::string message_;
|
||||
std::string data_;
|
||||
int code_;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_SAF_MODEL_EXECUTEREQUESTSGRESULT_H_
|
||||
@@ -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