FindCredentialsListResult.cc 3.4 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/csb/model/FindCredentialsListResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::CSB;
  19. using namespace AlibabaCloud::CSB::Model;
  20. FindCredentialsListResult::FindCredentialsListResult() :
  21. ServiceResult()
  22. {}
  23. FindCredentialsListResult::FindCredentialsListResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. FindCredentialsListResult::~FindCredentialsListResult()
  29. {}
  30. void FindCredentialsListResult::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 dataNode = value["Data"];
  37. if(!dataNode["CurrentPage"].isNull())
  38. data_.currentPage = std::stoi(dataNode["CurrentPage"].asString());
  39. if(!dataNode["PageNumber"].isNull())
  40. data_.pageNumber = std::stoi(dataNode["PageNumber"].asString());
  41. auto allCredentialListNode = dataNode["CredentialList"]["Credential"];
  42. for (auto dataNodeCredentialListCredential : allCredentialListNode)
  43. {
  44. Data::Credential credentialObject;
  45. if(!dataNodeCredentialListCredential["GmtCreate"].isNull())
  46. credentialObject.gmtCreate = std::stol(dataNodeCredentialListCredential["GmtCreate"].asString());
  47. if(!dataNodeCredentialListCredential["Id"].isNull())
  48. credentialObject.id = std::stol(dataNodeCredentialListCredential["Id"].asString());
  49. if(!dataNodeCredentialListCredential["Name"].isNull())
  50. credentialObject.name = dataNodeCredentialListCredential["Name"].asString();
  51. if(!dataNodeCredentialListCredential["OwnerAttr"].isNull())
  52. credentialObject.ownerAttr = dataNodeCredentialListCredential["OwnerAttr"].asString();
  53. if(!dataNodeCredentialListCredential["UserId"].isNull())
  54. credentialObject.userId = dataNodeCredentialListCredential["UserId"].asString();
  55. auto currentCredentialNode = value["CurrentCredential"];
  56. if(!currentCredentialNode["AccessKey"].isNull())
  57. credentialObject.currentCredential.accessKey = currentCredentialNode["AccessKey"].asString();
  58. if(!currentCredentialNode["SecretKey"].isNull())
  59. credentialObject.currentCredential.secretKey = currentCredentialNode["SecretKey"].asString();
  60. auto newCredentialNode = value["NewCredential"];
  61. if(!newCredentialNode["AccessKey"].isNull())
  62. credentialObject.newCredential.accessKey = newCredentialNode["AccessKey"].asString();
  63. if(!newCredentialNode["SecretKey"].isNull())
  64. credentialObject.newCredential.secretKey = newCredentialNode["SecretKey"].asString();
  65. data_.credentialList.push_back(credentialObject);
  66. }
  67. if(!value["Code"].isNull())
  68. code_ = std::stoi(value["Code"].asString());
  69. if(!value["Message"].isNull())
  70. message_ = value["Message"].asString();
  71. }
  72. std::string FindCredentialsListResult::getMessage()const
  73. {
  74. return message_;
  75. }
  76. FindCredentialsListResult::Data FindCredentialsListResult::getData()const
  77. {
  78. return data_;
  79. }
  80. int FindCredentialsListResult::getCode()const
  81. {
  82. return code_;
  83. }