From 164bc9082375775d5d447142f78ef711b4dc0b9f Mon Sep 17 00:00:00 2001 From: sdk-team Date: Thu, 5 Jun 2025 12:16:14 +0000 Subject: [PATCH] init sdk --- VERSION | 2 +- dms/CMakeLists.txt | 86 ++++++++++++++++++ dms/include/alibabacloud/dms/DmsClient.h | 54 +++++++++++ dms/include/alibabacloud/dms/DmsExport.h | 32 +++++++ .../model/CreateAirflowLoginTokenRequest.h | 42 +++++++++ .../dms/model/CreateAirflowLoginTokenResult.h | 66 ++++++++++++++ dms/src/DmsClient.cc | 89 +++++++++++++++++++ .../model/CreateAirflowLoginTokenRequest.cc | 36 ++++++++ .../model/CreateAirflowLoginTokenResult.cc | 89 +++++++++++++++++++ 9 files changed, 495 insertions(+), 1 deletion(-) create mode 100644 dms/CMakeLists.txt create mode 100644 dms/include/alibabacloud/dms/DmsClient.h create mode 100644 dms/include/alibabacloud/dms/DmsExport.h create mode 100644 dms/include/alibabacloud/dms/model/CreateAirflowLoginTokenRequest.h create mode 100644 dms/include/alibabacloud/dms/model/CreateAirflowLoginTokenResult.h create mode 100644 dms/src/DmsClient.cc create mode 100644 dms/src/model/CreateAirflowLoginTokenRequest.cc create mode 100644 dms/src/model/CreateAirflowLoginTokenResult.cc diff --git a/VERSION b/VERSION index e02cd36f4..42fa46e31 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.36.2072 \ No newline at end of file +1.36.2073 \ No newline at end of file diff --git a/dms/CMakeLists.txt b/dms/CMakeLists.txt new file mode 100644 index 000000000..ee0492149 --- /dev/null +++ b/dms/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(dms_public_header + include/alibabacloud/dms/DmsClient.h + include/alibabacloud/dms/DmsExport.h ) + +set(dms_public_header_model + include/alibabacloud/dms/model/CreateAirflowLoginTokenRequest.h + include/alibabacloud/dms/model/CreateAirflowLoginTokenResult.h ) + +set(dms_src + src/DmsClient.cc + src/model/CreateAirflowLoginTokenRequest.cc + src/model/CreateAirflowLoginTokenResult.cc ) + +add_library(dms ${LIB_TYPE} + ${dms_public_header} + ${dms_public_header_model} + ${dms_src}) + +set_target_properties(dms + 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}dms + ) + +if(${LIB_TYPE} STREQUAL "SHARED") + set_target_properties(dms + PROPERTIES + DEFINE_SYMBOL ALIBABACLOUD_DMS_LIBRARY) +endif() + +target_include_directories(dms + PRIVATE include + ${CMAKE_SOURCE_DIR}/core/include + ) +target_link_libraries(dms + core) + +if(CMAKE_HOST_WIN32) + ExternalProject_Get_Property(jsoncpp INSTALL_DIR) + set(jsoncpp_install_dir ${INSTALL_DIR}) + add_dependencies(dms + jsoncpp) + target_include_directories(dms + PRIVATE ${jsoncpp_install_dir}/include) + target_link_libraries(dms + ${jsoncpp_install_dir}/lib/jsoncpp.lib) + set_target_properties(dms + PROPERTIES + COMPILE_OPTIONS "/bigobj") +else() + target_include_directories(dms + PRIVATE /usr/include/jsoncpp) + target_link_libraries(dms + jsoncpp) +endif() + +install(FILES ${dms_public_header} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/dms) +install(FILES ${dms_public_header_model} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/dms/model) +install(TARGETS dms + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) \ No newline at end of file diff --git a/dms/include/alibabacloud/dms/DmsClient.h b/dms/include/alibabacloud/dms/DmsClient.h new file mode 100644 index 000000000..ea3f73405 --- /dev/null +++ b/dms/include/alibabacloud/dms/DmsClient.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_DMS_DMSCLIENT_H_ +#define ALIBABACLOUD_DMS_DMSCLIENT_H_ + +#include +#include +#include +#include +#include "DmsExport.h" +#include "model/CreateAirflowLoginTokenRequest.h" +#include "model/CreateAirflowLoginTokenResult.h" + + +namespace AlibabaCloud +{ + namespace Dms + { + class ALIBABACLOUD_DMS_EXPORT DmsClient : public RpcServiceClient + { + public: + typedef Outcome CreateAirflowLoginTokenOutcome; + typedef std::future CreateAirflowLoginTokenOutcomeCallable; + typedef std::function&)> CreateAirflowLoginTokenAsyncHandler; + + DmsClient(const Credentials &credentials, const ClientConfiguration &configuration); + DmsClient(const std::shared_ptr &credentialsProvider, const ClientConfiguration &configuration); + DmsClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration); + ~DmsClient(); + CreateAirflowLoginTokenOutcome createAirflowLoginToken(const Model::CreateAirflowLoginTokenRequest &request)const; + void createAirflowLoginTokenAsync(const Model::CreateAirflowLoginTokenRequest& request, const CreateAirflowLoginTokenAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + CreateAirflowLoginTokenOutcomeCallable createAirflowLoginTokenCallable(const Model::CreateAirflowLoginTokenRequest& request) const; + + private: + std::shared_ptr endpointProvider_; + }; + } +} + +#endif // !ALIBABACLOUD_DMS_DMSCLIENT_H_ diff --git a/dms/include/alibabacloud/dms/DmsExport.h b/dms/include/alibabacloud/dms/DmsExport.h new file mode 100644 index 000000000..3bc793b36 --- /dev/null +++ b/dms/include/alibabacloud/dms/DmsExport.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_DMS_DMSEXPORT_H_ +#define ALIBABACLOUD_DMS_DMSEXPORT_H_ + +#include + +#if defined(ALIBABACLOUD_SHARED) +# if defined(ALIBABACLOUD_DMS_LIBRARY) +# define ALIBABACLOUD_DMS_EXPORT ALIBABACLOUD_DECL_EXPORT +# else +# define ALIBABACLOUD_DMS_EXPORT ALIBABACLOUD_DECL_IMPORT +# endif +#else +# define ALIBABACLOUD_DMS_EXPORT +#endif + +#endif // !ALIBABACLOUD_DMS_DMSEXPORT_H_ \ No newline at end of file diff --git a/dms/include/alibabacloud/dms/model/CreateAirflowLoginTokenRequest.h b/dms/include/alibabacloud/dms/model/CreateAirflowLoginTokenRequest.h new file mode 100644 index 000000000..5309e9141 --- /dev/null +++ b/dms/include/alibabacloud/dms/model/CreateAirflowLoginTokenRequest.h @@ -0,0 +1,42 @@ +/* + * 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_DMS_MODEL_CREATEAIRFLOWLOGINTOKENREQUEST_H_ +#define ALIBABACLOUD_DMS_MODEL_CREATEAIRFLOWLOGINTOKENREQUEST_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud { +namespace Dms { +namespace Model { +class ALIBABACLOUD_DMS_EXPORT CreateAirflowLoginTokenRequest : public RpcServiceRequest { +public: + CreateAirflowLoginTokenRequest(); + ~CreateAirflowLoginTokenRequest(); + std::string getAirflowId() const; + void setAirflowId(const std::string &airflowId); + +private: + std::string airflowId_; +}; +} // namespace Model +} // namespace Dms +} // namespace AlibabaCloud +#endif // !ALIBABACLOUD_DMS_MODEL_CREATEAIRFLOWLOGINTOKENREQUEST_H_ diff --git a/dms/include/alibabacloud/dms/model/CreateAirflowLoginTokenResult.h b/dms/include/alibabacloud/dms/model/CreateAirflowLoginTokenResult.h new file mode 100644 index 000000000..7ac279e46 --- /dev/null +++ b/dms/include/alibabacloud/dms/model/CreateAirflowLoginTokenResult.h @@ -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. + */ + +#ifndef ALIBABACLOUD_DMS_MODEL_CREATEAIRFLOWLOGINTOKENRESULT_H_ +#define ALIBABACLOUD_DMS_MODEL_CREATEAIRFLOWLOGINTOKENRESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Dms + { + namespace Model + { + class ALIBABACLOUD_DMS_EXPORT CreateAirflowLoginTokenResult : public ServiceResult + { + public: + struct Data + { + std::string token; + std::string host; + }; + + + CreateAirflowLoginTokenResult(); + explicit CreateAirflowLoginTokenResult(const std::string &payload); + ~CreateAirflowLoginTokenResult(); + std::string getMessage()const; + int getHttpStatusCode()const; + Data getData()const; + std::string getErrorCode()const; + std::string getCode()const; + bool getSuccess()const; + + protected: + void parse(const std::string &payload); + private: + std::string message_; + int httpStatusCode_; + Data data_; + std::string errorCode_; + std::string code_; + bool success_; + + }; + } + } +} +#endif // !ALIBABACLOUD_DMS_MODEL_CREATEAIRFLOWLOGINTOKENRESULT_H_ \ No newline at end of file diff --git a/dms/src/DmsClient.cc b/dms/src/DmsClient.cc new file mode 100644 index 000000000..752499f5b --- /dev/null +++ b/dms/src/DmsClient.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::Dms; +using namespace AlibabaCloud::Dms::Model; + +namespace +{ + const std::string SERVICE_NAME = "Dms"; +} + +DmsClient::DmsClient(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, ""); +} + +DmsClient::DmsClient(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, ""); +} + +DmsClient::DmsClient(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, ""); +} + +DmsClient::~DmsClient() +{} + +DmsClient::CreateAirflowLoginTokenOutcome DmsClient::createAirflowLoginToken(const CreateAirflowLoginTokenRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return CreateAirflowLoginTokenOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return CreateAirflowLoginTokenOutcome(CreateAirflowLoginTokenResult(outcome.result())); + else + return CreateAirflowLoginTokenOutcome(outcome.error()); +} + +void DmsClient::createAirflowLoginTokenAsync(const CreateAirflowLoginTokenRequest& request, const CreateAirflowLoginTokenAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, createAirflowLoginToken(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +DmsClient::CreateAirflowLoginTokenOutcomeCallable DmsClient::createAirflowLoginTokenCallable(const CreateAirflowLoginTokenRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->createAirflowLoginToken(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + diff --git a/dms/src/model/CreateAirflowLoginTokenRequest.cc b/dms/src/model/CreateAirflowLoginTokenRequest.cc new file mode 100644 index 000000000..700226904 --- /dev/null +++ b/dms/src/model/CreateAirflowLoginTokenRequest.cc @@ -0,0 +1,36 @@ +/* + * 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::Dms::Model::CreateAirflowLoginTokenRequest; + +CreateAirflowLoginTokenRequest::CreateAirflowLoginTokenRequest() + : RpcServiceRequest("dms", "2025-04-14", "CreateAirflowLoginToken") { + setMethod(HttpRequest::Method::Post); +} + +CreateAirflowLoginTokenRequest::~CreateAirflowLoginTokenRequest() {} + +std::string CreateAirflowLoginTokenRequest::getAirflowId() const { + return airflowId_; +} + +void CreateAirflowLoginTokenRequest::setAirflowId(const std::string &airflowId) { + airflowId_ = airflowId; + setParameter(std::string("AirflowId"), airflowId); +} + diff --git a/dms/src/model/CreateAirflowLoginTokenResult.cc b/dms/src/model/CreateAirflowLoginTokenResult.cc new file mode 100644 index 000000000..3e607bc59 --- /dev/null +++ b/dms/src/model/CreateAirflowLoginTokenResult.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::Dms; +using namespace AlibabaCloud::Dms::Model; + +CreateAirflowLoginTokenResult::CreateAirflowLoginTokenResult() : + ServiceResult() +{} + +CreateAirflowLoginTokenResult::CreateAirflowLoginTokenResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +CreateAirflowLoginTokenResult::~CreateAirflowLoginTokenResult() +{} + +void CreateAirflowLoginTokenResult::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["Token"].isNull()) + data_.token = dataNode["Token"].asString(); + if(!dataNode["Host"].isNull()) + data_.host = dataNode["Host"].asString(); + if(!value["HttpStatusCode"].isNull()) + httpStatusCode_ = std::stoi(value["HttpStatusCode"].asString()); + if(!value["Success"].isNull()) + success_ = value["Success"].asString() == "true"; + if(!value["Message"].isNull()) + message_ = value["Message"].asString(); + if(!value["ErrorCode"].isNull()) + errorCode_ = value["ErrorCode"].asString(); + if(!value["Code"].isNull()) + code_ = value["Code"].asString(); + +} + +std::string CreateAirflowLoginTokenResult::getMessage()const +{ + return message_; +} + +int CreateAirflowLoginTokenResult::getHttpStatusCode()const +{ + return httpStatusCode_; +} + +CreateAirflowLoginTokenResult::Data CreateAirflowLoginTokenResult::getData()const +{ + return data_; +} + +std::string CreateAirflowLoginTokenResult::getErrorCode()const +{ + return errorCode_; +} + +std::string CreateAirflowLoginTokenResult::getCode()const +{ + return code_; +} + +bool CreateAirflowLoginTokenResult::getSuccess()const +{ + return success_; +} +