Support to create, describe and expire demo access token.

This commit is contained in:
sdk-team
2020-02-12 22:12:03 +08:00
parent 3b52186538
commit d3da09eb38
18 changed files with 994 additions and 1 deletions

View File

@@ -0,0 +1,161 @@
/*
* 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/DemoCenterClient.h>
#include <alibabacloud/core/SimpleCredentialsProvider.h>
using namespace AlibabaCloud;
using namespace AlibabaCloud::Location;
using namespace AlibabaCloud::DemoCenter;
using namespace AlibabaCloud::DemoCenter::Model;
namespace
{
const std::string SERVICE_NAME = "DemoCenter";
}
DemoCenterClient::DemoCenterClient(const Credentials &credentials, const ClientConfiguration &configuration) :
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");
}
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");
}
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");
}
DemoCenterClient::~DemoCenterClient()
{}
DemoCenterClient::CreateDemoAccessTokenOutcome DemoCenterClient::createDemoAccessToken(const CreateDemoAccessTokenRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return CreateDemoAccessTokenOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return CreateDemoAccessTokenOutcome(CreateDemoAccessTokenResult(outcome.result()));
else
return CreateDemoAccessTokenOutcome(outcome.error());
}
void DemoCenterClient::createDemoAccessTokenAsync(const CreateDemoAccessTokenRequest& request, const CreateDemoAccessTokenAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, createDemoAccessToken(request), context);
};
asyncExecute(new Runnable(fn));
}
DemoCenterClient::CreateDemoAccessTokenOutcomeCallable DemoCenterClient::createDemoAccessTokenCallable(const CreateDemoAccessTokenRequest &request) const
{
auto task = std::make_shared<std::packaged_task<CreateDemoAccessTokenOutcome()>>(
[this, request]()
{
return this->createDemoAccessToken(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
DemoCenterClient::DescribeDemoAccessTokenOutcome DemoCenterClient::describeDemoAccessToken(const DescribeDemoAccessTokenRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return DescribeDemoAccessTokenOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return DescribeDemoAccessTokenOutcome(DescribeDemoAccessTokenResult(outcome.result()));
else
return DescribeDemoAccessTokenOutcome(outcome.error());
}
void DemoCenterClient::describeDemoAccessTokenAsync(const DescribeDemoAccessTokenRequest& request, const DescribeDemoAccessTokenAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, describeDemoAccessToken(request), context);
};
asyncExecute(new Runnable(fn));
}
DemoCenterClient::DescribeDemoAccessTokenOutcomeCallable DemoCenterClient::describeDemoAccessTokenCallable(const DescribeDemoAccessTokenRequest &request) const
{
auto task = std::make_shared<std::packaged_task<DescribeDemoAccessTokenOutcome()>>(
[this, request]()
{
return this->describeDemoAccessToken(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
DemoCenterClient::ExpireDemoAccessTokenOutcome DemoCenterClient::expireDemoAccessToken(const ExpireDemoAccessTokenRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return ExpireDemoAccessTokenOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return ExpireDemoAccessTokenOutcome(ExpireDemoAccessTokenResult(outcome.result()));
else
return ExpireDemoAccessTokenOutcome(outcome.error());
}
void DemoCenterClient::expireDemoAccessTokenAsync(const ExpireDemoAccessTokenRequest& request, const ExpireDemoAccessTokenAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, expireDemoAccessToken(request), context);
};
asyncExecute(new Runnable(fn));
}
DemoCenterClient::ExpireDemoAccessTokenOutcomeCallable DemoCenterClient::expireDemoAccessTokenCallable(const ExpireDemoAccessTokenRequest &request) const
{
auto task = std::make_shared<std::packaged_task<ExpireDemoAccessTokenOutcome()>>(
[this, request]()
{
return this->expireDemoAccessToken(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}

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/CreateDemoAccessTokenRequest.h>
using AlibabaCloud::DemoCenter::Model::CreateDemoAccessTokenRequest;
CreateDemoAccessTokenRequest::CreateDemoAccessTokenRequest() :
RpcServiceRequest("democenter", "2020-01-21", "CreateDemoAccessToken")
{
setMethod(HttpRequest::Method::Post);
}
CreateDemoAccessTokenRequest::~CreateDemoAccessTokenRequest()
{}
long CreateDemoAccessTokenRequest::getDemoId()const
{
return demoId_;
}
void CreateDemoAccessTokenRequest::setDemoId(long demoId)
{
demoId_ = demoId;
setBodyParameter("DemoId", std::to_string(demoId));
}

View File

@@ -0,0 +1,79 @@
/*
* 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/CreateDemoAccessTokenResult.h>
#include <json/json.h>
using namespace AlibabaCloud::DemoCenter;
using namespace AlibabaCloud::DemoCenter::Model;
CreateDemoAccessTokenResult::CreateDemoAccessTokenResult() :
ServiceResult()
{}
CreateDemoAccessTokenResult::CreateDemoAccessTokenResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
CreateDemoAccessTokenResult::~CreateDemoAccessTokenResult()
{}
void CreateDemoAccessTokenResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
if(!value["DemoAccessToken"].isNull())
demoAccessToken_ = value["DemoAccessToken"].asString();
if(!value["ExpiredDate"].isNull())
expiredDate_ = value["ExpiredDate"].asString();
if(!value["OpenUserId"].isNull())
openUserId_ = value["OpenUserId"].asString();
if(!value["DemoTrialPage"].isNull())
demoTrialPage_ = value["DemoTrialPage"].asString();
if(!value["DemoDetailPage"].isNull())
demoDetailPage_ = value["DemoDetailPage"].asString();
}
std::string CreateDemoAccessTokenResult::getDemoTrialPage()const
{
return demoTrialPage_;
}
std::string CreateDemoAccessTokenResult::getDemoDetailPage()const
{
return demoDetailPage_;
}
std::string CreateDemoAccessTokenResult::getExpiredDate()const
{
return expiredDate_;
}
std::string CreateDemoAccessTokenResult::getDemoAccessToken()const
{
return demoAccessToken_;
}
std::string CreateDemoAccessTokenResult::getOpenUserId()const
{
return openUserId_;
}

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/DescribeDemoAccessTokenRequest.h>
using AlibabaCloud::DemoCenter::Model::DescribeDemoAccessTokenRequest;
DescribeDemoAccessTokenRequest::DescribeDemoAccessTokenRequest() :
RpcServiceRequest("democenter", "2020-01-21", "DescribeDemoAccessToken")
{
setMethod(HttpRequest::Method::Post);
}
DescribeDemoAccessTokenRequest::~DescribeDemoAccessTokenRequest()
{}
std::string DescribeDemoAccessTokenRequest::getDemoAccessToken()const
{
return demoAccessToken_;
}
void DescribeDemoAccessTokenRequest::setDemoAccessToken(const std::string& demoAccessToken)
{
demoAccessToken_ = demoAccessToken;
setBodyParameter("DemoAccessToken", demoAccessToken);
}

View File

@@ -0,0 +1,79 @@
/*
* 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/DescribeDemoAccessTokenResult.h>
#include <json/json.h>
using namespace AlibabaCloud::DemoCenter;
using namespace AlibabaCloud::DemoCenter::Model;
DescribeDemoAccessTokenResult::DescribeDemoAccessTokenResult() :
ServiceResult()
{}
DescribeDemoAccessTokenResult::DescribeDemoAccessTokenResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
DescribeDemoAccessTokenResult::~DescribeDemoAccessTokenResult()
{}
void DescribeDemoAccessTokenResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
if(!value["DemoAccessToken"].isNull())
demoAccessToken_ = value["DemoAccessToken"].asString();
if(!value["ExpiredDate"].isNull())
expiredDate_ = value["ExpiredDate"].asString();
if(!value["OpenUserId"].isNull())
openUserId_ = value["OpenUserId"].asString();
if(!value["DemoTrialPage"].isNull())
demoTrialPage_ = value["DemoTrialPage"].asString();
if(!value["DemoDetailPage"].isNull())
demoDetailPage_ = value["DemoDetailPage"].asString();
}
std::string DescribeDemoAccessTokenResult::getDemoTrialPage()const
{
return demoTrialPage_;
}
std::string DescribeDemoAccessTokenResult::getDemoDetailPage()const
{
return demoDetailPage_;
}
std::string DescribeDemoAccessTokenResult::getExpiredDate()const
{
return expiredDate_;
}
std::string DescribeDemoAccessTokenResult::getDemoAccessToken()const
{
return demoAccessToken_;
}
std::string DescribeDemoAccessTokenResult::getOpenUserId()const
{
return openUserId_;
}

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/ExpireDemoAccessTokenRequest.h>
using AlibabaCloud::DemoCenter::Model::ExpireDemoAccessTokenRequest;
ExpireDemoAccessTokenRequest::ExpireDemoAccessTokenRequest() :
RpcServiceRequest("democenter", "2020-01-21", "ExpireDemoAccessToken")
{
setMethod(HttpRequest::Method::Post);
}
ExpireDemoAccessTokenRequest::~ExpireDemoAccessTokenRequest()
{}
std::string ExpireDemoAccessTokenRequest::getDemoAccessToken()const
{
return demoAccessToken_;
}
void ExpireDemoAccessTokenRequest::setDemoAccessToken(const std::string& demoAccessToken)
{
demoAccessToken_ = demoAccessToken;
setBodyParameter("DemoAccessToken", demoAccessToken);
}

View File

@@ -0,0 +1,44 @@
/*
* 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/ExpireDemoAccessTokenResult.h>
#include <json/json.h>
using namespace AlibabaCloud::DemoCenter;
using namespace AlibabaCloud::DemoCenter::Model;
ExpireDemoAccessTokenResult::ExpireDemoAccessTokenResult() :
ServiceResult()
{}
ExpireDemoAccessTokenResult::ExpireDemoAccessTokenResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
ExpireDemoAccessTokenResult::~ExpireDemoAccessTokenResult()
{}
void ExpireDemoAccessTokenResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
}