ListApplicationsResult.cc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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/sae/model/ListApplicationsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Sae;
  19. using namespace AlibabaCloud::Sae::Model;
  20. ListApplicationsResult::ListApplicationsResult() :
  21. ServiceResult()
  22. {}
  23. ListApplicationsResult::ListApplicationsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListApplicationsResult::~ListApplicationsResult()
  29. {}
  30. void ListApplicationsResult::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 dataNode = value["Data"];
  37. if(!dataNode["CurrentPage"].isNull())
  38. data_.currentPage = std::stoi(dataNode["CurrentPage"].asString());
  39. if(!dataNode["PageSize"].isNull())
  40. data_.pageSize = std::stoi(dataNode["PageSize"].asString());
  41. if(!dataNode["TotalSize"].isNull())
  42. data_.totalSize = std::stoi(dataNode["TotalSize"].asString());
  43. auto allApplicationsNode = dataNode["Applications"]["Application"];
  44. for (auto dataNodeApplicationsApplication : allApplicationsNode)
  45. {
  46. Data::Application applicationObject;
  47. if(!dataNodeApplicationsApplication["AppDeletingStatus"].isNull())
  48. applicationObject.appDeletingStatus = dataNodeApplicationsApplication["AppDeletingStatus"].asString() == "true";
  49. if(!dataNodeApplicationsApplication["AppId"].isNull())
  50. applicationObject.appId = dataNodeApplicationsApplication["AppId"].asString();
  51. if(!dataNodeApplicationsApplication["AppName"].isNull())
  52. applicationObject.appName = dataNodeApplicationsApplication["AppName"].asString();
  53. if(!dataNodeApplicationsApplication["RegionId"].isNull())
  54. applicationObject.regionId = dataNodeApplicationsApplication["RegionId"].asString();
  55. if(!dataNodeApplicationsApplication["RunningInstances"].isNull())
  56. applicationObject.runningInstances = std::stoi(dataNodeApplicationsApplication["RunningInstances"].asString());
  57. if(!dataNodeApplicationsApplication["Instances"].isNull())
  58. applicationObject.instances = std::stoi(dataNodeApplicationsApplication["Instances"].asString());
  59. if(!dataNodeApplicationsApplication["NamespaceId"].isNull())
  60. applicationObject.namespaceId = dataNodeApplicationsApplication["NamespaceId"].asString();
  61. if(!dataNodeApplicationsApplication["ScaleRuleType"].isNull())
  62. applicationObject.scaleRuleType = dataNodeApplicationsApplication["ScaleRuleType"].asString();
  63. if(!dataNodeApplicationsApplication["ScaleRuleEnabled"].isNull())
  64. applicationObject.scaleRuleEnabled = dataNodeApplicationsApplication["ScaleRuleEnabled"].asString() == "true";
  65. auto allTagsNode = allApplicationsNode["Tags"]["TagsItem"];
  66. for (auto allApplicationsNodeTagsTagsItem : allTagsNode)
  67. {
  68. Data::Application::TagsItem tagsObject;
  69. if(!allApplicationsNodeTagsTagsItem["Key"].isNull())
  70. tagsObject.key = allApplicationsNodeTagsTagsItem["Key"].asString();
  71. if(!allApplicationsNodeTagsTagsItem["Value"].isNull())
  72. tagsObject.value = allApplicationsNodeTagsTagsItem["Value"].asString();
  73. applicationObject.tags.push_back(tagsObject);
  74. }
  75. data_.applications.push_back(applicationObject);
  76. }
  77. if(!value["Code"].isNull())
  78. code_ = value["Code"].asString();
  79. if(!value["Message"].isNull())
  80. message_ = value["Message"].asString();
  81. if(!value["Success"].isNull())
  82. success_ = value["Success"].asString() == "true";
  83. if(!value["ErrorCode"].isNull())
  84. errorCode_ = value["ErrorCode"].asString();
  85. }
  86. std::string ListApplicationsResult::getMessage()const
  87. {
  88. return message_;
  89. }
  90. ListApplicationsResult::Data ListApplicationsResult::getData()const
  91. {
  92. return data_;
  93. }
  94. std::string ListApplicationsResult::getErrorCode()const
  95. {
  96. return errorCode_;
  97. }
  98. std::string ListApplicationsResult::getCode()const
  99. {
  100. return code_;
  101. }
  102. bool ListApplicationsResult::getSuccess()const
  103. {
  104. return success_;
  105. }