由荣旸发起的TESLAMAXCOMPUTE SDK自动发布, BUILD_ID=314, 版本号:1.2.4

Signed-off-by: haowei.yao <haowei.yao@alibaba-inc.com>
This commit is contained in:
haowei.yao
2018-02-28 11:38:05 +08:00
parent 96d9eb7efd
commit 78ee1b30bd
11 changed files with 330 additions and 15 deletions

View File

@@ -131,6 +131,42 @@ TeslaMaxComputeClient::GetProjectInstanceOutcomeCallable TeslaMaxComputeClient::
return task->get_future();
}
TeslaMaxComputeClient::QueryResourceInventoryOutcome TeslaMaxComputeClient::queryResourceInventory(const QueryResourceInventoryRequest &request) const
{
auto endpointOutcome = endpoint();
if (!endpointOutcome.isSuccess())
return QueryResourceInventoryOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return QueryResourceInventoryOutcome(QueryResourceInventoryResult(outcome.result()));
else
return QueryResourceInventoryOutcome(outcome.error());
}
void TeslaMaxComputeClient::queryResourceInventoryAsync(const QueryResourceInventoryRequest& request, const QueryResourceInventoryAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, queryResourceInventory(request), context);
};
asyncExecute(new Runnable(fn));
}
TeslaMaxComputeClient::QueryResourceInventoryOutcomeCallable TeslaMaxComputeClient::queryResourceInventoryCallable(const QueryResourceInventoryRequest &request) const
{
auto task = std::make_shared<std::packaged_task<QueryResourceInventoryOutcome()>>(
[this, request]()
{
return this->queryResourceInventory(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
TeslaMaxComputeClient::QueryTopologyOutcome TeslaMaxComputeClient::queryTopology(const QueryTopologyRequest &request) const
{
auto endpointOutcome = endpoint();

View File

@@ -0,0 +1,27 @@
/*
* 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/teslamaxcompute/model/QueryResourceInventoryRequest.h>
using AlibabaCloud::TeslaMaxCompute::Model::QueryResourceInventoryRequest;
QueryResourceInventoryRequest::QueryResourceInventoryRequest() :
RpcServiceRequest("teslamaxcompute", "2018-01-04", "QueryResourceInventory")
{}
QueryResourceInventoryRequest::~QueryResourceInventoryRequest()
{}

View File

@@ -0,0 +1,110 @@
/*
* 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/teslamaxcompute/model/QueryResourceInventoryResult.h>
#include <json/json.h>
using namespace AlibabaCloud::TeslaMaxCompute;
using namespace AlibabaCloud::TeslaMaxCompute::Model;
QueryResourceInventoryResult::QueryResourceInventoryResult() :
ServiceResult()
{}
QueryResourceInventoryResult::QueryResourceInventoryResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
QueryResourceInventoryResult::~QueryResourceInventoryResult()
{}
void QueryResourceInventoryResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
auto allData = value["Data"];
for (auto value : allData)
{
Data dataObject;
if(!value["LastUpdate"].isNull())
dataObject.lastUpdate = value["LastUpdate"].asString();
auto allClusters = value["Clusters"]["cluster"];
for (auto value : allClusters)
{
Data::Cluster clusterObject;
if(!value["Status"].isNull())
clusterObject.status = value["Status"].asString();
if(!value["Cluster"].isNull())
clusterObject.cluster = value["Cluster"].asString();
if(!value["MachineRoom"].isNull())
clusterObject.machineRoom = value["MachineRoom"].asString();
if(!value["Region"].isNull())
clusterObject.region = value["Region"].asString();
auto allResourceParameters = value["ResourceParameters"]["resourceParameter"];
for (auto value : allResourceParameters)
{
Data::Cluster::ResourceParameter resourceParametersObject;
if(!value["ParaName"].isNull())
resourceParametersObject.paraName = value["ParaName"].asString();
if(!value["ParaValue"].isNull())
resourceParametersObject.paraValue = value["ParaValue"].asString();
clusterObject.resourceParameters.push_back(resourceParametersObject);
}
auto allResourceInventories = value["ResourceInventories"]["resourceInventory"];
for (auto value : allResourceInventories)
{
Data::Cluster::ResourceInventory resourceInventoriesObject;
if(!value["Total"].isNull())
resourceInventoriesObject.total = std::stol(value["Total"].asString());
if(!value["Available"].isNull())
resourceInventoriesObject.available = std::stol(value["Available"].asString());
if(!value["Used"].isNull())
resourceInventoriesObject.used = std::stol(value["Used"].asString());
if(!value["ResourceType"].isNull())
resourceInventoriesObject.resourceType = value["ResourceType"].asString();
clusterObject.resourceInventories.push_back(resourceInventoriesObject);
}
dataObject.clusters.push_back(clusterObject);
}
data_.push_back(dataObject);
}
if(!value["Code"].isNull())
code_ = std::stoi(value["Code"].asString());
if(!value["Message"].isNull())
message_ = value["Message"].asString();
}
std::string QueryResourceInventoryResult::getMessage()const
{
return message_;
}
std::vector<QueryResourceInventoryResult::Data> QueryResourceInventoryResult::getData()const
{
return data_;
}
int QueryResourceInventoryResult::getCode()const
{
return code_;
}

View File

@@ -40,26 +40,26 @@ void QueryTopologyResult::parse(const std::string &payload)
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
auto allResult = value["Result"];
auto allResult = value["Result"]["resultItem"];
for (auto value : allResult)
{
Result resultObject;
ResultItem resultObject;
if(!value["LastUpdate"].isNull())
resultObject.lastUpdate = value["LastUpdate"].asString();
auto allRegions = value["Regions"];
auto allRegions = value["Regions"]["regionItem"];
for (auto value : allRegions)
{
Result::Regions regionsObject;
ResultItem::RegionItem regionsObject;
if(!value["Region"].isNull())
regionsObject.region = value["Region"].asString();
if(!value["RegionEnName"].isNull())
regionsObject.regionEnName = value["RegionEnName"].asString();
if(!value["RegionCnName"].isNull())
regionsObject.regionCnName = value["RegionCnName"].asString();
auto allClusters = value["Clusters"];
auto allClusters = value["Clusters"]["clusterItem"];
for (auto value : allClusters)
{
Result::Regions::Clusters clustersObject;
ResultItem::RegionItem::ClusterItem clustersObject;
if(!value["Cluster"].isNull())
clustersObject.cluster = value["Cluster"].asString();
if(!value["ProductLine"].isNull())
@@ -97,7 +97,7 @@ int QueryTopologyResult::getCode()const
return code_;
}
std::vector<QueryTopologyResult::Result> QueryTopologyResult::getResult()const
std::vector<QueryTopologyResult::ResultItem> QueryTopologyResult::getResult()const
{
return result_;
}