Supported CloudGame.
This commit is contained in:
125
cloudgame/src/CloudgameClient.cc
Normal file
125
cloudgame/src/CloudgameClient.cc
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* 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/cloudgame/CloudgameClient.h>
|
||||
#include <alibabacloud/core/SimpleCredentialsProvider.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
using namespace AlibabaCloud::Location;
|
||||
using namespace AlibabaCloud::Cloudgame;
|
||||
using namespace AlibabaCloud::Cloudgame::Model;
|
||||
|
||||
namespace
|
||||
{
|
||||
const std::string SERVICE_NAME = "cloudgame";
|
||||
}
|
||||
|
||||
CloudgameClient::CloudgameClient(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, "");
|
||||
}
|
||||
|
||||
CloudgameClient::CloudgameClient(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, "");
|
||||
}
|
||||
|
||||
CloudgameClient::CloudgameClient(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, "");
|
||||
}
|
||||
|
||||
CloudgameClient::~CloudgameClient()
|
||||
{}
|
||||
|
||||
CloudgameClient::ListGamesOutcome CloudgameClient::listGames(const ListGamesRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
if (!endpointOutcome.isSuccess())
|
||||
return ListGamesOutcome(endpointOutcome.error());
|
||||
|
||||
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return ListGamesOutcome(ListGamesResult(outcome.result()));
|
||||
else
|
||||
return ListGamesOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void CloudgameClient::listGamesAsync(const ListGamesRequest& request, const ListGamesAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
handler(this, request, listGames(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
CloudgameClient::ListGamesOutcomeCallable CloudgameClient::listGamesCallable(const ListGamesRequest &request) const
|
||||
{
|
||||
auto task = std::make_shared<std::packaged_task<ListGamesOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
return this->listGames(request);
|
||||
});
|
||||
|
||||
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
CloudgameClient::ListProjectsOutcome CloudgameClient::listProjects(const ListProjectsRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
if (!endpointOutcome.isSuccess())
|
||||
return ListProjectsOutcome(endpointOutcome.error());
|
||||
|
||||
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return ListProjectsOutcome(ListProjectsResult(outcome.result()));
|
||||
else
|
||||
return ListProjectsOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void CloudgameClient::listProjectsAsync(const ListProjectsRequest& request, const ListProjectsAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
handler(this, request, listProjects(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
CloudgameClient::ListProjectsOutcomeCallable CloudgameClient::listProjectsCallable(const ListProjectsRequest &request) const
|
||||
{
|
||||
auto task = std::make_shared<std::packaged_task<ListProjectsOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
return this->listProjects(request);
|
||||
});
|
||||
|
||||
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
73
cloudgame/src/model/ListGamesRequest.cc
Normal file
73
cloudgame/src/model/ListGamesRequest.cc
Normal file
@@ -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 <alibabacloud/cloudgame/model/ListGamesRequest.h>
|
||||
|
||||
using AlibabaCloud::Cloudgame::Model::ListGamesRequest;
|
||||
|
||||
ListGamesRequest::ListGamesRequest() :
|
||||
RpcServiceRequest("cloudgame", "2020-04-29", "ListGames")
|
||||
{
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
ListGamesRequest::~ListGamesRequest()
|
||||
{}
|
||||
|
||||
std::string ListGamesRequest::getOrderKey()const
|
||||
{
|
||||
return orderKey_;
|
||||
}
|
||||
|
||||
void ListGamesRequest::setOrderKey(const std::string& orderKey)
|
||||
{
|
||||
orderKey_ = orderKey;
|
||||
setParameter("OrderKey", orderKey);
|
||||
}
|
||||
|
||||
std::string ListGamesRequest::getSortType()const
|
||||
{
|
||||
return sortType_;
|
||||
}
|
||||
|
||||
void ListGamesRequest::setSortType(const std::string& sortType)
|
||||
{
|
||||
sortType_ = sortType;
|
||||
setParameter("SortType", sortType);
|
||||
}
|
||||
|
||||
int ListGamesRequest::getPageNumber()const
|
||||
{
|
||||
return pageNumber_;
|
||||
}
|
||||
|
||||
void ListGamesRequest::setPageNumber(int pageNumber)
|
||||
{
|
||||
pageNumber_ = pageNumber;
|
||||
setParameter("PageNumber", std::to_string(pageNumber));
|
||||
}
|
||||
|
||||
int ListGamesRequest::getPageSize()const
|
||||
{
|
||||
return pageSize_;
|
||||
}
|
||||
|
||||
void ListGamesRequest::setPageSize(int pageSize)
|
||||
{
|
||||
pageSize_ = pageSize;
|
||||
setParameter("PageSize", std::to_string(pageSize));
|
||||
}
|
||||
|
||||
96
cloudgame/src/model/ListGamesResult.cc
Normal file
96
cloudgame/src/model/ListGamesResult.cc
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* 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/cloudgame/model/ListGamesResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Cloudgame;
|
||||
using namespace AlibabaCloud::Cloudgame::Model;
|
||||
|
||||
ListGamesResult::ListGamesResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
ListGamesResult::ListGamesResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
ListGamesResult::~ListGamesResult()
|
||||
{}
|
||||
|
||||
void ListGamesResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
auto allDataListNode = value["DataList"]["DataListItem"];
|
||||
for (auto valueDataListDataListItem : allDataListNode)
|
||||
{
|
||||
DataListItem dataListObject;
|
||||
if(!valueDataListDataListItem["GameId"].isNull())
|
||||
dataListObject.gameId = valueDataListDataListItem["GameId"].asString();
|
||||
if(!valueDataListDataListItem["GameName"].isNull())
|
||||
dataListObject.gameName = valueDataListDataListItem["GameName"].asString();
|
||||
if(!valueDataListDataListItem["InstallPath"].isNull())
|
||||
dataListObject.installPath = valueDataListDataListItem["InstallPath"].asString();
|
||||
if(!valueDataListDataListItem["SavePath"].isNull())
|
||||
dataListObject.savePath = valueDataListDataListItem["SavePath"].asString();
|
||||
if(!valueDataListDataListItem["Resolution"].isNull())
|
||||
dataListObject.resolution = valueDataListDataListItem["Resolution"].asString();
|
||||
if(!valueDataListDataListItem["FrameRate"].isNull())
|
||||
dataListObject.frameRate = valueDataListDataListItem["FrameRate"].asString();
|
||||
if(!valueDataListDataListItem["InputType"].isNull())
|
||||
dataListObject.inputType = valueDataListDataListItem["InputType"].asString();
|
||||
if(!valueDataListDataListItem["Device"].isNull())
|
||||
dataListObject.device = valueDataListDataListItem["Device"].asString();
|
||||
if(!valueDataListDataListItem["Status"].isNull())
|
||||
dataListObject.status = valueDataListDataListItem["Status"].asString();
|
||||
if(!valueDataListDataListItem["CurVersion"].isNull())
|
||||
dataListObject.curVersion = valueDataListDataListItem["CurVersion"].asString();
|
||||
dataList_.push_back(dataListObject);
|
||||
}
|
||||
if(!value["Count"].isNull())
|
||||
count_ = value["Count"].asString();
|
||||
if(!value["PageSize"].isNull())
|
||||
pageSize_ = std::stoi(value["PageSize"].asString());
|
||||
if(!value["CurrentPage"].isNull())
|
||||
currentPage_ = std::stoi(value["CurrentPage"].asString());
|
||||
|
||||
}
|
||||
|
||||
std::vector<ListGamesResult::DataListItem> ListGamesResult::getDataList()const
|
||||
{
|
||||
return dataList_;
|
||||
}
|
||||
|
||||
int ListGamesResult::getPageSize()const
|
||||
{
|
||||
return pageSize_;
|
||||
}
|
||||
|
||||
int ListGamesResult::getCurrentPage()const
|
||||
{
|
||||
return currentPage_;
|
||||
}
|
||||
|
||||
std::string ListGamesResult::getCount()const
|
||||
{
|
||||
return count_;
|
||||
}
|
||||
|
||||
62
cloudgame/src/model/ListProjectsRequest.cc
Normal file
62
cloudgame/src/model/ListProjectsRequest.cc
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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/cloudgame/model/ListProjectsRequest.h>
|
||||
|
||||
using AlibabaCloud::Cloudgame::Model::ListProjectsRequest;
|
||||
|
||||
ListProjectsRequest::ListProjectsRequest() :
|
||||
RpcServiceRequest("cloudgame", "2020-04-29", "ListProjects")
|
||||
{
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
ListProjectsRequest::~ListProjectsRequest()
|
||||
{}
|
||||
|
||||
std::string ListProjectsRequest::getProjectName()const
|
||||
{
|
||||
return projectName_;
|
||||
}
|
||||
|
||||
void ListProjectsRequest::setProjectName(const std::string& projectName)
|
||||
{
|
||||
projectName_ = projectName;
|
||||
setParameter("ProjectName", projectName);
|
||||
}
|
||||
|
||||
int ListProjectsRequest::getPageNumber()const
|
||||
{
|
||||
return pageNumber_;
|
||||
}
|
||||
|
||||
void ListProjectsRequest::setPageNumber(int pageNumber)
|
||||
{
|
||||
pageNumber_ = pageNumber;
|
||||
setParameter("PageNumber", std::to_string(pageNumber));
|
||||
}
|
||||
|
||||
int ListProjectsRequest::getPageSize()const
|
||||
{
|
||||
return pageSize_;
|
||||
}
|
||||
|
||||
void ListProjectsRequest::setPageSize(int pageSize)
|
||||
{
|
||||
pageSize_ = pageSize;
|
||||
setParameter("PageSize", std::to_string(pageSize));
|
||||
}
|
||||
|
||||
94
cloudgame/src/model/ListProjectsResult.cc
Normal file
94
cloudgame/src/model/ListProjectsResult.cc
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* 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/cloudgame/model/ListProjectsResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Cloudgame;
|
||||
using namespace AlibabaCloud::Cloudgame::Model;
|
||||
|
||||
ListProjectsResult::ListProjectsResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
ListProjectsResult::ListProjectsResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
ListProjectsResult::~ListProjectsResult()
|
||||
{}
|
||||
|
||||
void ListProjectsResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
auto allDataListNode = value["DataList"]["DataListItem"];
|
||||
for (auto valueDataListDataListItem : allDataListNode)
|
||||
{
|
||||
DataListItem dataListObject;
|
||||
if(!valueDataListDataListItem["StandardCodeRate"].isNull())
|
||||
dataListObject.standardCodeRate = valueDataListDataListItem["StandardCodeRate"].asString();
|
||||
if(!valueDataListDataListItem["HighDefinitionResolution"].isNull())
|
||||
dataListObject.highDefinitionResolution = valueDataListDataListItem["HighDefinitionResolution"].asString();
|
||||
if(!valueDataListDataListItem["HighDefinitionCodeRate"].isNull())
|
||||
dataListObject.highDefinitionCodeRate = valueDataListDataListItem["HighDefinitionCodeRate"].asString();
|
||||
if(!valueDataListDataListItem["StandardResolution"].isNull())
|
||||
dataListObject.standardResolution = valueDataListDataListItem["StandardResolution"].asString();
|
||||
if(!valueDataListDataListItem["ProjectId"].isNull())
|
||||
dataListObject.projectId = valueDataListDataListItem["ProjectId"].asString();
|
||||
if(!valueDataListDataListItem["ConcurrencyLimitNumber"].isNull())
|
||||
dataListObject.concurrencyLimitNumber = std::stoi(valueDataListDataListItem["ConcurrencyLimitNumber"].asString());
|
||||
if(!valueDataListDataListItem["HighestCodeRate"].isNull())
|
||||
dataListObject.highestCodeRate = valueDataListDataListItem["HighestCodeRate"].asString();
|
||||
if(!valueDataListDataListItem["ProjectName"].isNull())
|
||||
dataListObject.projectName = valueDataListDataListItem["ProjectName"].asString();
|
||||
if(!valueDataListDataListItem["HighestResolution"].isNull())
|
||||
dataListObject.highestResolution = valueDataListDataListItem["HighestResolution"].asString();
|
||||
dataList_.push_back(dataListObject);
|
||||
}
|
||||
if(!value["Count"].isNull())
|
||||
count_ = std::stoi(value["Count"].asString());
|
||||
if(!value["CurrentPage"].isNull())
|
||||
currentPage_ = std::stoi(value["CurrentPage"].asString());
|
||||
if(!value["PageSize"].isNull())
|
||||
pageSize_ = std::stoi(value["PageSize"].asString());
|
||||
|
||||
}
|
||||
|
||||
std::vector<ListProjectsResult::DataListItem> ListProjectsResult::getDataList()const
|
||||
{
|
||||
return dataList_;
|
||||
}
|
||||
|
||||
int ListProjectsResult::getPageSize()const
|
||||
{
|
||||
return pageSize_;
|
||||
}
|
||||
|
||||
int ListProjectsResult::getCurrentPage()const
|
||||
{
|
||||
return currentPage_;
|
||||
}
|
||||
|
||||
int ListProjectsResult::getCount()const
|
||||
{
|
||||
return count_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user