GetInstanceResult.cc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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/foas/model/GetInstanceResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Foas;
  19. using namespace AlibabaCloud::Foas::Model;
  20. GetInstanceResult::GetInstanceResult() :
  21. ServiceResult()
  22. {}
  23. GetInstanceResult::GetInstanceResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. GetInstanceResult::~GetInstanceResult()
  29. {}
  30. void GetInstanceResult::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 instanceNode = value["Instance"];
  37. if(!instanceNode["Id"].isNull())
  38. instance_.id = std::stol(instanceNode["Id"].asString());
  39. if(!instanceNode["ProjectName"].isNull())
  40. instance_.projectName = instanceNode["ProjectName"].asString();
  41. if(!instanceNode["JobName"].isNull())
  42. instance_.jobName = instanceNode["JobName"].asString();
  43. if(!instanceNode["ActualState"].isNull())
  44. instance_.actualState = instanceNode["ActualState"].asString();
  45. if(!instanceNode["ExpectState"].isNull())
  46. instance_.expectState = instanceNode["ExpectState"].asString();
  47. if(!instanceNode["JobType"].isNull())
  48. instance_.jobType = instanceNode["JobType"].asString();
  49. if(!instanceNode["ApiType"].isNull())
  50. instance_.apiType = instanceNode["ApiType"].asString();
  51. if(!instanceNode["Code"].isNull())
  52. instance_.code = instanceNode["Code"].asString();
  53. if(!instanceNode["Properties"].isNull())
  54. instance_.properties = instanceNode["Properties"].asString();
  55. if(!instanceNode["Packages"].isNull())
  56. instance_.packages = instanceNode["Packages"].asString();
  57. if(!instanceNode["Starter"].isNull())
  58. instance_.starter = instanceNode["Starter"].asString();
  59. if(!instanceNode["StartTime"].isNull())
  60. instance_.startTime = std::stol(instanceNode["StartTime"].asString());
  61. if(!instanceNode["LastErrorTime"].isNull())
  62. instance_.lastErrorTime = std::stol(instanceNode["LastErrorTime"].asString());
  63. if(!instanceNode["LastErrorMessage"].isNull())
  64. instance_.lastErrorMessage = instanceNode["LastErrorMessage"].asString();
  65. if(!instanceNode["LastOperator"].isNull())
  66. instance_.lastOperator = instanceNode["LastOperator"].asString();
  67. if(!instanceNode["LastOperateTime"].isNull())
  68. instance_.lastOperateTime = std::stol(instanceNode["LastOperateTime"].asString());
  69. if(!instanceNode["PlanJson"].isNull())
  70. instance_.planJson = instanceNode["PlanJson"].asString();
  71. if(!instanceNode["EngineVersion"].isNull())
  72. instance_.engineVersion = instanceNode["EngineVersion"].asString();
  73. if(!instanceNode["EngineJobHandler"].isNull())
  74. instance_.engineJobHandler = instanceNode["EngineJobHandler"].asString();
  75. if(!instanceNode["InputDelay"].isNull())
  76. instance_.inputDelay = std::stol(instanceNode["InputDelay"].asString());
  77. if(!instanceNode["ClusterId"].isNull())
  78. instance_.clusterId = instanceNode["ClusterId"].asString();
  79. if(!instanceNode["QueueName"].isNull())
  80. instance_.queueName = instanceNode["QueueName"].asString();
  81. if(!instanceNode["EndTime"].isNull())
  82. instance_.endTime = std::stol(instanceNode["EndTime"].asString());
  83. if(!instanceNode["AutoScaleParams"].isNull())
  84. instance_.autoScaleParams = instanceNode["AutoScaleParams"].asString();
  85. if(!instanceNode["Priority"].isNull())
  86. instance_.priority = std::stoi(instanceNode["Priority"].asString());
  87. }
  88. GetInstanceResult::Instance GetInstanceResult::getInstance()const
  89. {
  90. return instance_;
  91. }