ListVswitchResult.cc 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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/emr/model/ListVswitchResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Emr;
  19. using namespace AlibabaCloud::Emr::Model;
  20. ListVswitchResult::ListVswitchResult() :
  21. ServiceResult()
  22. {}
  23. ListVswitchResult::ListVswitchResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListVswitchResult::~ListVswitchResult()
  29. {}
  30. void ListVswitchResult::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 allVswitchListNode = value["VswitchList"]["Vswitch"];
  37. for (auto valueVswitchListVswitch : allVswitchListNode)
  38. {
  39. Vswitch vswitchListObject;
  40. if(!valueVswitchListVswitch["VSwitchId"].isNull())
  41. vswitchListObject.vSwitchId = valueVswitchListVswitch["VSwitchId"].asString();
  42. if(!valueVswitchListVswitch["VpcId"].isNull())
  43. vswitchListObject.vpcId = valueVswitchListVswitch["VpcId"].asString();
  44. if(!valueVswitchListVswitch["Status"].isNull())
  45. vswitchListObject.status = valueVswitchListVswitch["Status"].asString();
  46. if(!valueVswitchListVswitch["CidrBlock"].isNull())
  47. vswitchListObject.cidrBlock = valueVswitchListVswitch["CidrBlock"].asString();
  48. if(!valueVswitchListVswitch["ZoneId"].isNull())
  49. vswitchListObject.zoneId = valueVswitchListVswitch["ZoneId"].asString();
  50. if(!valueVswitchListVswitch["AvailableIpAddressCount"].isNull())
  51. vswitchListObject.availableIpAddressCount = valueVswitchListVswitch["AvailableIpAddressCount"].asString();
  52. if(!valueVswitchListVswitch["Description"].isNull())
  53. vswitchListObject.description = valueVswitchListVswitch["Description"].asString();
  54. if(!valueVswitchListVswitch["VSwitchName"].isNull())
  55. vswitchListObject.vSwitchName = valueVswitchListVswitch["VSwitchName"].asString();
  56. if(!valueVswitchListVswitch["CreationTime"].isNull())
  57. vswitchListObject.creationTime = valueVswitchListVswitch["CreationTime"].asString();
  58. if(!valueVswitchListVswitch["IsDefault"].isNull())
  59. vswitchListObject.isDefault = valueVswitchListVswitch["IsDefault"].asString() == "true";
  60. if(!valueVswitchListVswitch["ResourceGroupId"].isNull())
  61. vswitchListObject.resourceGroupId = valueVswitchListVswitch["ResourceGroupId"].asString();
  62. vswitchList_.push_back(vswitchListObject);
  63. }
  64. }
  65. std::vector<ListVswitchResult::Vswitch> ListVswitchResult::getVswitchList()const
  66. {
  67. return vswitchList_;
  68. }