GetUserDeviceResult.cc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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/csas/model/GetUserDeviceResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Csas;
  19. using namespace AlibabaCloud::Csas::Model;
  20. GetUserDeviceResult::GetUserDeviceResult() :
  21. ServiceResult()
  22. {}
  23. GetUserDeviceResult::GetUserDeviceResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. GetUserDeviceResult::~GetUserDeviceResult()
  29. {}
  30. void GetUserDeviceResult::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 deviceNode = value["Device"];
  37. if(!deviceNode["DeviceTag"].isNull())
  38. device_.deviceTag = deviceNode["DeviceTag"].asString();
  39. if(!deviceNode["DeviceType"].isNull())
  40. device_.deviceType = deviceNode["DeviceType"].asString();
  41. if(!deviceNode["DeviceModel"].isNull())
  42. device_.deviceModel = deviceNode["DeviceModel"].asString();
  43. if(!deviceNode["DeviceVersion"].isNull())
  44. device_.deviceVersion = deviceNode["DeviceVersion"].asString();
  45. if(!deviceNode["Hostname"].isNull())
  46. device_.hostname = deviceNode["Hostname"].asString();
  47. if(!deviceNode["Username"].isNull())
  48. device_.username = deviceNode["Username"].asString();
  49. if(!deviceNode["SaseUserId"].isNull())
  50. device_.saseUserId = deviceNode["SaseUserId"].asString();
  51. if(!deviceNode["Department"].isNull())
  52. device_.department = deviceNode["Department"].asString();
  53. if(!deviceNode["InnerIP"].isNull())
  54. device_.innerIP = deviceNode["InnerIP"].asString();
  55. if(!deviceNode["SrcIP"].isNull())
  56. device_.srcIP = deviceNode["SrcIP"].asString();
  57. if(!deviceNode["Memory"].isNull())
  58. device_.memory = deviceNode["Memory"].asString();
  59. if(!deviceNode["CPU"].isNull())
  60. device_.cPU = deviceNode["CPU"].asString();
  61. if(!deviceNode["Disk"].isNull())
  62. device_.disk = deviceNode["Disk"].asString();
  63. if(!deviceNode["Mac"].isNull())
  64. device_.mac = deviceNode["Mac"].asString();
  65. if(!deviceNode["AppVersion"].isNull())
  66. device_.appVersion = deviceNode["AppVersion"].asString();
  67. if(!deviceNode["DeviceBelong"].isNull())
  68. device_.deviceBelong = deviceNode["DeviceBelong"].asString();
  69. if(!deviceNode["SharingStatus"].isNull())
  70. device_.sharingStatus = deviceNode["SharingStatus"].asString() == "true";
  71. if(!deviceNode["DeviceStatus"].isNull())
  72. device_.deviceStatus = deviceNode["DeviceStatus"].asString();
  73. if(!deviceNode["AppStatus"].isNull())
  74. device_.appStatus = deviceNode["AppStatus"].asString();
  75. if(!deviceNode["PaStatus"].isNull())
  76. device_.paStatus = deviceNode["PaStatus"].asString();
  77. if(!deviceNode["IaStatus"].isNull())
  78. device_.iaStatus = deviceNode["IaStatus"].asString();
  79. if(!deviceNode["DlpStatus"].isNull())
  80. device_.dlpStatus = deviceNode["DlpStatus"].asString();
  81. if(!deviceNode["NacStatus"].isNull())
  82. device_.nacStatus = deviceNode["NacStatus"].asString();
  83. if(!deviceNode["CreateTime"].isNull())
  84. device_.createTime = deviceNode["CreateTime"].asString();
  85. if(!deviceNode["UpdateTime"].isNull())
  86. device_.updateTime = deviceNode["UpdateTime"].asString();
  87. auto allHistoryUsersNode = deviceNode["HistoryUsers"]["historyUsersItem"];
  88. for (auto deviceNodeHistoryUsershistoryUsersItem : allHistoryUsersNode)
  89. {
  90. Device::HistoryUsersItem historyUsersItemObject;
  91. if(!deviceNodeHistoryUsershistoryUsersItem["Username"].isNull())
  92. historyUsersItemObject.username = deviceNodeHistoryUsershistoryUsersItem["Username"].asString();
  93. if(!deviceNodeHistoryUsershistoryUsersItem["SaseUserId"].isNull())
  94. historyUsersItemObject.saseUserId = deviceNodeHistoryUsershistoryUsersItem["SaseUserId"].asString();
  95. device_.historyUsers.push_back(historyUsersItemObject);
  96. }
  97. }
  98. GetUserDeviceResult::Device GetUserDeviceResult::getDevice()const
  99. {
  100. return device_;
  101. }