CreateNetworkAclResult.cc 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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/vpc/model/CreateNetworkAclResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Vpc;
  19. using namespace AlibabaCloud::Vpc::Model;
  20. CreateNetworkAclResult::CreateNetworkAclResult() :
  21. ServiceResult()
  22. {}
  23. CreateNetworkAclResult::CreateNetworkAclResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. CreateNetworkAclResult::~CreateNetworkAclResult()
  29. {}
  30. void CreateNetworkAclResult::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 networkAclAttributeNode = value["NetworkAclAttribute"];
  37. if(!networkAclAttributeNode["NetworkAclId"].isNull())
  38. networkAclAttribute_.networkAclId = networkAclAttributeNode["NetworkAclId"].asString();
  39. if(!networkAclAttributeNode["RegionId"].isNull())
  40. networkAclAttribute_.regionId = networkAclAttributeNode["RegionId"].asString();
  41. if(!networkAclAttributeNode["NetworkAclName"].isNull())
  42. networkAclAttribute_.networkAclName = networkAclAttributeNode["NetworkAclName"].asString();
  43. if(!networkAclAttributeNode["Description"].isNull())
  44. networkAclAttribute_.description = networkAclAttributeNode["Description"].asString();
  45. if(!networkAclAttributeNode["VpcId"].isNull())
  46. networkAclAttribute_.vpcId = networkAclAttributeNode["VpcId"].asString();
  47. if(!networkAclAttributeNode["CreationTime"].isNull())
  48. networkAclAttribute_.creationTime = networkAclAttributeNode["CreationTime"].asString();
  49. if(!networkAclAttributeNode["Status"].isNull())
  50. networkAclAttribute_.status = networkAclAttributeNode["Status"].asString();
  51. auto allIngressAclEntriesNode = networkAclAttributeNode["IngressAclEntries"]["IngressAclEntry"];
  52. for (auto networkAclAttributeNodeIngressAclEntriesIngressAclEntry : allIngressAclEntriesNode)
  53. {
  54. NetworkAclAttribute::IngressAclEntry ingressAclEntryObject;
  55. if(!networkAclAttributeNodeIngressAclEntriesIngressAclEntry["NetworkAclEntryId"].isNull())
  56. ingressAclEntryObject.networkAclEntryId = networkAclAttributeNodeIngressAclEntriesIngressAclEntry["NetworkAclEntryId"].asString();
  57. if(!networkAclAttributeNodeIngressAclEntriesIngressAclEntry["Policy"].isNull())
  58. ingressAclEntryObject.policy = networkAclAttributeNodeIngressAclEntriesIngressAclEntry["Policy"].asString();
  59. if(!networkAclAttributeNodeIngressAclEntriesIngressAclEntry["Protocol"].isNull())
  60. ingressAclEntryObject.protocol = networkAclAttributeNodeIngressAclEntriesIngressAclEntry["Protocol"].asString();
  61. if(!networkAclAttributeNodeIngressAclEntriesIngressAclEntry["SourceCidrIp"].isNull())
  62. ingressAclEntryObject.sourceCidrIp = networkAclAttributeNodeIngressAclEntriesIngressAclEntry["SourceCidrIp"].asString();
  63. if(!networkAclAttributeNodeIngressAclEntriesIngressAclEntry["Port"].isNull())
  64. ingressAclEntryObject.port = networkAclAttributeNodeIngressAclEntriesIngressAclEntry["Port"].asString();
  65. if(!networkAclAttributeNodeIngressAclEntriesIngressAclEntry["EntryType"].isNull())
  66. ingressAclEntryObject.entryType = networkAclAttributeNodeIngressAclEntriesIngressAclEntry["EntryType"].asString();
  67. if(!networkAclAttributeNodeIngressAclEntriesIngressAclEntry["NetworkAclEntryName"].isNull())
  68. ingressAclEntryObject.networkAclEntryName = networkAclAttributeNodeIngressAclEntriesIngressAclEntry["NetworkAclEntryName"].asString();
  69. if(!networkAclAttributeNodeIngressAclEntriesIngressAclEntry["Description"].isNull())
  70. ingressAclEntryObject.description = networkAclAttributeNodeIngressAclEntriesIngressAclEntry["Description"].asString();
  71. networkAclAttribute_.ingressAclEntries.push_back(ingressAclEntryObject);
  72. }
  73. auto allEgressAclEntriesNode = networkAclAttributeNode["EgressAclEntries"]["EgressAclEntry"];
  74. for (auto networkAclAttributeNodeEgressAclEntriesEgressAclEntry : allEgressAclEntriesNode)
  75. {
  76. NetworkAclAttribute::EgressAclEntry egressAclEntryObject;
  77. if(!networkAclAttributeNodeEgressAclEntriesEgressAclEntry["NetworkAclEntryId"].isNull())
  78. egressAclEntryObject.networkAclEntryId = networkAclAttributeNodeEgressAclEntriesEgressAclEntry["NetworkAclEntryId"].asString();
  79. if(!networkAclAttributeNodeEgressAclEntriesEgressAclEntry["Policy"].isNull())
  80. egressAclEntryObject.policy = networkAclAttributeNodeEgressAclEntriesEgressAclEntry["Policy"].asString();
  81. if(!networkAclAttributeNodeEgressAclEntriesEgressAclEntry["Protocol"].isNull())
  82. egressAclEntryObject.protocol = networkAclAttributeNodeEgressAclEntriesEgressAclEntry["Protocol"].asString();
  83. if(!networkAclAttributeNodeEgressAclEntriesEgressAclEntry["DestinationCidrIp"].isNull())
  84. egressAclEntryObject.destinationCidrIp = networkAclAttributeNodeEgressAclEntriesEgressAclEntry["DestinationCidrIp"].asString();
  85. if(!networkAclAttributeNodeEgressAclEntriesEgressAclEntry["Port"].isNull())
  86. egressAclEntryObject.port = networkAclAttributeNodeEgressAclEntriesEgressAclEntry["Port"].asString();
  87. if(!networkAclAttributeNodeEgressAclEntriesEgressAclEntry["EntryType"].isNull())
  88. egressAclEntryObject.entryType = networkAclAttributeNodeEgressAclEntriesEgressAclEntry["EntryType"].asString();
  89. if(!networkAclAttributeNodeEgressAclEntriesEgressAclEntry["Description"].isNull())
  90. egressAclEntryObject.description = networkAclAttributeNodeEgressAclEntriesEgressAclEntry["Description"].asString();
  91. if(!networkAclAttributeNodeEgressAclEntriesEgressAclEntry["NetworkAclEntryName"].isNull())
  92. egressAclEntryObject.networkAclEntryName = networkAclAttributeNodeEgressAclEntriesEgressAclEntry["NetworkAclEntryName"].asString();
  93. networkAclAttribute_.egressAclEntries.push_back(egressAclEntryObject);
  94. }
  95. auto allResourcesNode = networkAclAttributeNode["Resources"]["Resource"];
  96. for (auto networkAclAttributeNodeResourcesResource : allResourcesNode)
  97. {
  98. NetworkAclAttribute::Resource resourceObject;
  99. if(!networkAclAttributeNodeResourcesResource["ResourceId"].isNull())
  100. resourceObject.resourceId = networkAclAttributeNodeResourcesResource["ResourceId"].asString();
  101. if(!networkAclAttributeNodeResourcesResource["ResourceType"].isNull())
  102. resourceObject.resourceType = networkAclAttributeNodeResourcesResource["ResourceType"].asString();
  103. if(!networkAclAttributeNodeResourcesResource["Status"].isNull())
  104. resourceObject.status = networkAclAttributeNodeResourcesResource["Status"].asString();
  105. networkAclAttribute_.resources.push_back(resourceObject);
  106. }
  107. if(!value["NetworkAclId"].isNull())
  108. networkAclId_ = value["NetworkAclId"].asString();
  109. }
  110. std::string CreateNetworkAclResult::getNetworkAclId()const
  111. {
  112. return networkAclId_;
  113. }
  114. CreateNetworkAclResult::NetworkAclAttribute CreateNetworkAclResult::getNetworkAclAttribute()const
  115. {
  116. return networkAclAttribute_;
  117. }