From 56c516a238466f82ec993d0091b7423b81d97815 Mon Sep 17 00:00:00 2001 From: sdk-team Date: Thu, 14 May 2020 10:33:25 +0800 Subject: [PATCH] Add demo edition auth. --- CHANGELOG | 3 ++ VERSION | 2 +- democenter/CMakeLists.txt | 8 ++- .../democenter/DemoCenterClient.h | 8 +++ .../model/CreateDemoAccessTokenRequest.h | 3 ++ .../model/DescribeDemoAccessTokenResult.h | 2 + .../model/GetDemoTrialAuthRequest.h | 48 +++++++++++++++++ .../democenter/model/GetDemoTrialAuthResult.h | 51 +++++++++++++++++++ democenter/src/DemoCenterClient.cc | 42 +++++++++++++-- .../src/model/CreateDemoAccessTokenRequest.cc | 11 ++++ .../model/DescribeDemoAccessTokenResult.cc | 7 +++ .../src/model/GetDemoTrialAuthRequest.cc | 40 +++++++++++++++ .../src/model/GetDemoTrialAuthResult.cc | 51 +++++++++++++++++++ 13 files changed, 270 insertions(+), 6 deletions(-) create mode 100644 democenter/include/alibabacloud/democenter/model/GetDemoTrialAuthRequest.h create mode 100644 democenter/include/alibabacloud/democenter/model/GetDemoTrialAuthResult.h create mode 100644 democenter/src/model/GetDemoTrialAuthRequest.cc create mode 100644 democenter/src/model/GetDemoTrialAuthResult.cc diff --git a/CHANGELOG b/CHANGELOG index 4bdc6680f..763c18879 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2020-05-14 Version: 1.36.411 +- Add demo edition auth. + 2020-05-13 Version: 1.36.410 - Add ListDevicesImages DescribeIpcLiveAddress. - Modify DescribeDevices. diff --git a/VERSION b/VERSION index 7c5ef8c9e..3f739d814 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.36.410 \ No newline at end of file +1.36.411 \ No newline at end of file diff --git a/democenter/CMakeLists.txt b/democenter/CMakeLists.txt index 35e40511a..728f8cafb 100644 --- a/democenter/CMakeLists.txt +++ b/democenter/CMakeLists.txt @@ -26,7 +26,9 @@ set(democenter_public_header_model include/alibabacloud/democenter/model/DescribeDemoAccessTokenRequest.h include/alibabacloud/democenter/model/DescribeDemoAccessTokenResult.h include/alibabacloud/democenter/model/ExpireDemoAccessTokenRequest.h - include/alibabacloud/democenter/model/ExpireDemoAccessTokenResult.h ) + include/alibabacloud/democenter/model/ExpireDemoAccessTokenResult.h + include/alibabacloud/democenter/model/GetDemoTrialAuthRequest.h + include/alibabacloud/democenter/model/GetDemoTrialAuthResult.h ) set(democenter_src src/DemoCenterClient.cc @@ -35,7 +37,9 @@ set(democenter_src src/model/DescribeDemoAccessTokenRequest.cc src/model/DescribeDemoAccessTokenResult.cc src/model/ExpireDemoAccessTokenRequest.cc - src/model/ExpireDemoAccessTokenResult.cc ) + src/model/ExpireDemoAccessTokenResult.cc + src/model/GetDemoTrialAuthRequest.cc + src/model/GetDemoTrialAuthResult.cc ) add_library(democenter ${LIB_TYPE} ${democenter_public_header} diff --git a/democenter/include/alibabacloud/democenter/DemoCenterClient.h b/democenter/include/alibabacloud/democenter/DemoCenterClient.h index 16ec6b52b..0adbb1d6e 100644 --- a/democenter/include/alibabacloud/democenter/DemoCenterClient.h +++ b/democenter/include/alibabacloud/democenter/DemoCenterClient.h @@ -28,6 +28,8 @@ #include "model/DescribeDemoAccessTokenResult.h" #include "model/ExpireDemoAccessTokenRequest.h" #include "model/ExpireDemoAccessTokenResult.h" +#include "model/GetDemoTrialAuthRequest.h" +#include "model/GetDemoTrialAuthResult.h" namespace AlibabaCloud @@ -46,6 +48,9 @@ namespace AlibabaCloud typedef Outcome ExpireDemoAccessTokenOutcome; typedef std::future ExpireDemoAccessTokenOutcomeCallable; typedef std::function&)> ExpireDemoAccessTokenAsyncHandler; + typedef Outcome GetDemoTrialAuthOutcome; + typedef std::future GetDemoTrialAuthOutcomeCallable; + typedef std::function&)> GetDemoTrialAuthAsyncHandler; DemoCenterClient(const Credentials &credentials, const ClientConfiguration &configuration); DemoCenterClient(const std::shared_ptr &credentialsProvider, const ClientConfiguration &configuration); @@ -60,6 +65,9 @@ namespace AlibabaCloud ExpireDemoAccessTokenOutcome expireDemoAccessToken(const Model::ExpireDemoAccessTokenRequest &request)const; void expireDemoAccessTokenAsync(const Model::ExpireDemoAccessTokenRequest& request, const ExpireDemoAccessTokenAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; ExpireDemoAccessTokenOutcomeCallable expireDemoAccessTokenCallable(const Model::ExpireDemoAccessTokenRequest& request) const; + GetDemoTrialAuthOutcome getDemoTrialAuth(const Model::GetDemoTrialAuthRequest &request)const; + void getDemoTrialAuthAsync(const Model::GetDemoTrialAuthRequest& request, const GetDemoTrialAuthAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + GetDemoTrialAuthOutcomeCallable getDemoTrialAuthCallable(const Model::GetDemoTrialAuthRequest& request) const; private: std::shared_ptr endpointProvider_; diff --git a/democenter/include/alibabacloud/democenter/model/CreateDemoAccessTokenRequest.h b/democenter/include/alibabacloud/democenter/model/CreateDemoAccessTokenRequest.h index f18b6b33c..701ccd65e 100644 --- a/democenter/include/alibabacloud/democenter/model/CreateDemoAccessTokenRequest.h +++ b/democenter/include/alibabacloud/democenter/model/CreateDemoAccessTokenRequest.h @@ -35,10 +35,13 @@ namespace AlibabaCloud CreateDemoAccessTokenRequest(); ~CreateDemoAccessTokenRequest(); + int getEdition()const; + void setEdition(int edition); long getDemoId()const; void setDemoId(long demoId); private: + int edition_; long demoId_; }; diff --git a/democenter/include/alibabacloud/democenter/model/DescribeDemoAccessTokenResult.h b/democenter/include/alibabacloud/democenter/model/DescribeDemoAccessTokenResult.h index 3b3035a99..6acfc0581 100644 --- a/democenter/include/alibabacloud/democenter/model/DescribeDemoAccessTokenResult.h +++ b/democenter/include/alibabacloud/democenter/model/DescribeDemoAccessTokenResult.h @@ -42,6 +42,7 @@ namespace AlibabaCloud std::string getExpiredDate()const; std::string getDemoAccessToken()const; std::string getOpenUserId()const; + std::string getEdition()const; protected: void parse(const std::string &payload); @@ -51,6 +52,7 @@ namespace AlibabaCloud std::string expiredDate_; std::string demoAccessToken_; std::string openUserId_; + std::string edition_; }; } diff --git a/democenter/include/alibabacloud/democenter/model/GetDemoTrialAuthRequest.h b/democenter/include/alibabacloud/democenter/model/GetDemoTrialAuthRequest.h new file mode 100644 index 000000000..ae7f4f911 --- /dev/null +++ b/democenter/include/alibabacloud/democenter/model/GetDemoTrialAuthRequest.h @@ -0,0 +1,48 @@ +/* + * 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_DEMOCENTER_MODEL_GETDEMOTRIALAUTHREQUEST_H_ +#define ALIBABACLOUD_DEMOCENTER_MODEL_GETDEMOTRIALAUTHREQUEST_H_ + +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace DemoCenter + { + namespace Model + { + class ALIBABACLOUD_DEMOCENTER_EXPORT GetDemoTrialAuthRequest : public RpcServiceRequest + { + + public: + GetDemoTrialAuthRequest(); + ~GetDemoTrialAuthRequest(); + + long getDemoId()const; + void setDemoId(long demoId); + + private: + long demoId_; + + }; + } + } +} +#endif // !ALIBABACLOUD_DEMOCENTER_MODEL_GETDEMOTRIALAUTHREQUEST_H_ \ No newline at end of file diff --git a/democenter/include/alibabacloud/democenter/model/GetDemoTrialAuthResult.h b/democenter/include/alibabacloud/democenter/model/GetDemoTrialAuthResult.h new file mode 100644 index 000000000..3265a95be --- /dev/null +++ b/democenter/include/alibabacloud/democenter/model/GetDemoTrialAuthResult.h @@ -0,0 +1,51 @@ +/* + * 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_DEMOCENTER_MODEL_GETDEMOTRIALAUTHRESULT_H_ +#define ALIBABACLOUD_DEMOCENTER_MODEL_GETDEMOTRIALAUTHRESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace DemoCenter + { + namespace Model + { + class ALIBABACLOUD_DEMOCENTER_EXPORT GetDemoTrialAuthResult : public ServiceResult + { + public: + + + GetDemoTrialAuthResult(); + explicit GetDemoTrialAuthResult(const std::string &payload); + ~GetDemoTrialAuthResult(); + std::string getAuthorization()const; + + protected: + void parse(const std::string &payload); + private: + std::string authorization_; + + }; + } + } +} +#endif // !ALIBABACLOUD_DEMOCENTER_MODEL_GETDEMOTRIALAUTHRESULT_H_ \ No newline at end of file diff --git a/democenter/src/DemoCenterClient.cc b/democenter/src/DemoCenterClient.cc index d1ce12166..cadb21b0e 100644 --- a/democenter/src/DemoCenterClient.cc +++ b/democenter/src/DemoCenterClient.cc @@ -31,21 +31,21 @@ DemoCenterClient::DemoCenterClient(const Credentials &credentials, const ClientC RpcServiceClient(SERVICE_NAME, std::make_shared(credentials), configuration) { auto locationClient = std::make_shared(credentials, configuration); - endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "DemoCenter"); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, ""); } DemoCenterClient::DemoCenterClient(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, "DemoCenter"); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, ""); } DemoCenterClient::DemoCenterClient(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, "DemoCenter"); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, ""); } DemoCenterClient::~DemoCenterClient() @@ -159,3 +159,39 @@ DemoCenterClient::ExpireDemoAccessTokenOutcomeCallable DemoCenterClient::expireD return task->get_future(); } +DemoCenterClient::GetDemoTrialAuthOutcome DemoCenterClient::getDemoTrialAuth(const GetDemoTrialAuthRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return GetDemoTrialAuthOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return GetDemoTrialAuthOutcome(GetDemoTrialAuthResult(outcome.result())); + else + return GetDemoTrialAuthOutcome(outcome.error()); +} + +void DemoCenterClient::getDemoTrialAuthAsync(const GetDemoTrialAuthRequest& request, const GetDemoTrialAuthAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, getDemoTrialAuth(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +DemoCenterClient::GetDemoTrialAuthOutcomeCallable DemoCenterClient::getDemoTrialAuthCallable(const GetDemoTrialAuthRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->getDemoTrialAuth(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + diff --git a/democenter/src/model/CreateDemoAccessTokenRequest.cc b/democenter/src/model/CreateDemoAccessTokenRequest.cc index 91b457c57..dd93b951c 100644 --- a/democenter/src/model/CreateDemoAccessTokenRequest.cc +++ b/democenter/src/model/CreateDemoAccessTokenRequest.cc @@ -27,6 +27,17 @@ CreateDemoAccessTokenRequest::CreateDemoAccessTokenRequest() : CreateDemoAccessTokenRequest::~CreateDemoAccessTokenRequest() {} +int CreateDemoAccessTokenRequest::getEdition()const +{ + return edition_; +} + +void CreateDemoAccessTokenRequest::setEdition(int edition) +{ + edition_ = edition; + setBodyParameter("Edition", std::to_string(edition)); +} + long CreateDemoAccessTokenRequest::getDemoId()const { return demoId_; diff --git a/democenter/src/model/DescribeDemoAccessTokenResult.cc b/democenter/src/model/DescribeDemoAccessTokenResult.cc index 9fbd3189f..ec0318d8a 100644 --- a/democenter/src/model/DescribeDemoAccessTokenResult.cc +++ b/democenter/src/model/DescribeDemoAccessTokenResult.cc @@ -49,6 +49,8 @@ void DescribeDemoAccessTokenResult::parse(const std::string &payload) demoTrialPage_ = value["DemoTrialPage"].asString(); if(!value["DemoDetailPage"].isNull()) demoDetailPage_ = value["DemoDetailPage"].asString(); + if(!value["Edition"].isNull()) + edition_ = value["Edition"].asString(); } @@ -77,3 +79,8 @@ std::string DescribeDemoAccessTokenResult::getOpenUserId()const return openUserId_; } +std::string DescribeDemoAccessTokenResult::getEdition()const +{ + return edition_; +} + diff --git a/democenter/src/model/GetDemoTrialAuthRequest.cc b/democenter/src/model/GetDemoTrialAuthRequest.cc new file mode 100644 index 000000000..448523b41 --- /dev/null +++ b/democenter/src/model/GetDemoTrialAuthRequest.cc @@ -0,0 +1,40 @@ +/* + * 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::DemoCenter::Model::GetDemoTrialAuthRequest; + +GetDemoTrialAuthRequest::GetDemoTrialAuthRequest() : + RpcServiceRequest("democenter", "2020-01-21", "GetDemoTrialAuth") +{ + setMethod(HttpRequest::Method::Get); +} + +GetDemoTrialAuthRequest::~GetDemoTrialAuthRequest() +{} + +long GetDemoTrialAuthRequest::getDemoId()const +{ + return demoId_; +} + +void GetDemoTrialAuthRequest::setDemoId(long demoId) +{ + demoId_ = demoId; + setBodyParameter("DemoId", std::to_string(demoId)); +} + diff --git a/democenter/src/model/GetDemoTrialAuthResult.cc b/democenter/src/model/GetDemoTrialAuthResult.cc new file mode 100644 index 000000000..8ccaf2e56 --- /dev/null +++ b/democenter/src/model/GetDemoTrialAuthResult.cc @@ -0,0 +1,51 @@ +/* + * 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::DemoCenter; +using namespace AlibabaCloud::DemoCenter::Model; + +GetDemoTrialAuthResult::GetDemoTrialAuthResult() : + ServiceResult() +{} + +GetDemoTrialAuthResult::GetDemoTrialAuthResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +GetDemoTrialAuthResult::~GetDemoTrialAuthResult() +{} + +void GetDemoTrialAuthResult::parse(const std::string &payload) +{ + Json::Reader reader; + Json::Value value; + reader.parse(payload, value); + setRequestId(value["RequestId"].asString()); + if(!value["Authorization"].isNull()) + authorization_ = value["Authorization"].asString(); + +} + +std::string GetDemoTrialAuthResult::getAuthorization()const +{ + return authorization_; +} +