diff --git a/CHANGELOG b/CHANGELOG index d638954b2..d9ae56c86 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2021-05-11 Version: 1.36.724 +- SDK device authorization API. + 2021-05-10 Version: 1.36.723 - Update RecognizeDriverLicense RecognizeLicensePlate. diff --git a/VERSION b/VERSION index 4dbfe0a96..7e931105a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.36.723 \ No newline at end of file +1.36.724 \ No newline at end of file diff --git a/moguan-sdk/CMakeLists.txt b/moguan-sdk/CMakeLists.txt new file mode 100644 index 000000000..79a41a792 --- /dev/null +++ b/moguan-sdk/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(moguan-sdk_public_header + include/alibabacloud/moguan-sdk/Moguan_sdkClient.h + include/alibabacloud/moguan-sdk/Moguan_sdkExport.h ) + +set(moguan-sdk_public_header_model + include/alibabacloud/moguan-sdk/model/RegisterDeviceRequest.h + include/alibabacloud/moguan-sdk/model/RegisterDeviceResult.h ) + +set(moguan-sdk_src + src/Moguan-sdkClient.cc + src/model/RegisterDeviceRequest.cc + src/model/RegisterDeviceResult.cc ) + +add_library(moguan-sdk ${LIB_TYPE} + ${moguan-sdk_public_header} + ${moguan-sdk_public_header_model} + ${moguan-sdk_src}) + +set_target_properties(moguan-sdk + 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}moguan-sdk + ) + +if(${LIB_TYPE} STREQUAL "SHARED") + set_target_properties(moguan-sdk + PROPERTIES + DEFINE_SYMBOL ALIBABACLOUD_MOGUAN_SDK_LIBRARY) +endif() + +target_include_directories(moguan-sdk + PRIVATE include + ${CMAKE_SOURCE_DIR}/core/include + ) +target_link_libraries(moguan-sdk + core) + +if(CMAKE_HOST_WIN32) + ExternalProject_Get_Property(jsoncpp INSTALL_DIR) + set(jsoncpp_install_dir ${INSTALL_DIR}) + add_dependencies(moguan-sdk + jsoncpp) + target_include_directories(moguan-sdk + PRIVATE ${jsoncpp_install_dir}/include) + target_link_libraries(moguan-sdk + ${jsoncpp_install_dir}/lib/jsoncpp.lib) + set_target_properties(moguan-sdk + PROPERTIES + COMPILE_OPTIONS "/bigobj") +else() + target_include_directories(moguan-sdk + PRIVATE /usr/include/jsoncpp) + target_link_libraries(moguan-sdk + jsoncpp) +endif() + +install(FILES ${moguan-sdk_public_header} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/moguan-sdk) +install(FILES ${moguan-sdk_public_header_model} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/moguan-sdk/model) +install(TARGETS moguan-sdk + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) \ No newline at end of file diff --git a/moguan-sdk/include/alibabacloud/moguan-sdk/Moguan_sdkClient.h b/moguan-sdk/include/alibabacloud/moguan-sdk/Moguan_sdkClient.h new file mode 100644 index 000000000..451f30af6 --- /dev/null +++ b/moguan-sdk/include/alibabacloud/moguan-sdk/Moguan_sdkClient.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_MOGUAN_SDK_MOGUAN_SDKCLIENT_H_ +#define ALIBABACLOUD_MOGUAN_SDK_MOGUAN_SDKCLIENT_H_ + +#include +#include +#include +#include +#include "Moguan_sdkExport.h" +#include "model/RegisterDeviceRequest.h" +#include "model/RegisterDeviceResult.h" + + +namespace AlibabaCloud +{ + namespace Moguan_sdk + { + class ALIBABACLOUD_MOGUAN_SDK_EXPORT Moguan_sdkClient : public RpcServiceClient + { + public: + typedef Outcome RegisterDeviceOutcome; + typedef std::future RegisterDeviceOutcomeCallable; + typedef std::function&)> RegisterDeviceAsyncHandler; + + Moguan_sdkClient(const Credentials &credentials, const ClientConfiguration &configuration); + Moguan_sdkClient(const std::shared_ptr &credentialsProvider, const ClientConfiguration &configuration); + Moguan_sdkClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration); + ~Moguan_sdkClient(); + RegisterDeviceOutcome registerDevice(const Model::RegisterDeviceRequest &request)const; + void registerDeviceAsync(const Model::RegisterDeviceRequest& request, const RegisterDeviceAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + RegisterDeviceOutcomeCallable registerDeviceCallable(const Model::RegisterDeviceRequest& request) const; + + private: + std::shared_ptr endpointProvider_; + }; + } +} + +#endif // !ALIBABACLOUD_MOGUAN_SDK_MOGUAN_SDKCLIENT_H_ diff --git a/moguan-sdk/include/alibabacloud/moguan-sdk/Moguan_sdkExport.h b/moguan-sdk/include/alibabacloud/moguan-sdk/Moguan_sdkExport.h new file mode 100644 index 000000000..2910b40a8 --- /dev/null +++ b/moguan-sdk/include/alibabacloud/moguan-sdk/Moguan_sdkExport.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_MOGUAN_SDK_MOGUAN_SDKEXPORT_H_ +#define ALIBABACLOUD_MOGUAN_SDK_MOGUAN_SDKEXPORT_H_ + +#include + +#if defined(ALIBABACLOUD_SHARED) +# if defined(ALIBABACLOUD_MOGUAN_SDK_LIBRARY) +# define ALIBABACLOUD_MOGUAN_SDK_EXPORT ALIBABACLOUD_DECL_EXPORT +# else +# define ALIBABACLOUD_MOGUAN_SDK_EXPORT ALIBABACLOUD_DECL_IMPORT +# endif +#else +# define ALIBABACLOUD_MOGUAN_SDK_EXPORT +#endif + +#endif // !ALIBABACLOUD_MOGUAN_SDK_MOGUAN_SDKEXPORT_H_ \ No newline at end of file diff --git a/moguan-sdk/include/alibabacloud/moguan-sdk/model/RegisterDeviceRequest.h b/moguan-sdk/include/alibabacloud/moguan-sdk/model/RegisterDeviceRequest.h new file mode 100644 index 000000000..ada734783 --- /dev/null +++ b/moguan-sdk/include/alibabacloud/moguan-sdk/model/RegisterDeviceRequest.h @@ -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_MOGUAN_SDK_MODEL_REGISTERDEVICEREQUEST_H_ +#define ALIBABACLOUD_MOGUAN_SDK_MODEL_REGISTERDEVICEREQUEST_H_ + +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Moguan_sdk + { + namespace Model + { + class ALIBABACLOUD_MOGUAN_SDK_EXPORT RegisterDeviceRequest : public RpcServiceRequest + { + + public: + RegisterDeviceRequest(); + ~RegisterDeviceRequest(); + + std::string getUserDeviceId()const; + void setUserDeviceId(const std::string& userDeviceId); + std::string getExtend()const; + void setExtend(const std::string& extend); + std::string getSdkCode()const; + void setSdkCode(const std::string& sdkCode); + std::string getAppKey()const; + void setAppKey(const std::string& appKey); + std::string getDeviceId()const; + void setDeviceId(const std::string& deviceId); + + private: + std::string userDeviceId_; + std::string extend_; + std::string sdkCode_; + std::string appKey_; + std::string deviceId_; + + }; + } + } +} +#endif // !ALIBABACLOUD_MOGUAN_SDK_MODEL_REGISTERDEVICEREQUEST_H_ \ No newline at end of file diff --git a/moguan-sdk/include/alibabacloud/moguan-sdk/model/RegisterDeviceResult.h b/moguan-sdk/include/alibabacloud/moguan-sdk/model/RegisterDeviceResult.h new file mode 100644 index 000000000..04d52c1dc --- /dev/null +++ b/moguan-sdk/include/alibabacloud/moguan-sdk/model/RegisterDeviceResult.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_MOGUAN_SDK_MODEL_REGISTERDEVICERESULT_H_ +#define ALIBABACLOUD_MOGUAN_SDK_MODEL_REGISTERDEVICERESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Moguan_sdk + { + namespace Model + { + class ALIBABACLOUD_MOGUAN_SDK_EXPORT RegisterDeviceResult : public ServiceResult + { + public: + struct Data + { + std::string rid; + }; + + + RegisterDeviceResult(); + explicit RegisterDeviceResult(const std::string &payload); + ~RegisterDeviceResult(); + std::string getMessage()const; + Data getData()const; + int getErrorCode()const; + std::string getErrorMessage()const; + + protected: + void parse(const std::string &payload); + private: + std::string message_; + Data data_; + int errorCode_; + std::string errorMessage_; + + }; + } + } +} +#endif // !ALIBABACLOUD_MOGUAN_SDK_MODEL_REGISTERDEVICERESULT_H_ \ No newline at end of file diff --git a/moguan-sdk/src/Moguan-sdkClient.cc b/moguan-sdk/src/Moguan-sdkClient.cc new file mode 100644 index 000000000..dfb4614c9 --- /dev/null +++ b/moguan-sdk/src/Moguan-sdkClient.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::Moguan_sdk; +using namespace AlibabaCloud::Moguan_sdk::Model; + +namespace +{ + const std::string SERVICE_NAME = "moguan-sdk"; +} + +Moguan_sdkClient::Moguan_sdkClient(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, "visionai"); +} + +Moguan_sdkClient::Moguan_sdkClient(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, "visionai"); +} + +Moguan_sdkClient::Moguan_sdkClient(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, "visionai"); +} + +Moguan_sdkClient::~Moguan_sdkClient() +{} + +Moguan_sdkClient::RegisterDeviceOutcome Moguan_sdkClient::registerDevice(const RegisterDeviceRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return RegisterDeviceOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return RegisterDeviceOutcome(RegisterDeviceResult(outcome.result())); + else + return RegisterDeviceOutcome(outcome.error()); +} + +void Moguan_sdkClient::registerDeviceAsync(const RegisterDeviceRequest& request, const RegisterDeviceAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, registerDevice(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +Moguan_sdkClient::RegisterDeviceOutcomeCallable Moguan_sdkClient::registerDeviceCallable(const RegisterDeviceRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->registerDevice(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + diff --git a/moguan-sdk/src/model/RegisterDeviceRequest.cc b/moguan-sdk/src/model/RegisterDeviceRequest.cc new file mode 100644 index 000000000..e87714f73 --- /dev/null +++ b/moguan-sdk/src/model/RegisterDeviceRequest.cc @@ -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 + +using AlibabaCloud::Moguan_sdk::Model::RegisterDeviceRequest; + +RegisterDeviceRequest::RegisterDeviceRequest() : + RpcServiceRequest("moguan-sdk", "2021-04-15", "RegisterDevice") +{ + setMethod(HttpRequest::Method::Post); +} + +RegisterDeviceRequest::~RegisterDeviceRequest() +{} + +std::string RegisterDeviceRequest::getUserDeviceId()const +{ + return userDeviceId_; +} + +void RegisterDeviceRequest::setUserDeviceId(const std::string& userDeviceId) +{ + userDeviceId_ = userDeviceId; + setBodyParameter("UserDeviceId", userDeviceId); +} + +std::string RegisterDeviceRequest::getExtend()const +{ + return extend_; +} + +void RegisterDeviceRequest::setExtend(const std::string& extend) +{ + extend_ = extend; + setBodyParameter("Extend", extend); +} + +std::string RegisterDeviceRequest::getSdkCode()const +{ + return sdkCode_; +} + +void RegisterDeviceRequest::setSdkCode(const std::string& sdkCode) +{ + sdkCode_ = sdkCode; + setBodyParameter("SdkCode", sdkCode); +} + +std::string RegisterDeviceRequest::getAppKey()const +{ + return appKey_; +} + +void RegisterDeviceRequest::setAppKey(const std::string& appKey) +{ + appKey_ = appKey; + setBodyParameter("AppKey", appKey); +} + +std::string RegisterDeviceRequest::getDeviceId()const +{ + return deviceId_; +} + +void RegisterDeviceRequest::setDeviceId(const std::string& deviceId) +{ + deviceId_ = deviceId; + setBodyParameter("DeviceId", deviceId); +} + diff --git a/moguan-sdk/src/model/RegisterDeviceResult.cc b/moguan-sdk/src/model/RegisterDeviceResult.cc new file mode 100644 index 000000000..7eaf97b23 --- /dev/null +++ b/moguan-sdk/src/model/RegisterDeviceResult.cc @@ -0,0 +1,73 @@ +/* + * 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::Moguan_sdk; +using namespace AlibabaCloud::Moguan_sdk::Model; + +RegisterDeviceResult::RegisterDeviceResult() : + ServiceResult() +{} + +RegisterDeviceResult::RegisterDeviceResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +RegisterDeviceResult::~RegisterDeviceResult() +{} + +void RegisterDeviceResult::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["Rid"].isNull()) + data_.rid = dataNode["Rid"].asString(); + if(!value["Message"].isNull()) + message_ = value["Message"].asString(); + if(!value["ErrorCode"].isNull()) + errorCode_ = std::stoi(value["ErrorCode"].asString()); + if(!value["ErrorMessage"].isNull()) + errorMessage_ = value["ErrorMessage"].asString(); + +} + +std::string RegisterDeviceResult::getMessage()const +{ + return message_; +} + +RegisterDeviceResult::Data RegisterDeviceResult::getData()const +{ + return data_; +} + +int RegisterDeviceResult::getErrorCode()const +{ + return errorCode_; +} + +std::string RegisterDeviceResult::getErrorMessage()const +{ + return errorMessage_; +} +