RenewCredentialsResult.cc 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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/RenewCredentialsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::CSB;
  19. using namespace AlibabaCloud::CSB::Model;
  20. RenewCredentialsResult::RenewCredentialsResult() :
  21. ServiceResult()
  22. {}
  23. RenewCredentialsResult::RenewCredentialsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. RenewCredentialsResult::~RenewCredentialsResult()
  29. {}
  30. void RenewCredentialsResult::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. auto credentialsNode = dataNode["Credentials"];
  38. if(!credentialsNode["GmtCreate"].isNull())
  39. data_.credentials.gmtCreate = std::stol(credentialsNode["GmtCreate"].asString());
  40. if(!credentialsNode["Id"].isNull())
  41. data_.credentials.id = std::stol(credentialsNode["Id"].asString());
  42. if(!credentialsNode["Name"].isNull())
  43. data_.credentials.name = credentialsNode["Name"].asString();
  44. if(!credentialsNode["UserId"].isNull())
  45. data_.credentials.userId = credentialsNode["UserId"].asString();
  46. auto currentCredentialNode = credentialsNode["CurrentCredential"];
  47. if(!currentCredentialNode["AccessKey"].isNull())
  48. data_.credentials.currentCredential.accessKey = currentCredentialNode["AccessKey"].asString();
  49. if(!currentCredentialNode["SecretKey"].isNull())
  50. data_.credentials.currentCredential.secretKey = currentCredentialNode["SecretKey"].asString();
  51. auto newCredentialNode = credentialsNode["NewCredential"];
  52. if(!newCredentialNode["AccessKey"].isNull())
  53. data_.credentials.newCredential.accessKey = newCredentialNode["AccessKey"].asString();
  54. if(!newCredentialNode["SecretKey"].isNull())
  55. data_.credentials.newCredential.secretKey = newCredentialNode["SecretKey"].asString();
  56. if(!value["Code"].isNull())
  57. code_ = std::stoi(value["Code"].asString());
  58. if(!value["Message"].isNull())
  59. message_ = value["Message"].asString();
  60. }
  61. std::string RenewCredentialsResult::getMessage()const
  62. {
  63. return message_;
  64. }
  65. RenewCredentialsResult::Data RenewCredentialsResult::getData()const
  66. {
  67. return data_;
  68. }
  69. int RenewCredentialsResult::getCode()const
  70. {
  71. return code_;
  72. }