Support certificate translate.

This commit is contained in:
sdk-team
2020-03-11 15:45:45 +08:00
parent f41733beaa
commit dacb2ef983
14 changed files with 330 additions and 9 deletions

View File

@@ -1,3 +1,6 @@
2020-03-11 Version: 1.36.314
- Support certificate translate.
2020-03-10 Version: 1.36.313
- Add ExportTas apis.

View File

@@ -1 +1 @@
1.36.313
1.36.314

View File

@@ -27,6 +27,8 @@ set(alimt_public_header_model
include/alibabacloud/alimt/model/GetDocTranslateTaskResult.h
include/alibabacloud/alimt/model/TranslateRequest.h
include/alibabacloud/alimt/model/TranslateResult.h
include/alibabacloud/alimt/model/TranslateCertificateRequest.h
include/alibabacloud/alimt/model/TranslateCertificateResult.h
include/alibabacloud/alimt/model/TranslateECommerceRequest.h
include/alibabacloud/alimt/model/TranslateECommerceResult.h
include/alibabacloud/alimt/model/TranslateGeneralRequest.h
@@ -40,6 +42,8 @@ set(alimt_src
src/model/GetDocTranslateTaskResult.cc
src/model/TranslateRequest.cc
src/model/TranslateResult.cc
src/model/TranslateCertificateRequest.cc
src/model/TranslateCertificateResult.cc
src/model/TranslateECommerceRequest.cc
src/model/TranslateECommerceResult.cc
src/model/TranslateGeneralRequest.cc

View File

@@ -28,6 +28,8 @@
#include "model/GetDocTranslateTaskResult.h"
#include "model/TranslateRequest.h"
#include "model/TranslateResult.h"
#include "model/TranslateCertificateRequest.h"
#include "model/TranslateCertificateResult.h"
#include "model/TranslateECommerceRequest.h"
#include "model/TranslateECommerceResult.h"
#include "model/TranslateGeneralRequest.h"
@@ -50,6 +52,9 @@ namespace AlibabaCloud
typedef Outcome<Error, Model::TranslateResult> TranslateOutcome;
typedef std::future<TranslateOutcome> TranslateOutcomeCallable;
typedef std::function<void(const AlimtClient*, const Model::TranslateRequest&, const TranslateOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> TranslateAsyncHandler;
typedef Outcome<Error, Model::TranslateCertificateResult> TranslateCertificateOutcome;
typedef std::future<TranslateCertificateOutcome> TranslateCertificateOutcomeCallable;
typedef std::function<void(const AlimtClient*, const Model::TranslateCertificateRequest&, const TranslateCertificateOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> TranslateCertificateAsyncHandler;
typedef Outcome<Error, Model::TranslateECommerceResult> TranslateECommerceOutcome;
typedef std::future<TranslateECommerceOutcome> TranslateECommerceOutcomeCallable;
typedef std::function<void(const AlimtClient*, const Model::TranslateECommerceRequest&, const TranslateECommerceOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> TranslateECommerceAsyncHandler;
@@ -70,6 +75,9 @@ namespace AlibabaCloud
TranslateOutcome translate(const Model::TranslateRequest &request)const;
void translateAsync(const Model::TranslateRequest& request, const TranslateAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
TranslateOutcomeCallable translateCallable(const Model::TranslateRequest& request) const;
TranslateCertificateOutcome translateCertificate(const Model::TranslateCertificateRequest &request)const;
void translateCertificateAsync(const Model::TranslateCertificateRequest& request, const TranslateCertificateAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
TranslateCertificateOutcomeCallable translateCertificateCallable(const Model::TranslateCertificateRequest& request) const;
TranslateECommerceOutcome translateECommerce(const Model::TranslateECommerceRequest &request)const;
void translateECommerceAsync(const Model::TranslateECommerceRequest& request, const TranslateECommerceAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
TranslateECommerceOutcomeCallable translateECommerceCallable(const Model::TranslateECommerceRequest& request) const;

View File

@@ -0,0 +1,60 @@
/*
* 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_ALIMT_MODEL_TRANSLATECERTIFICATEREQUEST_H_
#define ALIBABACLOUD_ALIMT_MODEL_TRANSLATECERTIFICATEREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/alimt/AlimtExport.h>
namespace AlibabaCloud
{
namespace Alimt
{
namespace Model
{
class ALIBABACLOUD_ALIMT_EXPORT TranslateCertificateRequest : public RpcServiceRequest
{
public:
TranslateCertificateRequest();
~TranslateCertificateRequest();
std::string getSourceLanguage()const;
void setSourceLanguage(const std::string& sourceLanguage);
std::string getCertificateType()const;
void setCertificateType(const std::string& certificateType);
std::string getResultType()const;
void setResultType(const std::string& resultType);
std::string getImageUrl()const;
void setImageUrl(const std::string& imageUrl);
std::string getTargetLanguage()const;
void setTargetLanguage(const std::string& targetLanguage);
private:
std::string sourceLanguage_;
std::string certificateType_;
std::string resultType_;
std::string imageUrl_;
std::string targetLanguage_;
};
}
}
}
#endif // !ALIBABACLOUD_ALIMT_MODEL_TRANSLATECERTIFICATEREQUEST_H_

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.
*/
#ifndef ALIBABACLOUD_ALIMT_MODEL_TRANSLATECERTIFICATERESULT_H_
#define ALIBABACLOUD_ALIMT_MODEL_TRANSLATECERTIFICATERESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/alimt/AlimtExport.h>
namespace AlibabaCloud
{
namespace Alimt
{
namespace Model
{
class ALIBABACLOUD_ALIMT_EXPORT TranslateCertificateResult : public ServiceResult
{
public:
struct Data
{
struct CertificateTranslateItemDTO
{
std::string valueTranslation;
std::string keyTranslation;
std::string value;
std::string key;
};
std::vector<CertificateTranslateItemDTO> translatedValues;
};
TranslateCertificateResult();
explicit TranslateCertificateResult(const std::string &payload);
~TranslateCertificateResult();
Data getData()const;
protected:
void parse(const std::string &payload);
private:
Data data_;
};
}
}
}
#endif // !ALIBABACLOUD_ALIMT_MODEL_TRANSLATECERTIFICATERESULT_H_

View File

@@ -31,21 +31,21 @@ AlimtClient::AlimtClient(const Credentials &credentials, const ClientConfigurati
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, "alimt");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "alimtct");
}
AlimtClient::AlimtClient(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, "alimt");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "alimtct");
}
AlimtClient::AlimtClient(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, "alimt");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "alimtct");
}
AlimtClient::~AlimtClient()
@@ -159,6 +159,42 @@ AlimtClient::TranslateOutcomeCallable AlimtClient::translateCallable(const Trans
return task->get_future();
}
AlimtClient::TranslateCertificateOutcome AlimtClient::translateCertificate(const TranslateCertificateRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return TranslateCertificateOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return TranslateCertificateOutcome(TranslateCertificateResult(outcome.result()));
else
return TranslateCertificateOutcome(outcome.error());
}
void AlimtClient::translateCertificateAsync(const TranslateCertificateRequest& request, const TranslateCertificateAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, translateCertificate(request), context);
};
asyncExecute(new Runnable(fn));
}
AlimtClient::TranslateCertificateOutcomeCallable AlimtClient::translateCertificateCallable(const TranslateCertificateRequest &request) const
{
auto task = std::make_shared<std::packaged_task<TranslateCertificateOutcome()>>(
[this, request]()
{
return this->translateCertificate(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
AlimtClient::TranslateECommerceOutcome AlimtClient::translateECommerce(const TranslateECommerceRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();

View File

@@ -21,7 +21,7 @@ using AlibabaCloud::Alimt::Model::CreateDocTranslateTaskRequest;
CreateDocTranslateTaskRequest::CreateDocTranslateTaskRequest() :
RpcServiceRequest("alimt", "2018-10-12", "CreateDocTranslateTask")
{
setMethod(HttpRequest::Method::POST);
setMethod(HttpRequest::Method::Post);
}
CreateDocTranslateTaskRequest::~CreateDocTranslateTaskRequest()

View File

@@ -21,7 +21,7 @@ using AlibabaCloud::Alimt::Model::GetDocTranslateTaskRequest;
GetDocTranslateTaskRequest::GetDocTranslateTaskRequest() :
RpcServiceRequest("alimt", "2018-10-12", "GetDocTranslateTask")
{
setMethod(HttpRequest::Method::GET);
setMethod(HttpRequest::Method::Get);
}
GetDocTranslateTaskRequest::~GetDocTranslateTaskRequest()

View File

@@ -0,0 +1,84 @@
/*
* 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/alimt/model/TranslateCertificateRequest.h>
using AlibabaCloud::Alimt::Model::TranslateCertificateRequest;
TranslateCertificateRequest::TranslateCertificateRequest() :
RpcServiceRequest("alimt", "2018-10-12", "TranslateCertificate")
{
setMethod(HttpRequest::Method::Post);
}
TranslateCertificateRequest::~TranslateCertificateRequest()
{}
std::string TranslateCertificateRequest::getSourceLanguage()const
{
return sourceLanguage_;
}
void TranslateCertificateRequest::setSourceLanguage(const std::string& sourceLanguage)
{
sourceLanguage_ = sourceLanguage;
setBodyParameter("SourceLanguage", sourceLanguage);
}
std::string TranslateCertificateRequest::getCertificateType()const
{
return certificateType_;
}
void TranslateCertificateRequest::setCertificateType(const std::string& certificateType)
{
certificateType_ = certificateType;
setBodyParameter("CertificateType", certificateType);
}
std::string TranslateCertificateRequest::getResultType()const
{
return resultType_;
}
void TranslateCertificateRequest::setResultType(const std::string& resultType)
{
resultType_ = resultType;
setBodyParameter("ResultType", resultType);
}
std::string TranslateCertificateRequest::getImageUrl()const
{
return imageUrl_;
}
void TranslateCertificateRequest::setImageUrl(const std::string& imageUrl)
{
imageUrl_ = imageUrl;
setBodyParameter("ImageUrl", imageUrl);
}
std::string TranslateCertificateRequest::getTargetLanguage()const
{
return targetLanguage_;
}
void TranslateCertificateRequest::setTargetLanguage(const std::string& targetLanguage)
{
targetLanguage_ = targetLanguage;
setBodyParameter("TargetLanguage", targetLanguage);
}

View File

@@ -0,0 +1,64 @@
/*
* 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/alimt/model/TranslateCertificateResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Alimt;
using namespace AlibabaCloud::Alimt::Model;
TranslateCertificateResult::TranslateCertificateResult() :
ServiceResult()
{}
TranslateCertificateResult::TranslateCertificateResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
TranslateCertificateResult::~TranslateCertificateResult()
{}
void TranslateCertificateResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
auto dataNode = value["Data"];
auto allTranslatedValuesNode = dataNode["TranslatedValues"]["CertificateTranslateItemDTO"];
for (auto dataNodeTranslatedValuesCertificateTranslateItemDTO : allTranslatedValuesNode)
{
Data::CertificateTranslateItemDTO certificateTranslateItemDTOObject;
if(!dataNodeTranslatedValuesCertificateTranslateItemDTO["Key"].isNull())
certificateTranslateItemDTOObject.key = dataNodeTranslatedValuesCertificateTranslateItemDTO["Key"].asString();
if(!dataNodeTranslatedValuesCertificateTranslateItemDTO["Value"].isNull())
certificateTranslateItemDTOObject.value = dataNodeTranslatedValuesCertificateTranslateItemDTO["Value"].asString();
if(!dataNodeTranslatedValuesCertificateTranslateItemDTO["ValueTranslation"].isNull())
certificateTranslateItemDTOObject.valueTranslation = dataNodeTranslatedValuesCertificateTranslateItemDTO["ValueTranslation"].asString();
if(!dataNodeTranslatedValuesCertificateTranslateItemDTO["KeyTranslation"].isNull())
certificateTranslateItemDTOObject.keyTranslation = dataNodeTranslatedValuesCertificateTranslateItemDTO["KeyTranslation"].asString();
data_.translatedValues.push_back(certificateTranslateItemDTOObject);
}
}
TranslateCertificateResult::Data TranslateCertificateResult::getData()const
{
return data_;
}

View File

@@ -21,7 +21,7 @@ using AlibabaCloud::Alimt::Model::TranslateECommerceRequest;
TranslateECommerceRequest::TranslateECommerceRequest() :
RpcServiceRequest("alimt", "2018-10-12", "TranslateECommerce")
{
setMethod(HttpRequest::Method::POST);
setMethod(HttpRequest::Method::Post);
}
TranslateECommerceRequest::~TranslateECommerceRequest()

View File

@@ -21,7 +21,7 @@ using AlibabaCloud::Alimt::Model::TranslateGeneralRequest;
TranslateGeneralRequest::TranslateGeneralRequest() :
RpcServiceRequest("alimt", "2018-10-12", "TranslateGeneral")
{
setMethod(HttpRequest::Method::POST);
setMethod(HttpRequest::Method::Post);
}
TranslateGeneralRequest::~TranslateGeneralRequest()

View File

@@ -21,7 +21,7 @@ using AlibabaCloud::Alimt::Model::TranslateRequest;
TranslateRequest::TranslateRequest() :
RpcServiceRequest("alimt", "2018-10-12", "Translate")
{
setMethod(HttpRequest::Method::POST);
setMethod(HttpRequest::Method::Post);
}
TranslateRequest::~TranslateRequest()