DescribeMonitorGroupsResult.cc 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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/DescribeMonitorGroupsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Cms;
  19. using namespace AlibabaCloud::Cms::Model;
  20. DescribeMonitorGroupsResult::DescribeMonitorGroupsResult() :
  21. ServiceResult()
  22. {}
  23. DescribeMonitorGroupsResult::DescribeMonitorGroupsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeMonitorGroupsResult::~DescribeMonitorGroupsResult()
  29. {}
  30. void DescribeMonitorGroupsResult::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 allResourcesNode = value["Resources"]["Resource"];
  37. for (auto valueResourcesResource : allResourcesNode)
  38. {
  39. Resource resourcesObject;
  40. if(!valueResourcesResource["GroupId"].isNull())
  41. resourcesObject.groupId = std::stol(valueResourcesResource["GroupId"].asString());
  42. if(!valueResourcesResource["GroupName"].isNull())
  43. resourcesObject.groupName = valueResourcesResource["GroupName"].asString();
  44. if(!valueResourcesResource["ServiceId"].isNull())
  45. resourcesObject.serviceId = valueResourcesResource["ServiceId"].asString();
  46. if(!valueResourcesResource["Type"].isNull())
  47. resourcesObject.type = valueResourcesResource["Type"].asString();
  48. if(!valueResourcesResource["GmtModified"].isNull())
  49. resourcesObject.gmtModified = std::stol(valueResourcesResource["GmtModified"].asString());
  50. if(!valueResourcesResource["GmtCreate"].isNull())
  51. resourcesObject.gmtCreate = std::stol(valueResourcesResource["GmtCreate"].asString());
  52. if(!valueResourcesResource["BindUrl"].isNull())
  53. resourcesObject.bindUrl = valueResourcesResource["BindUrl"].asString();
  54. if(!valueResourcesResource["DynamicTagRuleId"].isNull())
  55. resourcesObject.dynamicTagRuleId = valueResourcesResource["DynamicTagRuleId"].asString();
  56. if(!valueResourcesResource["GroupFounderTagKey"].isNull())
  57. resourcesObject.groupFounderTagKey = valueResourcesResource["GroupFounderTagKey"].asString();
  58. if(!valueResourcesResource["GroupFounderTagValue"].isNull())
  59. resourcesObject.groupFounderTagValue = valueResourcesResource["GroupFounderTagValue"].asString();
  60. auto allContactGroupsNode = allResourcesNode["ContactGroups"]["ContactGroup"];
  61. for (auto allResourcesNodeContactGroupsContactGroup : allContactGroupsNode)
  62. {
  63. Resource::ContactGroup contactGroupsObject;
  64. if(!allResourcesNodeContactGroupsContactGroup["Name"].isNull())
  65. contactGroupsObject.name = allResourcesNodeContactGroupsContactGroup["Name"].asString();
  66. resourcesObject.contactGroups.push_back(contactGroupsObject);
  67. }
  68. auto allTagsNode = allResourcesNode["Tags"]["Tag"];
  69. for (auto allResourcesNodeTagsTag : allTagsNode)
  70. {
  71. Resource::Tag tagsObject;
  72. if(!allResourcesNodeTagsTag["Key"].isNull())
  73. tagsObject.key = allResourcesNodeTagsTag["Key"].asString();
  74. if(!allResourcesNodeTagsTag["Value"].isNull())
  75. tagsObject.value = allResourcesNodeTagsTag["Value"].asString();
  76. resourcesObject.tags.push_back(tagsObject);
  77. }
  78. auto allTemplateIds = value["TemplateIds"]["TemplateId"];
  79. for (auto value : allTemplateIds)
  80. resourcesObject.templateIds.push_back(value.asString());
  81. resources_.push_back(resourcesObject);
  82. }
  83. if(!value["Success"].isNull())
  84. success_ = value["Success"].asString() == "true";
  85. if(!value["Code"].isNull())
  86. code_ = std::stoi(value["Code"].asString());
  87. if(!value["Message"].isNull())
  88. message_ = value["Message"].asString();
  89. if(!value["PageNumber"].isNull())
  90. pageNumber_ = std::stoi(value["PageNumber"].asString());
  91. if(!value["PageSize"].isNull())
  92. pageSize_ = std::stoi(value["PageSize"].asString());
  93. if(!value["Total"].isNull())
  94. total_ = std::stoi(value["Total"].asString());
  95. }
  96. std::string DescribeMonitorGroupsResult::getMessage()const
  97. {
  98. return message_;
  99. }
  100. int DescribeMonitorGroupsResult::getPageSize()const
  101. {
  102. return pageSize_;
  103. }
  104. int DescribeMonitorGroupsResult::getPageNumber()const
  105. {
  106. return pageNumber_;
  107. }
  108. int DescribeMonitorGroupsResult::getTotal()const
  109. {
  110. return total_;
  111. }
  112. std::vector<DescribeMonitorGroupsResult::Resource> DescribeMonitorGroupsResult::getResources()const
  113. {
  114. return resources_;
  115. }
  116. int DescribeMonitorGroupsResult::getCode()const
  117. {
  118. return code_;
  119. }
  120. bool DescribeMonitorGroupsResult::getSuccess()const
  121. {
  122. return success_;
  123. }