diff --git a/CHANGELOG b/CHANGELOG index b4373f51c..fe32aad16 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2020-07-30 Version: 1.36.545 +- Supported ChatApp for SDK. + 2020-07-30 Version: 1.36.544 - Generated 2020-06-29 for `alinlp`. diff --git a/VERSION b/VERSION index 6d1150203..8bac6901a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.36.544 \ No newline at end of file +1.36.545 \ No newline at end of file diff --git a/cams/CMakeLists.txt b/cams/CMakeLists.txt new file mode 100644 index 000000000..c4b582ee4 --- /dev/null +++ b/cams/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(cams_public_header + include/alibabacloud/cams/CamsClient.h + include/alibabacloud/cams/CamsExport.h ) + +set(cams_public_header_model + include/alibabacloud/cams/model/SendMessageRequest.h + include/alibabacloud/cams/model/SendMessageResult.h ) + +set(cams_src + src/CamsClient.cc + src/model/SendMessageRequest.cc + src/model/SendMessageResult.cc ) + +add_library(cams ${LIB_TYPE} + ${cams_public_header} + ${cams_public_header_model} + ${cams_src}) + +set_target_properties(cams + 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}cams + ) + +if(${LIB_TYPE} STREQUAL "SHARED") + set_target_properties(cams + PROPERTIES + DEFINE_SYMBOL ALIBABACLOUD_CAMS_LIBRARY) +endif() + +target_include_directories(cams + PRIVATE include + ${CMAKE_SOURCE_DIR}/core/include + ) +target_link_libraries(cams + core) + +if(CMAKE_HOST_WIN32) + ExternalProject_Get_Property(jsoncpp INSTALL_DIR) + set(jsoncpp_install_dir ${INSTALL_DIR}) + add_dependencies(cams + jsoncpp) + target_include_directories(cams + PRIVATE ${jsoncpp_install_dir}/include) + target_link_libraries(cams + ${jsoncpp_install_dir}/lib/jsoncpp.lib) + set_target_properties(cams + PROPERTIES + COMPILE_OPTIONS "/bigobj") +else() + target_include_directories(cams + PRIVATE /usr/include/jsoncpp) + target_link_libraries(cams + jsoncpp) +endif() + +install(FILES ${cams_public_header} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/cams) +install(FILES ${cams_public_header_model} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/cams/model) +install(TARGETS cams + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) \ No newline at end of file diff --git a/cams/include/alibabacloud/cams/CamsClient.h b/cams/include/alibabacloud/cams/CamsClient.h new file mode 100644 index 000000000..701f143c6 --- /dev/null +++ b/cams/include/alibabacloud/cams/CamsClient.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_CAMS_CAMSCLIENT_H_ +#define ALIBABACLOUD_CAMS_CAMSCLIENT_H_ + +#include +#include +#include +#include +#include "CamsExport.h" +#include "model/SendMessageRequest.h" +#include "model/SendMessageResult.h" + + +namespace AlibabaCloud +{ + namespace Cams + { + class ALIBABACLOUD_CAMS_EXPORT CamsClient : public RpcServiceClient + { + public: + typedef Outcome SendMessageOutcome; + typedef std::future SendMessageOutcomeCallable; + typedef std::function&)> SendMessageAsyncHandler; + + CamsClient(const Credentials &credentials, const ClientConfiguration &configuration); + CamsClient(const std::shared_ptr &credentialsProvider, const ClientConfiguration &configuration); + CamsClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration); + ~CamsClient(); + SendMessageOutcome sendMessage(const Model::SendMessageRequest &request)const; + void sendMessageAsync(const Model::SendMessageRequest& request, const SendMessageAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + SendMessageOutcomeCallable sendMessageCallable(const Model::SendMessageRequest& request) const; + + private: + std::shared_ptr endpointProvider_; + }; + } +} + +#endif // !ALIBABACLOUD_CAMS_CAMSCLIENT_H_ diff --git a/cams/include/alibabacloud/cams/CamsExport.h b/cams/include/alibabacloud/cams/CamsExport.h new file mode 100644 index 000000000..3804ec0e4 --- /dev/null +++ b/cams/include/alibabacloud/cams/CamsExport.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_CAMS_CAMSEXPORT_H_ +#define ALIBABACLOUD_CAMS_CAMSEXPORT_H_ + +#include + +#if defined(ALIBABACLOUD_SHARED) +# if defined(ALIBABACLOUD_CAMS_LIBRARY) +# define ALIBABACLOUD_CAMS_EXPORT ALIBABACLOUD_DECL_EXPORT +# else +# define ALIBABACLOUD_CAMS_EXPORT ALIBABACLOUD_DECL_IMPORT +# endif +#else +# define ALIBABACLOUD_CAMS_EXPORT +#endif + +#endif // !ALIBABACLOUD_CAMS_CAMSEXPORT_H_ \ No newline at end of file diff --git a/cams/include/alibabacloud/cams/model/SendMessageRequest.h b/cams/include/alibabacloud/cams/model/SendMessageRequest.h new file mode 100644 index 000000000..73f4ba507 --- /dev/null +++ b/cams/include/alibabacloud/cams/model/SendMessageRequest.h @@ -0,0 +1,75 @@ +/* + * 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_CAMS_MODEL_SENDMESSAGEREQUEST_H_ +#define ALIBABACLOUD_CAMS_MODEL_SENDMESSAGEREQUEST_H_ + +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Cams + { + namespace Model + { + class ALIBABACLOUD_CAMS_EXPORT SendMessageRequest : public RpcServiceRequest + { + + public: + SendMessageRequest(); + ~SendMessageRequest(); + + long getResourceOwnerId()const; + void setResourceOwnerId(long resourceOwnerId); + std::string getTemplateBodyParams()const; + void setTemplateBodyParams(const std::string& templateBodyParams); + std::string getType()const; + void setType(const std::string& type); + std::string getAccessKeyId()const; + void setAccessKeyId(const std::string& accessKeyId); + std::string getChannelType()const; + void setChannelType(const std::string& channelType); + std::string getFrom()const; + void setFrom(const std::string& from); + std::string getResourceOwnerAccount()const; + void setResourceOwnerAccount(const std::string& resourceOwnerAccount); + long getOwnerId()const; + void setOwnerId(long ownerId); + std::string getTo()const; + void setTo(const std::string& to); + std::string getTemplateCode()const; + void setTemplateCode(const std::string& templateCode); + + private: + long resourceOwnerId_; + std::string templateBodyParams_; + std::string type_; + std::string accessKeyId_; + std::string channelType_; + std::string from_; + std::string resourceOwnerAccount_; + long ownerId_; + std::string to_; + std::string templateCode_; + + }; + } + } +} +#endif // !ALIBABACLOUD_CAMS_MODEL_SENDMESSAGEREQUEST_H_ \ No newline at end of file diff --git a/cams/include/alibabacloud/cams/model/SendMessageResult.h b/cams/include/alibabacloud/cams/model/SendMessageResult.h new file mode 100644 index 000000000..925fc61c5 --- /dev/null +++ b/cams/include/alibabacloud/cams/model/SendMessageResult.h @@ -0,0 +1,61 @@ +/* + * 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_CAMS_MODEL_SENDMESSAGERESULT_H_ +#define ALIBABACLOUD_CAMS_MODEL_SENDMESSAGERESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Cams + { + namespace Model + { + class ALIBABACLOUD_CAMS_EXPORT SendMessageResult : public ServiceResult + { + public: + struct Module + { + std::string toId; + std::string fromId; + std::string messageId; + }; + + + SendMessageResult(); + explicit SendMessageResult(const std::string &payload); + ~SendMessageResult(); + Module getModule()const; + std::string getResultMessage()const; + std::string getResultCode()const; + + protected: + void parse(const std::string &payload); + private: + Module module_; + std::string resultMessage_; + std::string resultCode_; + + }; + } + } +} +#endif // !ALIBABACLOUD_CAMS_MODEL_SENDMESSAGERESULT_H_ \ No newline at end of file diff --git a/cams/src/CamsClient.cc b/cams/src/CamsClient.cc new file mode 100644 index 000000000..9f9602f4d --- /dev/null +++ b/cams/src/CamsClient.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::Cams; +using namespace AlibabaCloud::Cams::Model; + +namespace +{ + const std::string SERVICE_NAME = "cams"; +} + +CamsClient::CamsClient(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, "cams"); +} + +CamsClient::CamsClient(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, "cams"); +} + +CamsClient::CamsClient(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, "cams"); +} + +CamsClient::~CamsClient() +{} + +CamsClient::SendMessageOutcome CamsClient::sendMessage(const SendMessageRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return SendMessageOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return SendMessageOutcome(SendMessageResult(outcome.result())); + else + return SendMessageOutcome(outcome.error()); +} + +void CamsClient::sendMessageAsync(const SendMessageRequest& request, const SendMessageAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, sendMessage(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +CamsClient::SendMessageOutcomeCallable CamsClient::sendMessageCallable(const SendMessageRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->sendMessage(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + diff --git a/cams/src/model/SendMessageRequest.cc b/cams/src/model/SendMessageRequest.cc new file mode 100644 index 000000000..14ef1baa7 --- /dev/null +++ b/cams/src/model/SendMessageRequest.cc @@ -0,0 +1,139 @@ +/* + * 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::Cams::Model::SendMessageRequest; + +SendMessageRequest::SendMessageRequest() : + RpcServiceRequest("cams", "2020-06-06", "SendMessage") +{ + setMethod(HttpRequest::Method::Post); +} + +SendMessageRequest::~SendMessageRequest() +{} + +long SendMessageRequest::getResourceOwnerId()const +{ + return resourceOwnerId_; +} + +void SendMessageRequest::setResourceOwnerId(long resourceOwnerId) +{ + resourceOwnerId_ = resourceOwnerId; + setParameter("ResourceOwnerId", std::to_string(resourceOwnerId)); +} + +std::string SendMessageRequest::getTemplateBodyParams()const +{ + return templateBodyParams_; +} + +void SendMessageRequest::setTemplateBodyParams(const std::string& templateBodyParams) +{ + templateBodyParams_ = templateBodyParams; + setParameter("TemplateBodyParams", templateBodyParams); +} + +std::string SendMessageRequest::getType()const +{ + return type_; +} + +void SendMessageRequest::setType(const std::string& type) +{ + type_ = type; + setParameter("Type", type); +} + +std::string SendMessageRequest::getAccessKeyId()const +{ + return accessKeyId_; +} + +void SendMessageRequest::setAccessKeyId(const std::string& accessKeyId) +{ + accessKeyId_ = accessKeyId; + setParameter("AccessKeyId", accessKeyId); +} + +std::string SendMessageRequest::getChannelType()const +{ + return channelType_; +} + +void SendMessageRequest::setChannelType(const std::string& channelType) +{ + channelType_ = channelType; + setParameter("ChannelType", channelType); +} + +std::string SendMessageRequest::getFrom()const +{ + return from_; +} + +void SendMessageRequest::setFrom(const std::string& from) +{ + from_ = from; + setParameter("From", from); +} + +std::string SendMessageRequest::getResourceOwnerAccount()const +{ + return resourceOwnerAccount_; +} + +void SendMessageRequest::setResourceOwnerAccount(const std::string& resourceOwnerAccount) +{ + resourceOwnerAccount_ = resourceOwnerAccount; + setParameter("ResourceOwnerAccount", resourceOwnerAccount); +} + +long SendMessageRequest::getOwnerId()const +{ + return ownerId_; +} + +void SendMessageRequest::setOwnerId(long ownerId) +{ + ownerId_ = ownerId; + setParameter("OwnerId", std::to_string(ownerId)); +} + +std::string SendMessageRequest::getTo()const +{ + return to_; +} + +void SendMessageRequest::setTo(const std::string& to) +{ + to_ = to; + setParameter("To", to); +} + +std::string SendMessageRequest::getTemplateCode()const +{ + return templateCode_; +} + +void SendMessageRequest::setTemplateCode(const std::string& templateCode) +{ + templateCode_ = templateCode; + setParameter("TemplateCode", templateCode); +} + diff --git a/cams/src/model/SendMessageResult.cc b/cams/src/model/SendMessageResult.cc new file mode 100644 index 000000000..c4efbeb3b --- /dev/null +++ b/cams/src/model/SendMessageResult.cc @@ -0,0 +1,70 @@ +/* + * 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::Cams; +using namespace AlibabaCloud::Cams::Model; + +SendMessageResult::SendMessageResult() : + ServiceResult() +{} + +SendMessageResult::SendMessageResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +SendMessageResult::~SendMessageResult() +{} + +void SendMessageResult::parse(const std::string &payload) +{ + Json::Reader reader; + Json::Value value; + reader.parse(payload, value); + setRequestId(value["RequestId"].asString()); + auto moduleNode = value["Module"]; + if(!moduleNode["FromId"].isNull()) + module_.fromId = moduleNode["FromId"].asString(); + if(!moduleNode["ToId"].isNull()) + module_.toId = moduleNode["ToId"].asString(); + if(!moduleNode["MessageId"].isNull()) + module_.messageId = moduleNode["MessageId"].asString(); + if(!value["ResultCode"].isNull()) + resultCode_ = value["ResultCode"].asString(); + if(!value["ResultMessage"].isNull()) + resultMessage_ = value["ResultMessage"].asString(); + +} + +SendMessageResult::Module SendMessageResult::getModule()const +{ + return module_; +} + +std::string SendMessageResult::getResultMessage()const +{ + return resultMessage_; +} + +std::string SendMessageResult::getResultCode()const +{ + return resultCode_; +} +