GetJobResult.cc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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/GetJobResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Foas;
  19. using namespace AlibabaCloud::Foas::Model;
  20. GetJobResult::GetJobResult() :
  21. ServiceResult()
  22. {}
  23. GetJobResult::GetJobResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. GetJobResult::~GetJobResult()
  29. {}
  30. void GetJobResult::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 jobNode = value["Job"];
  37. if(!jobNode["JobName"].isNull())
  38. job_.jobName = jobNode["JobName"].asString();
  39. if(!jobNode["ProjectName"].isNull())
  40. job_.projectName = jobNode["ProjectName"].asString();
  41. if(!jobNode["JobType"].isNull())
  42. job_.jobType = jobNode["JobType"].asString();
  43. if(!jobNode["ApiType"].isNull())
  44. job_.apiType = jobNode["ApiType"].asString();
  45. if(!jobNode["Code"].isNull())
  46. job_.code = jobNode["Code"].asString();
  47. if(!jobNode["PlanJson"].isNull())
  48. job_.planJson = jobNode["PlanJson"].asString();
  49. if(!jobNode["Properties"].isNull())
  50. job_.properties = jobNode["Properties"].asString();
  51. if(!jobNode["Packages"].isNull())
  52. job_.packages = jobNode["Packages"].asString();
  53. if(!jobNode["IsCommitted"].isNull())
  54. job_.isCommitted = jobNode["IsCommitted"].asString() == "true";
  55. if(!jobNode["Creator"].isNull())
  56. job_.creator = jobNode["Creator"].asString();
  57. if(!jobNode["CreateTime"].isNull())
  58. job_.createTime = std::stol(jobNode["CreateTime"].asString());
  59. if(!jobNode["Modifier"].isNull())
  60. job_.modifier = jobNode["Modifier"].asString();
  61. if(!jobNode["ModifyTime"].isNull())
  62. job_.modifyTime = std::stol(jobNode["ModifyTime"].asString());
  63. if(!jobNode["Description"].isNull())
  64. job_.description = jobNode["Description"].asString();
  65. if(!jobNode["EngineVersion"].isNull())
  66. job_.engineVersion = jobNode["EngineVersion"].asString();
  67. if(!jobNode["ClusterId"].isNull())
  68. job_.clusterId = jobNode["ClusterId"].asString();
  69. if(!jobNode["QueueName"].isNull())
  70. job_.queueName = jobNode["QueueName"].asString();
  71. if(!jobNode["FolderId"].isNull())
  72. job_.folderId = std::stol(jobNode["FolderId"].asString());
  73. if(!jobNode["JobId"].isNull())
  74. job_.jobId = jobNode["JobId"].asString();
  75. if(!jobNode["FileId"].isNull())
  76. job_.fileId = jobNode["FileId"].asString();
  77. }
  78. GetJobResult::Job GetJobResult::getJob()const
  79. {
  80. return job_;
  81. }