DescribeKeyPairsResult.cc 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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/ecs/model/DescribeKeyPairsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Ecs;
  19. using namespace AlibabaCloud::Ecs::Model;
  20. DescribeKeyPairsResult::DescribeKeyPairsResult() :
  21. ServiceResult()
  22. {}
  23. DescribeKeyPairsResult::DescribeKeyPairsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeKeyPairsResult::~DescribeKeyPairsResult()
  29. {}
  30. void DescribeKeyPairsResult::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 allKeyPairsNode = value["KeyPairs"]["KeyPair"];
  37. for (auto valueKeyPairsKeyPair : allKeyPairsNode)
  38. {
  39. KeyPair keyPairsObject;
  40. if(!valueKeyPairsKeyPair["KeyPairName"].isNull())
  41. keyPairsObject.keyPairName = valueKeyPairsKeyPair["KeyPairName"].asString();
  42. if(!valueKeyPairsKeyPair["KeyPairFingerPrint"].isNull())
  43. keyPairsObject.keyPairFingerPrint = valueKeyPairsKeyPair["KeyPairFingerPrint"].asString();
  44. if(!valueKeyPairsKeyPair["CreationTime"].isNull())
  45. keyPairsObject.creationTime = valueKeyPairsKeyPair["CreationTime"].asString();
  46. if(!valueKeyPairsKeyPair["ResourceGroupId"].isNull())
  47. keyPairsObject.resourceGroupId = valueKeyPairsKeyPair["ResourceGroupId"].asString();
  48. auto allTagsNode = valueKeyPairsKeyPair["Tags"]["Tag"];
  49. for (auto valueKeyPairsKeyPairTagsTag : allTagsNode)
  50. {
  51. KeyPair::Tag tagsObject;
  52. if(!valueKeyPairsKeyPairTagsTag["TagKey"].isNull())
  53. tagsObject.tagKey = valueKeyPairsKeyPairTagsTag["TagKey"].asString();
  54. if(!valueKeyPairsKeyPairTagsTag["TagValue"].isNull())
  55. tagsObject.tagValue = valueKeyPairsKeyPairTagsTag["TagValue"].asString();
  56. keyPairsObject.tags.push_back(tagsObject);
  57. }
  58. keyPairs_.push_back(keyPairsObject);
  59. }
  60. if(!value["TotalCount"].isNull())
  61. totalCount_ = std::stoi(value["TotalCount"].asString());
  62. if(!value["PageNumber"].isNull())
  63. pageNumber_ = std::stoi(value["PageNumber"].asString());
  64. if(!value["PageSize"].isNull())
  65. pageSize_ = std::stoi(value["PageSize"].asString());
  66. }
  67. int DescribeKeyPairsResult::getTotalCount()const
  68. {
  69. return totalCount_;
  70. }
  71. int DescribeKeyPairsResult::getPageSize()const
  72. {
  73. return pageSize_;
  74. }
  75. int DescribeKeyPairsResult::getPageNumber()const
  76. {
  77. return pageNumber_;
  78. }
  79. std::vector<DescribeKeyPairsResult::KeyPair> DescribeKeyPairsResult::getKeyPairs()const
  80. {
  81. return keyPairs_;
  82. }