diff --git a/CHANGELOG b/CHANGELOG index 7ab72ea2d..b44578816 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2020-01-20 Version 1.36.247 +- Release on full language support. + 2020-01-17 Version 1.36.246 - Supported Add the history event signature function. diff --git a/VERSION b/VERSION index ce422ad07..e485466d8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.36.246 \ No newline at end of file +1.36.247 \ No newline at end of file diff --git a/hiknoengine/CMakeLists.txt b/hiknoengine/CMakeLists.txt new file mode 100644 index 000000000..0c83d00aa --- /dev/null +++ b/hiknoengine/CMakeLists.txt @@ -0,0 +1,86 @@ +# +# 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. +# + +set(public_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/../include) + +set(hiknoengine_public_header + include/alibabacloud/hiknoengine/HiknoengineClient.h + include/alibabacloud/hiknoengine/HiknoengineExport.h ) + +set(hiknoengine_public_header_model + include/alibabacloud/hiknoengine/model/TranslateTextRequest.h + include/alibabacloud/hiknoengine/model/TranslateTextResult.h ) + +set(hiknoengine_src + src/HiknoengineClient.cc + src/model/TranslateTextRequest.cc + src/model/TranslateTextResult.cc ) + +add_library(hiknoengine ${LIB_TYPE} + ${hiknoengine_public_header} + ${hiknoengine_public_header_model} + ${hiknoengine_src}) + +set_target_properties(hiknoengine + PROPERTIES + LINKER_LANGUAGE CXX + ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin + OUTPUT_NAME ${TARGET_OUTPUT_NAME_PREFIX}hiknoengine + ) + +if(${LIB_TYPE} STREQUAL "SHARED") + set_target_properties(hiknoengine + PROPERTIES + DEFINE_SYMBOL ALIBABACLOUD_HIKNOENGINE_LIBRARY) +endif() + +target_include_directories(hiknoengine + PRIVATE include + ${CMAKE_SOURCE_DIR}/core/include + ) +target_link_libraries(hiknoengine + core) + +if(CMAKE_HOST_WIN32) + ExternalProject_Get_Property(jsoncpp INSTALL_DIR) + set(jsoncpp_install_dir ${INSTALL_DIR}) + add_dependencies(hiknoengine + jsoncpp) + target_include_directories(hiknoengine + PRIVATE ${jsoncpp_install_dir}/include) + target_link_libraries(hiknoengine + ${jsoncpp_install_dir}/lib/jsoncpp.lib) + set_target_properties(hiknoengine + PROPERTIES + COMPILE_OPTIONS "/bigobj") +else() + target_include_directories(hiknoengine + PRIVATE /usr/include/jsoncpp) + target_link_libraries(hiknoengine + jsoncpp) +endif() + +install(FILES ${hiknoengine_public_header} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/hiknoengine) +install(FILES ${hiknoengine_public_header_model} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/hiknoengine/model) +install(TARGETS hiknoengine + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) \ No newline at end of file diff --git a/hiknoengine/include/alibabacloud/hiknoengine/HiknoengineClient.h b/hiknoengine/include/alibabacloud/hiknoengine/HiknoengineClient.h new file mode 100644 index 000000000..4b85a383d --- /dev/null +++ b/hiknoengine/include/alibabacloud/hiknoengine/HiknoengineClient.h @@ -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_HIKNOENGINE_HIKNOENGINECLIENT_H_ +#define ALIBABACLOUD_HIKNOENGINE_HIKNOENGINECLIENT_H_ + +#include +#include +#include +#include +#include "HiknoengineExport.h" +#include "model/TranslateTextRequest.h" +#include "model/TranslateTextResult.h" + + +namespace AlibabaCloud +{ + namespace Hiknoengine + { + class ALIBABACLOUD_HIKNOENGINE_EXPORT HiknoengineClient : public RpcServiceClient + { + public: + typedef Outcome TranslateTextOutcome; + typedef std::future TranslateTextOutcomeCallable; + typedef std::function&)> TranslateTextAsyncHandler; + + HiknoengineClient(const Credentials &credentials, const ClientConfiguration &configuration); + HiknoengineClient(const std::shared_ptr &credentialsProvider, const ClientConfiguration &configuration); + HiknoengineClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration); + ~HiknoengineClient(); + TranslateTextOutcome translateText(const Model::TranslateTextRequest &request)const; + void translateTextAsync(const Model::TranslateTextRequest& request, const TranslateTextAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + TranslateTextOutcomeCallable translateTextCallable(const Model::TranslateTextRequest& request) const; + + private: + std::shared_ptr endpointProvider_; + }; + } +} + +#endif // !ALIBABACLOUD_HIKNOENGINE_HIKNOENGINECLIENT_H_ diff --git a/hiknoengine/include/alibabacloud/hiknoengine/HiknoengineExport.h b/hiknoengine/include/alibabacloud/hiknoengine/HiknoengineExport.h new file mode 100644 index 000000000..63f063c7e --- /dev/null +++ b/hiknoengine/include/alibabacloud/hiknoengine/HiknoengineExport.h @@ -0,0 +1,32 @@ +/* + * 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_HIKNOENGINE_HIKNOENGINEEXPORT_H_ +#define ALIBABACLOUD_HIKNOENGINE_HIKNOENGINEEXPORT_H_ + +#include + +#if defined(ALIBABACLOUD_SHARED) +# if defined(ALIBABACLOUD_HIKNOENGINE_LIBRARY) +# define ALIBABACLOUD_HIKNOENGINE_EXPORT ALIBABACLOUD_DECL_EXPORT +# else +# define ALIBABACLOUD_HIKNOENGINE_EXPORT ALIBABACLOUD_DECL_IMPORT +# endif +#else +# define ALIBABACLOUD_HIKNOENGINE_EXPORT +#endif + +#endif // !ALIBABACLOUD_HIKNOENGINE_HIKNOENGINEEXPORT_H_ \ No newline at end of file diff --git a/hiknoengine/include/alibabacloud/hiknoengine/model/TranslateTextRequest.h b/hiknoengine/include/alibabacloud/hiknoengine/model/TranslateTextRequest.h new file mode 100644 index 000000000..c70cda36e --- /dev/null +++ b/hiknoengine/include/alibabacloud/hiknoengine/model/TranslateTextRequest.h @@ -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_HIKNOENGINE_MODEL_TRANSLATETEXTREQUEST_H_ +#define ALIBABACLOUD_HIKNOENGINE_MODEL_TRANSLATETEXTREQUEST_H_ + +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Hiknoengine + { + namespace Model + { + class ALIBABACLOUD_HIKNOENGINE_EXPORT TranslateTextRequest : public RpcServiceRequest + { + + public: + TranslateTextRequest(); + ~TranslateTextRequest(); + + std::string getFromLang()const; + void setFromLang(const std::string& fromLang); + std::string getToLang()const; + void setToLang(const std::string& toLang); + std::string getText()const; + void setText(const std::string& text); + + private: + std::string fromLang_; + std::string toLang_; + std::string text_; + + }; + } + } +} +#endif // !ALIBABACLOUD_HIKNOENGINE_MODEL_TRANSLATETEXTREQUEST_H_ \ No newline at end of file diff --git a/hiknoengine/include/alibabacloud/hiknoengine/model/TranslateTextResult.h b/hiknoengine/include/alibabacloud/hiknoengine/model/TranslateTextResult.h new file mode 100644 index 000000000..74ec24608 --- /dev/null +++ b/hiknoengine/include/alibabacloud/hiknoengine/model/TranslateTextResult.h @@ -0,0 +1,59 @@ +/* + * 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_HIKNOENGINE_MODEL_TRANSLATETEXTRESULT_H_ +#define ALIBABACLOUD_HIKNOENGINE_MODEL_TRANSLATETEXTRESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Hiknoengine + { + namespace Model + { + class ALIBABACLOUD_HIKNOENGINE_EXPORT TranslateTextResult : public ServiceResult + { + public: + struct Data + { + std::string text; + }; + + + TranslateTextResult(); + explicit TranslateTextResult(const std::string &payload); + ~TranslateTextResult(); + std::string getMessage()const; + Data getData()const; + std::string getCode()const; + + protected: + void parse(const std::string &payload); + private: + std::string message_; + Data data_; + std::string code_; + + }; + } + } +} +#endif // !ALIBABACLOUD_HIKNOENGINE_MODEL_TRANSLATETEXTRESULT_H_ \ No newline at end of file diff --git a/hiknoengine/src/HiknoengineClient.cc b/hiknoengine/src/HiknoengineClient.cc new file mode 100644 index 000000000..b13ca1f1a --- /dev/null +++ b/hiknoengine/src/HiknoengineClient.cc @@ -0,0 +1,89 @@ +/* + * 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 +#include + +using namespace AlibabaCloud; +using namespace AlibabaCloud::Location; +using namespace AlibabaCloud::Hiknoengine; +using namespace AlibabaCloud::Hiknoengine::Model; + +namespace +{ + const std::string SERVICE_NAME = "hiknoengine"; +} + +HiknoengineClient::HiknoengineClient(const Credentials &credentials, const ClientConfiguration &configuration) : + RpcServiceClient(SERVICE_NAME, std::make_shared(credentials), configuration) +{ + auto locationClient = std::make_shared(credentials, configuration); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "hiknoengine"); +} + +HiknoengineClient::HiknoengineClient(const std::shared_ptr& credentialsProvider, const ClientConfiguration & configuration) : + RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration) +{ + auto locationClient = std::make_shared(credentialsProvider, configuration); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "hiknoengine"); +} + +HiknoengineClient::HiknoengineClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) : + RpcServiceClient(SERVICE_NAME, std::make_shared(accessKeyId, accessKeySecret), configuration) +{ + auto locationClient = std::make_shared(accessKeyId, accessKeySecret, configuration); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "hiknoengine"); +} + +HiknoengineClient::~HiknoengineClient() +{} + +HiknoengineClient::TranslateTextOutcome HiknoengineClient::translateText(const TranslateTextRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return TranslateTextOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return TranslateTextOutcome(TranslateTextResult(outcome.result())); + else + return TranslateTextOutcome(outcome.error()); +} + +void HiknoengineClient::translateTextAsync(const TranslateTextRequest& request, const TranslateTextAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, translateText(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +HiknoengineClient::TranslateTextOutcomeCallable HiknoengineClient::translateTextCallable(const TranslateTextRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->translateText(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + diff --git a/hiknoengine/src/model/TranslateTextRequest.cc b/hiknoengine/src/model/TranslateTextRequest.cc new file mode 100644 index 000000000..bd37d5c6d --- /dev/null +++ b/hiknoengine/src/model/TranslateTextRequest.cc @@ -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 + +using AlibabaCloud::Hiknoengine::Model::TranslateTextRequest; + +TranslateTextRequest::TranslateTextRequest() : + RpcServiceRequest("hiknoengine", "2019-06-25", "TranslateText") +{ + setMethod(HttpRequest::Method::Post); +} + +TranslateTextRequest::~TranslateTextRequest() +{} + +std::string TranslateTextRequest::getFromLang()const +{ + return fromLang_; +} + +void TranslateTextRequest::setFromLang(const std::string& fromLang) +{ + fromLang_ = fromLang; + setCoreParameter("FromLang", fromLang); +} + +std::string TranslateTextRequest::getToLang()const +{ + return toLang_; +} + +void TranslateTextRequest::setToLang(const std::string& toLang) +{ + toLang_ = toLang; + setCoreParameter("ToLang", toLang); +} + +std::string TranslateTextRequest::getText()const +{ + return text_; +} + +void TranslateTextRequest::setText(const std::string& text) +{ + text_ = text; + setCoreParameter("Text", text); +} + diff --git a/hiknoengine/src/model/TranslateTextResult.cc b/hiknoengine/src/model/TranslateTextResult.cc new file mode 100644 index 000000000..a5031cde6 --- /dev/null +++ b/hiknoengine/src/model/TranslateTextResult.cc @@ -0,0 +1,66 @@ +/* + * 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 +#include + +using namespace AlibabaCloud::Hiknoengine; +using namespace AlibabaCloud::Hiknoengine::Model; + +TranslateTextResult::TranslateTextResult() : + ServiceResult() +{} + +TranslateTextResult::TranslateTextResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +TranslateTextResult::~TranslateTextResult() +{} + +void TranslateTextResult::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["Text"].isNull()) + data_.text = dataNode["Text"].asString(); + if(!value["Code"].isNull()) + code_ = value["Code"].asString(); + if(!value["Message"].isNull()) + message_ = value["Message"].asString(); + +} + +std::string TranslateTextResult::getMessage()const +{ + return message_; +} + +TranslateTextResult::Data TranslateTextResult::getData()const +{ + return data_; +} + +std::string TranslateTextResult::getCode()const +{ + return code_; +} +