Support Saf For ExecuteExtendService.

This commit is contained in:
sdk-team
2020-07-01 15:12:17 +08:00
parent 5a451d16d4
commit 97918475fb
9 changed files with 314 additions and 4 deletions

View File

@@ -1,3 +1,6 @@
2020-07-01 Version: 1.36.488
- Support Saf For ExecuteExtendService.
2020-06-30 Version: 1.36.487
- Add ListMetrics API.

View File

@@ -1 +1 @@
1.36.487
1.36.488

View File

@@ -21,6 +21,8 @@ set(saf_public_header
include/alibabacloud/saf/SafExport.h )
set(saf_public_header_model
include/alibabacloud/saf/model/ExecuteExtendServiceRequest.h
include/alibabacloud/saf/model/ExecuteExtendServiceResult.h
include/alibabacloud/saf/model/ExecuteRequestRequest.h
include/alibabacloud/saf/model/ExecuteRequestResult.h
include/alibabacloud/saf/model/ExecuteRequestSGRequest.h
@@ -28,6 +30,8 @@ set(saf_public_header_model
set(saf_src
src/SafClient.cc
src/model/ExecuteExtendServiceRequest.cc
src/model/ExecuteExtendServiceResult.cc
src/model/ExecuteRequestRequest.cc
src/model/ExecuteRequestResult.cc
src/model/ExecuteRequestSGRequest.cc

View File

@@ -22,6 +22,8 @@
#include <alibabacloud/core/EndpointProvider.h>
#include <alibabacloud/core/RpcServiceClient.h>
#include "SafExport.h"
#include "model/ExecuteExtendServiceRequest.h"
#include "model/ExecuteExtendServiceResult.h"
#include "model/ExecuteRequestRequest.h"
#include "model/ExecuteRequestResult.h"
#include "model/ExecuteRequestSGRequest.h"
@@ -35,6 +37,9 @@ namespace AlibabaCloud
class ALIBABACLOUD_SAF_EXPORT SafClient : public RpcServiceClient
{
public:
typedef Outcome<Error, Model::ExecuteExtendServiceResult> ExecuteExtendServiceOutcome;
typedef std::future<ExecuteExtendServiceOutcome> ExecuteExtendServiceOutcomeCallable;
typedef std::function<void(const SafClient*, const Model::ExecuteExtendServiceRequest&, const ExecuteExtendServiceOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ExecuteExtendServiceAsyncHandler;
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;
@@ -46,6 +51,9 @@ namespace AlibabaCloud
SafClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
SafClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration);
~SafClient();
ExecuteExtendServiceOutcome executeExtendService(const Model::ExecuteExtendServiceRequest &request)const;
void executeExtendServiceAsync(const Model::ExecuteExtendServiceRequest& request, const ExecuteExtendServiceAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
ExecuteExtendServiceOutcomeCallable executeExtendServiceCallable(const Model::ExecuteExtendServiceRequest& request) const;
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;

View File

@@ -0,0 +1,54 @@
/*
* 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_EXECUTEEXTENDSERVICEREQUEST_H_
#define ALIBABACLOUD_SAF_MODEL_EXECUTEEXTENDSERVICEREQUEST_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 ExecuteExtendServiceRequest : public RpcServiceRequest
{
public:
ExecuteExtendServiceRequest();
~ExecuteExtendServiceRequest();
std::string getServiceParameters()const;
void setServiceParameters(const std::string& serviceParameters);
std::string getService()const;
void setService(const std::string& service);
std::string getRegion()const;
void setRegion(const std::string& region);
private:
std::string serviceParameters_;
std::string service_;
std::string region_;
};
}
}
}
#endif // !ALIBABACLOUD_SAF_MODEL_EXECUTEEXTENDSERVICEREQUEST_H_

View File

@@ -0,0 +1,63 @@
/*
* 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_EXECUTEEXTENDSERVICERESULT_H_
#define ALIBABACLOUD_SAF_MODEL_EXECUTEEXTENDSERVICERESULT_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 ExecuteExtendServiceResult : public ServiceResult
{
public:
struct Data
{
std::string invokeResult;
};
ExecuteExtendServiceResult();
explicit ExecuteExtendServiceResult(const std::string &payload);
~ExecuteExtendServiceResult();
std::string getMessage()const;
std::string getHttpStatusCode()const;
Data getData()const;
std::string getCode()const;
bool getSuccess()const;
protected:
void parse(const std::string &payload);
private:
std::string message_;
std::string httpStatusCode_;
Data data_;
std::string code_;
bool success_;
};
}
}
}
#endif // !ALIBABACLOUD_SAF_MODEL_EXECUTEEXTENDSERVICERESULT_H_

View File

@@ -31,26 +31,62 @@ SafClient::SafClient(const Credentials &credentials, const ClientConfiguration &
RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(credentials), configuration)
{
auto locationClient = std::make_shared<LocationClient>(credentials, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "saf");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "SAF");
}
SafClient::SafClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration)
{
auto locationClient = std::make_shared<LocationClient>(credentialsProvider, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "saf");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "SAF");
}
SafClient::SafClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(accessKeyId, accessKeySecret), configuration)
{
auto locationClient = std::make_shared<LocationClient>(accessKeyId, accessKeySecret, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "saf");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "SAF");
}
SafClient::~SafClient()
{}
SafClient::ExecuteExtendServiceOutcome SafClient::executeExtendService(const ExecuteExtendServiceRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return ExecuteExtendServiceOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return ExecuteExtendServiceOutcome(ExecuteExtendServiceResult(outcome.result()));
else
return ExecuteExtendServiceOutcome(outcome.error());
}
void SafClient::executeExtendServiceAsync(const ExecuteExtendServiceRequest& request, const ExecuteExtendServiceAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, executeExtendService(request), context);
};
asyncExecute(new Runnable(fn));
}
SafClient::ExecuteExtendServiceOutcomeCallable SafClient::executeExtendServiceCallable(const ExecuteExtendServiceRequest &request) const
{
auto task = std::make_shared<std::packaged_task<ExecuteExtendServiceOutcome()>>(
[this, request]()
{
return this->executeExtendService(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
SafClient::ExecuteRequestOutcome SafClient::executeRequest(const ExecuteRequestRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();

View File

@@ -0,0 +1,62 @@
/*
* 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/ExecuteExtendServiceRequest.h>
using AlibabaCloud::Saf::Model::ExecuteExtendServiceRequest;
ExecuteExtendServiceRequest::ExecuteExtendServiceRequest() :
RpcServiceRequest("saf", "2019-05-21", "ExecuteExtendService")
{
setMethod(HttpRequest::Method::Post);
}
ExecuteExtendServiceRequest::~ExecuteExtendServiceRequest()
{}
std::string ExecuteExtendServiceRequest::getServiceParameters()const
{
return serviceParameters_;
}
void ExecuteExtendServiceRequest::setServiceParameters(const std::string& serviceParameters)
{
serviceParameters_ = serviceParameters;
setParameter("ServiceParameters", serviceParameters);
}
std::string ExecuteExtendServiceRequest::getService()const
{
return service_;
}
void ExecuteExtendServiceRequest::setService(const std::string& service)
{
service_ = service;
setParameter("Service", service);
}
std::string ExecuteExtendServiceRequest::getRegion()const
{
return region_;
}
void ExecuteExtendServiceRequest::setRegion(const std::string& region)
{
region_ = region;
setParameter("Region", region);
}

View File

@@ -0,0 +1,80 @@
/*
* 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/ExecuteExtendServiceResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Saf;
using namespace AlibabaCloud::Saf::Model;
ExecuteExtendServiceResult::ExecuteExtendServiceResult() :
ServiceResult()
{}
ExecuteExtendServiceResult::ExecuteExtendServiceResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
ExecuteExtendServiceResult::~ExecuteExtendServiceResult()
{}
void ExecuteExtendServiceResult::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["InvokeResult"].isNull())
data_.invokeResult = dataNode["InvokeResult"].asString();
if(!value["Code"].isNull())
code_ = value["Code"].asString();
if(!value["Success"].isNull())
success_ = value["Success"].asString() == "true";
if(!value["Message"].isNull())
message_ = value["Message"].asString();
if(!value["HttpStatusCode"].isNull())
httpStatusCode_ = value["HttpStatusCode"].asString();
}
std::string ExecuteExtendServiceResult::getMessage()const
{
return message_;
}
std::string ExecuteExtendServiceResult::getHttpStatusCode()const
{
return httpStatusCode_;
}
ExecuteExtendServiceResult::Data ExecuteExtendServiceResult::getData()const
{
return data_;
}
std::string ExecuteExtendServiceResult::getCode()const
{
return code_;
}
bool ExecuteExtendServiceResult::getSuccess()const
{
return success_;
}