OnsInstanceBaseInfoResult.cc 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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/ons/model/OnsInstanceBaseInfoResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Ons;
  19. using namespace AlibabaCloud::Ons::Model;
  20. OnsInstanceBaseInfoResult::OnsInstanceBaseInfoResult() :
  21. ServiceResult()
  22. {}
  23. OnsInstanceBaseInfoResult::OnsInstanceBaseInfoResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. OnsInstanceBaseInfoResult::~OnsInstanceBaseInfoResult()
  29. {}
  30. void OnsInstanceBaseInfoResult::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 instanceBaseInfoNode = value["InstanceBaseInfo"];
  37. if(!instanceBaseInfoNode["IndependentNaming"].isNull())
  38. instanceBaseInfo_.independentNaming = instanceBaseInfoNode["IndependentNaming"].asString() == "true";
  39. if(!instanceBaseInfoNode["MaxTps"].isNull())
  40. instanceBaseInfo_.maxTps = std::stol(instanceBaseInfoNode["MaxTps"].asString());
  41. if(!instanceBaseInfoNode["Remark"].isNull())
  42. instanceBaseInfo_.remark = instanceBaseInfoNode["Remark"].asString();
  43. if(!instanceBaseInfoNode["InstanceName"].isNull())
  44. instanceBaseInfo_.instanceName = instanceBaseInfoNode["InstanceName"].asString();
  45. if(!instanceBaseInfoNode["ReleaseTime"].isNull())
  46. instanceBaseInfo_.releaseTime = std::stol(instanceBaseInfoNode["ReleaseTime"].asString());
  47. if(!instanceBaseInfoNode["TopicCapacity"].isNull())
  48. instanceBaseInfo_.topicCapacity = std::stoi(instanceBaseInfoNode["TopicCapacity"].asString());
  49. if(!instanceBaseInfoNode["InstanceStatus"].isNull())
  50. instanceBaseInfo_.instanceStatus = std::stoi(instanceBaseInfoNode["InstanceStatus"].asString());
  51. if(!instanceBaseInfoNode["InstanceId"].isNull())
  52. instanceBaseInfo_.instanceId = instanceBaseInfoNode["InstanceId"].asString();
  53. if(!instanceBaseInfoNode["InstanceType"].isNull())
  54. instanceBaseInfo_.instanceType = std::stoi(instanceBaseInfoNode["InstanceType"].asString());
  55. if(!instanceBaseInfoNode["CreateTime"].isNull())
  56. instanceBaseInfo_.createTime = instanceBaseInfoNode["CreateTime"].asString();
  57. if(!instanceBaseInfoNode["spInstanceId"].isNull())
  58. instanceBaseInfo_.spInstanceId = instanceBaseInfoNode["spInstanceId"].asString();
  59. if(!instanceBaseInfoNode["spInstanceType"].isNull())
  60. instanceBaseInfo_.spInstanceType = std::stoi(instanceBaseInfoNode["spInstanceType"].asString());
  61. auto endpointsNode = instanceBaseInfoNode["Endpoints"];
  62. if(!endpointsNode["TcpEndpoint"].isNull())
  63. instanceBaseInfo_.endpoints.tcpEndpoint = endpointsNode["TcpEndpoint"].asString();
  64. if(!endpointsNode["TcpInternetEndpoint"].isNull())
  65. instanceBaseInfo_.endpoints.tcpInternetEndpoint = endpointsNode["TcpInternetEndpoint"].asString();
  66. if(!endpointsNode["HttpInternetEndpoint"].isNull())
  67. instanceBaseInfo_.endpoints.httpInternetEndpoint = endpointsNode["HttpInternetEndpoint"].asString();
  68. if(!endpointsNode["HttpInternalEndpoint"].isNull())
  69. instanceBaseInfo_.endpoints.httpInternalEndpoint = endpointsNode["HttpInternalEndpoint"].asString();
  70. if(!endpointsNode["HttpInternetSecureEndpoint"].isNull())
  71. instanceBaseInfo_.endpoints.httpInternetSecureEndpoint = endpointsNode["HttpInternetSecureEndpoint"].asString();
  72. if(!value["HelpUrl"].isNull())
  73. helpUrl_ = value["HelpUrl"].asString();
  74. }
  75. OnsInstanceBaseInfoResult::InstanceBaseInfo OnsInstanceBaseInfoResult::getInstanceBaseInfo()const
  76. {
  77. return instanceBaseInfo_;
  78. }
  79. std::string OnsInstanceBaseInfoResult::getHelpUrl()const
  80. {
  81. return helpUrl_;
  82. }