ListQueuesResult.cc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright 2009-2017 Alibaba Cloud All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <alibabacloud/ehpc/model/ListQueuesResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::EHPC;
  19. using namespace AlibabaCloud::EHPC::Model;
  20. ListQueuesResult::ListQueuesResult() :
  21. ServiceResult()
  22. {}
  23. ListQueuesResult::ListQueuesResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListQueuesResult::~ListQueuesResult()
  29. {}
  30. void ListQueuesResult::parse(const std::string &payload)
  31. {
  32. Json::Reader reader;
  33. Json::Value value;
  34. reader.parse(payload, value);
  35. setRequestId(value["RequestId"].asString());
  36. auto allQueuesNode = value["Queues"]["QueueInfo"];
  37. for (auto valueQueuesQueueInfo : allQueuesNode)
  38. {
  39. QueueInfo queuesObject;
  40. if(!valueQueuesQueueInfo["Type"].isNull())
  41. queuesObject.type = valueQueuesQueueInfo["Type"].asString();
  42. if(!valueQueuesQueueInfo["HostNamePrefix"].isNull())
  43. queuesObject.hostNamePrefix = valueQueuesQueueInfo["HostNamePrefix"].asString();
  44. if(!valueQueuesQueueInfo["QueueName"].isNull())
  45. queuesObject.queueName = valueQueuesQueueInfo["QueueName"].asString();
  46. if(!valueQueuesQueueInfo["EnableAutoGrow"].isNull())
  47. queuesObject.enableAutoGrow = valueQueuesQueueInfo["EnableAutoGrow"].asString() == "true";
  48. if(!valueQueuesQueueInfo["ResourceGroupId"].isNull())
  49. queuesObject.resourceGroupId = valueQueuesQueueInfo["ResourceGroupId"].asString();
  50. if(!valueQueuesQueueInfo["ImageId"].isNull())
  51. queuesObject.imageId = valueQueuesQueueInfo["ImageId"].asString();
  52. if(!valueQueuesQueueInfo["HostNameSuffix"].isNull())
  53. queuesObject.hostNameSuffix = valueQueuesQueueInfo["HostNameSuffix"].asString();
  54. if(!valueQueuesQueueInfo["SpotStrategy"].isNull())
  55. queuesObject.spotStrategy = valueQueuesQueueInfo["SpotStrategy"].asString();
  56. if(!valueQueuesQueueInfo["DeploymentSetId"].isNull())
  57. queuesObject.deploymentSetId = valueQueuesQueueInfo["DeploymentSetId"].asString();
  58. if(!valueQueuesQueueInfo["UseESS"].isNull())
  59. queuesObject.useESS = valueQueuesQueueInfo["UseESS"].asString() == "true";
  60. if(!valueQueuesQueueInfo["NetworkInterfaceTrafficMode"].isNull())
  61. queuesObject.networkInterfaceTrafficMode = valueQueuesQueueInfo["NetworkInterfaceTrafficMode"].asString();
  62. auto allSpotInstanceTypesNode = valueQueuesQueueInfo["SpotInstanceTypes"]["Instance"];
  63. for (auto valueQueuesQueueInfoSpotInstanceTypesInstance : allSpotInstanceTypesNode)
  64. {
  65. QueueInfo::Instance spotInstanceTypesObject;
  66. if(!valueQueuesQueueInfoSpotInstanceTypesInstance["InstanceType"].isNull())
  67. spotInstanceTypesObject.instanceType = valueQueuesQueueInfoSpotInstanceTypesInstance["InstanceType"].asString();
  68. if(!valueQueuesQueueInfoSpotInstanceTypesInstance["SpotPriceLimit"].isNull())
  69. spotInstanceTypesObject.spotPriceLimit = std::stof(valueQueuesQueueInfoSpotInstanceTypesInstance["SpotPriceLimit"].asString());
  70. queuesObject.spotInstanceTypes.push_back(spotInstanceTypesObject);
  71. }
  72. auto allComputeInstanceType = value["ComputeInstanceType"]["InstanceType"];
  73. for (auto value : allComputeInstanceType)
  74. queuesObject.computeInstanceType.push_back(value.asString());
  75. queues_.push_back(queuesObject);
  76. }
  77. }
  78. std::vector<ListQueuesResult::QueueInfo> ListQueuesResult::getQueues()const
  79. {
  80. return queues_;
  81. }