Add demo edition auth.

This commit is contained in:
sdk-team
2020-05-14 10:33:25 +08:00
parent 2fd4ebc0a8
commit 56c516a238
13 changed files with 270 additions and 6 deletions

View File

@@ -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.

View File

@@ -1 +1 @@
1.36.410
1.36.411

View File

@@ -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}

View File

@@ -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<Error, Model::ExpireDemoAccessTokenResult> ExpireDemoAccessTokenOutcome;
typedef std::future<ExpireDemoAccessTokenOutcome> ExpireDemoAccessTokenOutcomeCallable;
typedef std::function<void(const DemoCenterClient*, const Model::ExpireDemoAccessTokenRequest&, const ExpireDemoAccessTokenOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ExpireDemoAccessTokenAsyncHandler;
typedef Outcome<Error, Model::GetDemoTrialAuthResult> GetDemoTrialAuthOutcome;
typedef std::future<GetDemoTrialAuthOutcome> GetDemoTrialAuthOutcomeCallable;
typedef std::function<void(const DemoCenterClient*, const Model::GetDemoTrialAuthRequest&, const GetDemoTrialAuthOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetDemoTrialAuthAsyncHandler;
DemoCenterClient(const Credentials &credentials, const ClientConfiguration &configuration);
DemoCenterClient(const std::shared_ptr<CredentialsProvider> &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<const AsyncCallerContext>& 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<const AsyncCallerContext>& context = nullptr) const;
GetDemoTrialAuthOutcomeCallable getDemoTrialAuthCallable(const Model::GetDemoTrialAuthRequest& request) const;
private:
std::shared_ptr<EndpointProvider> endpointProvider_;

View File

@@ -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_;
};

View File

@@ -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_;
};
}

View File

@@ -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 <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/democenter/DemoCenterExport.h>
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_

View File

@@ -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 <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/democenter/DemoCenterExport.h>
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_

View File

@@ -31,21 +31,21 @@ DemoCenterClient::DemoCenterClient(const Credentials &credentials, const ClientC
RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(credentials), configuration)
{
auto locationClient = std::make_shared<LocationClient>(credentials, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "DemoCenter");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
}
DemoCenterClient::DemoCenterClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration)
{
auto locationClient = std::make_shared<LocationClient>(credentialsProvider, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "DemoCenter");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
}
DemoCenterClient::DemoCenterClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(accessKeyId, accessKeySecret), configuration)
{
auto locationClient = std::make_shared<LocationClient>(accessKeyId, accessKeySecret, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "DemoCenter");
endpointProvider_ = std::make_shared<EndpointProvider>(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<const AsyncCallerContext>& 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<std::packaged_task<GetDemoTrialAuthOutcome()>>(
[this, request]()
{
return this->getDemoTrialAuth(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}

View File

@@ -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_;

View File

@@ -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_;
}

View File

@@ -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 <alibabacloud/democenter/model/GetDemoTrialAuthRequest.h>
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));
}

View File

@@ -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 <alibabacloud/democenter/model/GetDemoTrialAuthResult.h>
#include <json/json.h>
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_;
}