DescribeMetricRuleTemplateListResult.cc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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/cms/model/DescribeMetricRuleTemplateListResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Cms;
  19. using namespace AlibabaCloud::Cms::Model;
  20. DescribeMetricRuleTemplateListResult::DescribeMetricRuleTemplateListResult() :
  21. ServiceResult()
  22. {}
  23. DescribeMetricRuleTemplateListResult::DescribeMetricRuleTemplateListResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeMetricRuleTemplateListResult::~DescribeMetricRuleTemplateListResult()
  29. {}
  30. void DescribeMetricRuleTemplateListResult::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 allTemplatesNode = value["Templates"]["Template"];
  37. for (auto valueTemplatesTemplate : allTemplatesNode)
  38. {
  39. _Template templatesObject;
  40. if(!valueTemplatesTemplate["Name"].isNull())
  41. templatesObject.name = valueTemplatesTemplate["Name"].asString();
  42. if(!valueTemplatesTemplate["Description"].isNull())
  43. templatesObject.description = valueTemplatesTemplate["Description"].asString();
  44. if(!valueTemplatesTemplate["RestVersion"].isNull())
  45. templatesObject.restVersion = std::stol(valueTemplatesTemplate["RestVersion"].asString());
  46. if(!valueTemplatesTemplate["TemplateId"].isNull())
  47. templatesObject.templateId = std::stol(valueTemplatesTemplate["TemplateId"].asString());
  48. if(!valueTemplatesTemplate["GmtCreate"].isNull())
  49. templatesObject.gmtCreate = std::stol(valueTemplatesTemplate["GmtCreate"].asString());
  50. if(!valueTemplatesTemplate["GmtModified"].isNull())
  51. templatesObject.gmtModified = std::stol(valueTemplatesTemplate["GmtModified"].asString());
  52. auto allApplyHistoriesNode = allTemplatesNode["ApplyHistories"]["ApplyHistory"];
  53. for (auto allTemplatesNodeApplyHistoriesApplyHistory : allApplyHistoriesNode)
  54. {
  55. _Template::ApplyHistory applyHistoriesObject;
  56. if(!allTemplatesNodeApplyHistoriesApplyHistory["GroupId"].isNull())
  57. applyHistoriesObject.groupId = std::stol(allTemplatesNodeApplyHistoriesApplyHistory["GroupId"].asString());
  58. if(!allTemplatesNodeApplyHistoriesApplyHistory["GroupName"].isNull())
  59. applyHistoriesObject.groupName = allTemplatesNodeApplyHistoriesApplyHistory["GroupName"].asString();
  60. if(!allTemplatesNodeApplyHistoriesApplyHistory["ApplyTime"].isNull())
  61. applyHistoriesObject.applyTime = std::stol(allTemplatesNodeApplyHistoriesApplyHistory["ApplyTime"].asString());
  62. templatesObject.applyHistories.push_back(applyHistoriesObject);
  63. }
  64. templates_.push_back(templatesObject);
  65. }
  66. if(!value["Success"].isNull())
  67. success_ = value["Success"].asString() == "true";
  68. if(!value["Code"].isNull())
  69. code_ = std::stoi(value["Code"].asString());
  70. if(!value["Message"].isNull())
  71. message_ = value["Message"].asString();
  72. if(!value["Total"].isNull())
  73. total_ = std::stol(value["Total"].asString());
  74. }
  75. std::string DescribeMetricRuleTemplateListResult::getMessage()const
  76. {
  77. return message_;
  78. }
  79. long DescribeMetricRuleTemplateListResult::getTotal()const
  80. {
  81. return total_;
  82. }
  83. std::vector<DescribeMetricRuleTemplateListResult::_Template> DescribeMetricRuleTemplateListResult::getTemplates()const
  84. {
  85. return templates_;
  86. }
  87. int DescribeMetricRuleTemplateListResult::getCode()const
  88. {
  89. return code_;
  90. }
  91. bool DescribeMetricRuleTemplateListResult::getSuccess()const
  92. {
  93. return success_;
  94. }