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 
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
Definition: admin.hpp:67
std::optional< std::string > userId() const
The Matrix user ID of the user.
Definition: admin.cpp:80
bool success() const
Definition: admin.cpp:70
JobResponse(Response r)
Definition: admin.cpp:67
immer::map< std::string, DeviceInfo > devices() const
Each key is an identifier for one of the user's devices.
Definition: admin.cpp:91
Gets information about a particular user.
Definition: admin.hpp:20
static BaseJob::Body buildBody(std::string userId)
Definition: admin.cpp:21
static constexpr auto needsAuth()
Definition: admin.hpp:86
static BaseJob::Query buildQuery()
Definition: admin.cpp:13
GetWhoIsJob(std::string serverUrl, std::string _accessToken, std::string userId)
Gets information about a particular user.
Definition: admin.cpp:33
GetWhoIsJob withData(JsonWrap j) &&
Definition: admin.cpp:53
Definition: basejob.hpp:91
Definition: basejob.hpp:77
::Kazv::Body Body
Definition: basejob.hpp:100
Definition: jsonwrap.hpp:23
Definition: location.hpp:10
Definition: location.hpp:10
void addToJsonIfNeeded(json &j, std::string name, T &&arg)
Definition: types.hpp:80
nlohmann::json json
Definition: jsonwrap.hpp:20
Definition: location.hpp:27
Gets information about a particular user.
Definition: admin.hpp:30
std::optional< std::int_fast64_t > lastSeen
Unix timestamp that the session was last active.
Definition: admin.hpp:34
std::optional< std::string > ip
Most recently seen IP address of the session.
Definition: admin.hpp:32
std::optional< std::string > userAgent
User agent string last seen in the session.
Definition: admin.hpp:36
Gets information about a particular user.
Definition: admin.hpp:58
immer::array< SessionInfo > sessions
A user's sessions (i.e. what they did with an access token from one login).
Definition: admin.hpp:60
Gets information about a particular user.
Definition: admin.hpp:46
immer::array< ConnectionInfo > connections
Information particular connections in the session.
Definition: admin.hpp:48
Definition: basejob.hpp:50
static void from_json(const json &jo, GetWhoIsJob::ConnectionInfo &result)
Definition: admin.hpp:140
static void to_json(json &jo, const GetWhoIsJob::ConnectionInfo &pod)
Definition: admin.hpp:127
static void to_json(json &jo, const GetWhoIsJob::DeviceInfo &pod)
Definition: admin.hpp:181
static void from_json(const json &jo, GetWhoIsJob::DeviceInfo &result)
Definition: admin.hpp:190
static void to_json(json &jo, const GetWhoIsJob::SessionInfo &pod)
Definition: admin.hpp:159
static void from_json(const json &jo, GetWhoIsJob::SessionInfo &result)
Definition: admin.hpp:168