GetElasticNetworkInterfaceResult.cc 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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/eflo/model/GetElasticNetworkInterfaceResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Eflo;
  19. using namespace AlibabaCloud::Eflo::Model;
  20. GetElasticNetworkInterfaceResult::GetElasticNetworkInterfaceResult() :
  21. ServiceResult()
  22. {}
  23. GetElasticNetworkInterfaceResult::GetElasticNetworkInterfaceResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. GetElasticNetworkInterfaceResult::~GetElasticNetworkInterfaceResult()
  29. {}
  30. void GetElasticNetworkInterfaceResult::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 contentNode = value["Content"];
  37. if(!contentNode["RegionId"].isNull())
  38. content_.regionId = contentNode["RegionId"].asString();
  39. if(!contentNode["ZoneId"].isNull())
  40. content_.zoneId = contentNode["ZoneId"].asString();
  41. if(!contentNode["ElasticNetworkInterfaceId"].isNull())
  42. content_.elasticNetworkInterfaceId = contentNode["ElasticNetworkInterfaceId"].asString();
  43. if(!contentNode["NodeId"].isNull())
  44. content_.nodeId = contentNode["NodeId"].asString();
  45. if(!contentNode["Status"].isNull())
  46. content_.status = contentNode["Status"].asString();
  47. if(!contentNode["Ip"].isNull())
  48. content_.ip = contentNode["Ip"].asString();
  49. if(!contentNode["VpcId"].isNull())
  50. content_.vpcId = contentNode["VpcId"].asString();
  51. if(!contentNode["VSwitchId"].isNull())
  52. content_.vSwitchId = contentNode["VSwitchId"].asString();
  53. if(!contentNode["Message"].isNull())
  54. content_.message = contentNode["Message"].asString();
  55. if(!contentNode["Mac"].isNull())
  56. content_.mac = contentNode["Mac"].asString();
  57. if(!contentNode["Type"].isNull())
  58. content_.type = contentNode["Type"].asString();
  59. if(!contentNode["Gateway"].isNull())
  60. content_.gateway = contentNode["Gateway"].asString();
  61. if(!contentNode["Mask"].isNull())
  62. content_.mask = contentNode["Mask"].asString();
  63. if(!contentNode["CreateTime"].isNull())
  64. content_.createTime = contentNode["CreateTime"].asString();
  65. if(!contentNode["GmtModified"].isNull())
  66. content_.gmtModified = contentNode["GmtModified"].asString();
  67. if(!contentNode["Description"].isNull())
  68. content_.description = contentNode["Description"].asString();
  69. auto allPrivateIpAddressesNode = contentNode["PrivateIpAddresses"]["PrivateIpAddress"];
  70. for (auto contentNodePrivateIpAddressesPrivateIpAddress : allPrivateIpAddressesNode)
  71. {
  72. Content::PrivateIpAddress privateIpAddressObject;
  73. if(!contentNodePrivateIpAddressesPrivateIpAddress["ElasticNetworkInterfaceId"].isNull())
  74. privateIpAddressObject.elasticNetworkInterfaceId = contentNodePrivateIpAddressesPrivateIpAddress["ElasticNetworkInterfaceId"].asString();
  75. if(!contentNodePrivateIpAddressesPrivateIpAddress["RegionId"].isNull())
  76. privateIpAddressObject.regionId = contentNodePrivateIpAddressesPrivateIpAddress["RegionId"].asString();
  77. if(!contentNodePrivateIpAddressesPrivateIpAddress["GmtCreate"].isNull())
  78. privateIpAddressObject.gmtCreate = contentNodePrivateIpAddressesPrivateIpAddress["GmtCreate"].asString();
  79. if(!contentNodePrivateIpAddressesPrivateIpAddress["GmtModified"].isNull())
  80. privateIpAddressObject.gmtModified = contentNodePrivateIpAddressesPrivateIpAddress["GmtModified"].asString();
  81. if(!contentNodePrivateIpAddressesPrivateIpAddress["IpName"].isNull())
  82. privateIpAddressObject.ipName = contentNodePrivateIpAddressesPrivateIpAddress["IpName"].asString();
  83. if(!contentNodePrivateIpAddressesPrivateIpAddress["PrivateIpAddress"].isNull())
  84. privateIpAddressObject.privateIpAddress = contentNodePrivateIpAddressesPrivateIpAddress["PrivateIpAddress"].asString();
  85. if(!contentNodePrivateIpAddressesPrivateIpAddress["Status"].isNull())
  86. privateIpAddressObject.status = contentNodePrivateIpAddressesPrivateIpAddress["Status"].asString();
  87. if(!contentNodePrivateIpAddressesPrivateIpAddress["Description"].isNull())
  88. privateIpAddressObject.description = contentNodePrivateIpAddressesPrivateIpAddress["Description"].asString();
  89. if(!contentNodePrivateIpAddressesPrivateIpAddress["Message"].isNull())
  90. privateIpAddressObject.message = contentNodePrivateIpAddressesPrivateIpAddress["Message"].asString();
  91. content_.privateIpAddresses.push_back(privateIpAddressObject);
  92. }
  93. if(!value["Code"].isNull())
  94. code_ = std::stoi(value["Code"].asString());
  95. if(!value["Message"].isNull())
  96. message_ = value["Message"].asString();
  97. }
  98. std::string GetElasticNetworkInterfaceResult::getMessage()const
  99. {
  100. return message_;
  101. }
  102. GetElasticNetworkInterfaceResult::Content GetElasticNetworkInterfaceResult::getContent()const
  103. {
  104. return content_;
  105. }
  106. int GetElasticNetworkInterfaceResult::getCode()const
  107. {
  108. return code_;
  109. }