libkazv
admin.hpp
Go to the documentation of this file.
1 /******************************************************************************
2  * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
3  */
4 
5 #pragma once
6 
7 #include "basejob.hpp"
8 
9 
10 namespace Kazv::Api {
11 
20 class GetWhoIsJob : public BaseJob {
21 public:
22  // Inner data structures
23 
29  struct ConnectionInfo
30  {
32  std::optional<std::string> ip;
34  std::optional<std::int_fast64_t> lastSeen;
36  std::optional<std::string> userAgent;
37 
38  };
39 
45  struct SessionInfo
46  {
48  immer::array<ConnectionInfo> connections;
49 
50  };
51 
57  struct DeviceInfo
58  {
60  immer::array<SessionInfo> sessions;
61 
62  };
63 
64 
65 
66 class JobResponse : public Response
67 {
68 
69 public:
71  bool success() const;
72 
73  // Result properties
74 
75 
76 
77 
79 std::optional<std::string> userId() const;
80 
81 
83 immer::map<std::string, DeviceInfo> devices() const;
84 
85 };
86  static constexpr auto needsAuth() {
87  return true
88  ;
89  }
90 
91 
92 // Construction/destruction
93 
99  explicit GetWhoIsJob(std::string serverUrl
100  , std::string _accessToken
101  ,
102  std::string userId
103  );
104 
105 
106  static BaseJob::Query buildQuery(
107  );
108 
109  static BaseJob::Body buildBody(std::string userId);
110 
111 
112 
113 
114 
116  GetWhoIsJob withData(JsonWrap j) const &;
117  };
119  }
120  namespace nlohmann
121  {
122  using namespace Kazv;
123  using namespace Kazv::Api;
124  template<>
125  struct adl_serializer<GetWhoIsJob::ConnectionInfo> {
126 
127  static void to_json(json& jo, const GetWhoIsJob::ConnectionInfo &pod)
128  {
129  if (! jo.is_object()) { jo = json::object(); }
130 
131 
132 
133  addToJsonIfNeeded(jo, "ip"s, pod.ip);
134 
135  addToJsonIfNeeded(jo, "last_seen"s, pod.lastSeen);
136 
137  addToJsonIfNeeded(jo, "user_agent"s, pod.userAgent);
138  }
139 
140  static void from_json(const json &jo, GetWhoIsJob::ConnectionInfo& result)
141  {
142 
143  if (jo.contains("ip"s)) {
144  result.ip = jo.at("ip"s);
145  }
146  if (jo.contains("last_seen"s)) {
147  result.lastSeen = jo.at("last_seen"s);
148  }
149  if (jo.contains("user_agent"s)) {
150  result.userAgent = jo.at("user_agent"s);
151  }
152 
153  }
154 
155 };
156  template<>
157  struct adl_serializer<GetWhoIsJob::SessionInfo> {
158 
159  static void to_json(json& jo, const GetWhoIsJob::SessionInfo &pod)
160  {
161  if (! jo.is_object()) { jo = json::object(); }
162 
163 
164 
165  addToJsonIfNeeded(jo, "connections"s, pod.connections);
166  }
167 
168  static void from_json(const json &jo, GetWhoIsJob::SessionInfo& result)
169  {
170 
171  if (jo.contains("connections"s)) {
172  result.connections = jo.at("connections"s);
173  }
174 
175  }
176 
177 };
178  template<>
179  struct adl_serializer<GetWhoIsJob::DeviceInfo> {
180 
181  static void to_json(json& jo, const GetWhoIsJob::DeviceInfo &pod)
182  {
183  if (! jo.is_object()) { jo = json::object(); }
184 
185 
186 
187  addToJsonIfNeeded(jo, "sessions"s, pod.sessions);
188  }
189 
190  static void from_json(const json &jo, GetWhoIsJob::DeviceInfo& result)
191  {
192 
193  if (jo.contains("sessions"s)) {
194  result.sessions = jo.at("sessions"s);
195  }
196 
197  }
198 
199 };
200  }
201 
202  namespace Kazv::Api
203  {
204 
205 } // namespace Kazv::Api
nlohmann::adl_serializer< GetWhoIsJob::DeviceInfo >::to_json
static void to_json(json &jo, const GetWhoIsJob::DeviceInfo &pod)
Definition: admin.hpp:181
nlohmann::adl_serializer< GetWhoIsJob::DeviceInfo >::from_json
static void from_json(const json &jo, GetWhoIsJob::DeviceInfo &result)
Definition: admin.hpp:190
Kazv::Api::GetWhoIsJob::JobResponse::devices
immer::map< std::string, DeviceInfo > devices() const
Each key is an identifier for one of the user's devices.
Definition: admin.cpp:93
nlohmann::adl_serializer< GetWhoIsJob::ConnectionInfo >::to_json
static void to_json(json &jo, const GetWhoIsJob::ConnectionInfo &pod)
Definition: admin.hpp:127
Kazv::Api::GetWhoIsJob::needsAuth
static constexpr auto needsAuth()
Definition: admin.hpp:90
Kazv::Api::GetWhoIsJob::buildBody
static BaseJob::Body buildBody(std::string userId)
Definition: admin.cpp:23
nlohmann
Definition: location.hpp:26
Kazv::Api::GetWhoIsJob::SessionInfo
Gets information about a particular user.
Definition: admin.hpp:49
Kazv::Api::GetWhoIsJob::JobResponse::success
bool success() const
Definition: admin.cpp:72
Kazv::Api::GetWhoIsJob::JobResponse::JobResponse
JobResponse(Response r)
Definition: admin.cpp:69
Kazv
Definition: location.hpp:10
Kazv::BaseJob::Query
Definition: basejob.hpp:90
nlohmann::adl_serializer< GetWhoIsJob::ConnectionInfo >::from_json
static void from_json(const json &jo, GetWhoIsJob::ConnectionInfo &result)
Definition: admin.hpp:140
Kazv::Api::GetWhoIsJob::GetWhoIsJob
GetWhoIsJob(std::string serverUrl, std::string _accessToken, std::string userId)
Gets information about a particular user.
Definition: admin.cpp:35
Kazv::Api::GetWhoIsJob::JobResponse::userId
std::optional< std::string > userId() const
The Matrix user ID of the user.
Definition: admin.cpp:82
Kazv::Api::GetWhoIsJob::ConnectionInfo::ip
std::optional< std::string > ip
Most recently seen IP address of the session.
Definition: admin.hpp:38
Kazv::Api::GetWhoIsJob
Gets information about a particular user.
Definition: admin.hpp:22
Kazv::json
nlohmann::json json
Definition: jsonwrap.hpp:20
nlohmann::adl_serializer< GetWhoIsJob::SessionInfo >::from_json
static void from_json(const json &jo, GetWhoIsJob::SessionInfo &result)
Definition: admin.hpp:168
Kazv::Api
Definition: location.hpp:10
nlohmann::adl_serializer< GetWhoIsJob::SessionInfo >::to_json
static void to_json(json &jo, const GetWhoIsJob::SessionInfo &pod)
Definition: admin.hpp:159
Kazv::Api::GetWhoIsJob::withData
GetWhoIsJob withData(JsonWrap j) &&
Definition: admin.cpp:55
Kazv::addToJsonIfNeeded
void addToJsonIfNeeded(json &j, std::string name, T &&arg)
Definition: types.hpp:80
basejob.hpp
Kazv::Api::GetWhoIsJob::DeviceInfo
Gets information about a particular user.
Definition: admin.hpp:61
Kazv::JsonWrap
Definition: jsonwrap.hpp:22
Kazv::Api::GetWhoIsJob::ConnectionInfo
Gets information about a particular user.
Definition: admin.hpp:33
Kazv::Api::GetWhoIsJob::ConnectionInfo::userAgent
std::optional< std::string > userAgent
User agent string last seen in the session.
Definition: admin.hpp:42
Kazv::BaseJob::Body
::Kazv::Body Body
Definition: basejob.hpp:100
Kazv::Api::GetWhoIsJob::JobResponse
Definition: admin.hpp:70
Kazv::Api::GetWhoIsJob::DeviceInfo::sessions
immer::array< SessionInfo > sessions
A user's sessions (i.e. what they did with an access token from one login).
Definition: admin.hpp:64
Kazv::Api::GetWhoIsJob::ConnectionInfo::lastSeen
std::optional< std::int_fast64_t > lastSeen
Unix timestamp that the session was last active.
Definition: admin.hpp:40
Kazv::Api::GetWhoIsJob::buildQuery
static BaseJob::Query buildQuery()
Definition: admin.cpp:15
Kazv::Api::GetWhoIsJob::SessionInfo::connections
immer::array< ConnectionInfo > connections
Information particular connections in the session.
Definition: admin.hpp:52
Kazv::Response
Definition: basejob.hpp:50