1 | /****************************************************************************** |
2 | * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN |
3 | */ |
4 | |
5 | #pragma once |
6 | |
7 | #include <Quotient/csapi/definitions/key_backup_data.h> |
8 | #include <Quotient/csapi/definitions/room_key_backup.h> |
9 | |
10 | #include <Quotient/jobs/basejob.h> |
11 | |
12 | namespace Quotient { |
13 | |
14 | /*! \brief Create a new backup. |
15 | * |
16 | * Creates a new backup. |
17 | */ |
18 | class QUOTIENT_API PostRoomKeysVersionJob : public BaseJob { |
19 | public: |
20 | /*! \brief Create a new backup. |
21 | * |
22 | * \param algorithm |
23 | * The algorithm used for storing backups. |
24 | * |
25 | * \param authData |
26 | * Algorithm-dependent data. See the documentation for the backup |
27 | * algorithms in [Server-side key |
28 | * backups](/client-server-api/#server-side-key-backups) for more |
29 | * information on the expected format of the data. |
30 | */ |
31 | explicit PostRoomKeysVersionJob(const QString& algorithm, |
32 | const QJsonObject& authData); |
33 | |
34 | // Result properties |
35 | |
36 | /// The backup version. This is an opaque string. |
37 | QString version() const { return loadFromJson<QString>(keyName: "version"_ls ); } |
38 | }; |
39 | |
40 | /*! \brief Get information about the latest backup version. |
41 | * |
42 | * Get information about the latest backup version. |
43 | */ |
44 | class QUOTIENT_API GetRoomKeysVersionCurrentJob : public BaseJob { |
45 | public: |
46 | /// Get information about the latest backup version. |
47 | explicit GetRoomKeysVersionCurrentJob(); |
48 | |
49 | /*! \brief Construct a URL without creating a full-fledged job object |
50 | * |
51 | * This function can be used when a URL for GetRoomKeysVersionCurrentJob |
52 | * is necessary but the job itself isn't. |
53 | */ |
54 | static QUrl makeRequestUrl(QUrl baseUrl); |
55 | |
56 | // Result properties |
57 | |
58 | /// The algorithm used for storing backups. |
59 | QString algorithm() const { return loadFromJson<QString>(keyName: "algorithm"_ls ); } |
60 | |
61 | /// Algorithm-dependent data. See the documentation for the backup |
62 | /// algorithms in [Server-side key |
63 | /// backups](/client-server-api/#server-side-key-backups) for more |
64 | /// information on the expected format of the data. |
65 | QJsonObject authData() const |
66 | { |
67 | return loadFromJson<QJsonObject>(keyName: "auth_data"_ls ); |
68 | } |
69 | |
70 | /// The number of keys stored in the backup. |
71 | int count() const { return loadFromJson<int>(keyName: "count"_ls ); } |
72 | |
73 | /// An opaque string representing stored keys in the backup. |
74 | /// Clients can compare it with the `etag` value they received |
75 | /// in the request of their last key storage request. If not |
76 | /// equal, another client has modified the backup. |
77 | QString etag() const { return loadFromJson<QString>(keyName: "etag"_ls ); } |
78 | |
79 | /// The backup version. |
80 | QString version() const { return loadFromJson<QString>(keyName: "version"_ls ); } |
81 | }; |
82 | |
83 | /*! \brief Get information about an existing backup. |
84 | * |
85 | * Get information about an existing backup. |
86 | */ |
87 | class QUOTIENT_API GetRoomKeysVersionJob : public BaseJob { |
88 | public: |
89 | /*! \brief Get information about an existing backup. |
90 | * |
91 | * \param version |
92 | * The backup version to get, as returned in the `version` parameter |
93 | * of the response in |
94 | * [`POST |
95 | * /_matrix/client/v3/room_keys/version`](/client-server-api/#post_matrixclientv3room_keysversion) |
96 | * or this endpoint. |
97 | */ |
98 | explicit GetRoomKeysVersionJob(const QString& version); |
99 | |
100 | /*! \brief Construct a URL without creating a full-fledged job object |
101 | * |
102 | * This function can be used when a URL for GetRoomKeysVersionJob |
103 | * is necessary but the job itself isn't. |
104 | */ |
105 | static QUrl makeRequestUrl(QUrl baseUrl, const QString& version); |
106 | |
107 | // Result properties |
108 | |
109 | /// The algorithm used for storing backups. |
110 | QString algorithm() const { return loadFromJson<QString>(keyName: "algorithm"_ls ); } |
111 | |
112 | /// Algorithm-dependent data. See the documentation for the backup |
113 | /// algorithms in [Server-side key |
114 | /// backups](/client-server-api/#server-side-key-backups) for more |
115 | /// information on the expected format of the data. |
116 | QJsonObject authData() const |
117 | { |
118 | return loadFromJson<QJsonObject>(keyName: "auth_data"_ls ); |
119 | } |
120 | |
121 | /// The number of keys stored in the backup. |
122 | int count() const { return loadFromJson<int>(keyName: "count"_ls ); } |
123 | |
124 | /// An opaque string representing stored keys in the backup. |
125 | /// Clients can compare it with the `etag` value they received |
126 | /// in the request of their last key storage request. If not |
127 | /// equal, another client has modified the backup. |
128 | QString etag() const { return loadFromJson<QString>(keyName: "etag"_ls ); } |
129 | |
130 | /// The backup version. |
131 | QString version() const { return loadFromJson<QString>(keyName: "version"_ls ); } |
132 | }; |
133 | |
134 | /*! \brief Update information about an existing backup. |
135 | * |
136 | * Update information about an existing backup. Only `auth_data` can be |
137 | * modified. |
138 | */ |
139 | class QUOTIENT_API PutRoomKeysVersionJob : public BaseJob { |
140 | public: |
141 | /*! \brief Update information about an existing backup. |
142 | * |
143 | * \param version |
144 | * The backup version to update, as returned in the `version` |
145 | * parameter in the response of |
146 | * [`POST |
147 | * /_matrix/client/v3/room_keys/version`](/client-server-api/#post_matrixclientv3room_keysversion) |
148 | * or [`GET |
149 | * /_matrix/client/v3/room_keys/version/{version}`](/client-server-api/#get_matrixclientv3room_keysversionversion). |
150 | * |
151 | * \param algorithm |
152 | * The algorithm used for storing backups. Must be the same as |
153 | * the algorithm currently used by the backup. |
154 | * |
155 | * \param authData |
156 | * Algorithm-dependent data. See the documentation for the backup |
157 | * algorithms in [Server-side key |
158 | * backups](/client-server-api/#server-side-key-backups) for more |
159 | * information on the expected format of the data. |
160 | */ |
161 | explicit PutRoomKeysVersionJob(const QString& version, |
162 | const QString& algorithm, |
163 | const QJsonObject& authData); |
164 | }; |
165 | |
166 | /*! \brief Delete an existing key backup. |
167 | * |
168 | * Delete an existing key backup. Both the information about the backup, |
169 | * as well as all key data related to the backup will be deleted. |
170 | */ |
171 | class QUOTIENT_API DeleteRoomKeysVersionJob : public BaseJob { |
172 | public: |
173 | /*! \brief Delete an existing key backup. |
174 | * |
175 | * \param version |
176 | * The backup version to delete, as returned in the `version` |
177 | * parameter in the response of |
178 | * [`POST |
179 | * /_matrix/client/v3/room_keys/version`](/client-server-api/#post_matrixclientv3room_keysversion) |
180 | * or [`GET |
181 | * /_matrix/client/v3/room_keys/version/{version}`](/client-server-api/#get_matrixclientv3room_keysversionversion). |
182 | */ |
183 | explicit DeleteRoomKeysVersionJob(const QString& version); |
184 | |
185 | /*! \brief Construct a URL without creating a full-fledged job object |
186 | * |
187 | * This function can be used when a URL for DeleteRoomKeysVersionJob |
188 | * is necessary but the job itself isn't. |
189 | */ |
190 | static QUrl makeRequestUrl(QUrl baseUrl, const QString& version); |
191 | }; |
192 | |
193 | /*! \brief Store a key in the backup. |
194 | * |
195 | * Store a key in the backup. |
196 | */ |
197 | class QUOTIENT_API PutRoomKeyBySessionIdJob : public BaseJob { |
198 | public: |
199 | /*! \brief Store a key in the backup. |
200 | * |
201 | * \param roomId |
202 | * The ID of the room that the key is for. |
203 | * |
204 | * \param sessionId |
205 | * The ID of the megolm session that the key is for. |
206 | * |
207 | * \param version |
208 | * The backup in which to store the key. Must be the current backup. |
209 | * |
210 | * \param data |
211 | * The key data. |
212 | */ |
213 | explicit PutRoomKeyBySessionIdJob(const QString& roomId, |
214 | const QString& sessionId, |
215 | const QString& version, |
216 | const KeyBackupData& data); |
217 | |
218 | // Result properties |
219 | |
220 | /// The new etag value representing stored keys in the backup. |
221 | /// See `GET /room_keys/version/{version}` for more details. |
222 | QString etag() const { return loadFromJson<QString>(keyName: "etag"_ls ); } |
223 | |
224 | /// The number of keys stored in the backup |
225 | int count() const { return loadFromJson<int>(keyName: "count"_ls ); } |
226 | }; |
227 | |
228 | /*! \brief Retrieve a key from the backup. |
229 | * |
230 | * Retrieve a key from the backup. |
231 | */ |
232 | class QUOTIENT_API GetRoomKeyBySessionIdJob : public BaseJob { |
233 | public: |
234 | /*! \brief Retrieve a key from the backup. |
235 | * |
236 | * \param roomId |
237 | * The ID of the room that the requested key is for. |
238 | * |
239 | * \param sessionId |
240 | * The ID of the megolm session whose key is requested. |
241 | * |
242 | * \param version |
243 | * The backup from which to retrieve the key. |
244 | */ |
245 | explicit GetRoomKeyBySessionIdJob(const QString& roomId, |
246 | const QString& sessionId, |
247 | const QString& version); |
248 | |
249 | /*! \brief Construct a URL without creating a full-fledged job object |
250 | * |
251 | * This function can be used when a URL for GetRoomKeyBySessionIdJob |
252 | * is necessary but the job itself isn't. |
253 | */ |
254 | static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, |
255 | const QString& sessionId, const QString& version); |
256 | |
257 | // Result properties |
258 | |
259 | /// The key data |
260 | KeyBackupData data() const { return fromJson<KeyBackupData>(json: jsonData()); } |
261 | }; |
262 | |
263 | /*! \brief Delete a key from the backup. |
264 | * |
265 | * Delete a key from the backup. |
266 | */ |
267 | class QUOTIENT_API DeleteRoomKeyBySessionIdJob : public BaseJob { |
268 | public: |
269 | /*! \brief Delete a key from the backup. |
270 | * |
271 | * \param roomId |
272 | * The ID of the room that the specified key is for. |
273 | * |
274 | * \param sessionId |
275 | * The ID of the megolm session whose key is to be deleted. |
276 | * |
277 | * \param version |
278 | * The backup from which to delete the key |
279 | */ |
280 | explicit DeleteRoomKeyBySessionIdJob(const QString& roomId, |
281 | const QString& sessionId, |
282 | const QString& version); |
283 | |
284 | /*! \brief Construct a URL without creating a full-fledged job object |
285 | * |
286 | * This function can be used when a URL for DeleteRoomKeyBySessionIdJob |
287 | * is necessary but the job itself isn't. |
288 | */ |
289 | static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, |
290 | const QString& sessionId, const QString& version); |
291 | |
292 | // Result properties |
293 | |
294 | /// The new etag value representing stored keys in the backup. |
295 | /// See `GET /room_keys/version/{version}` for more details. |
296 | QString etag() const { return loadFromJson<QString>(keyName: "etag"_ls ); } |
297 | |
298 | /// The number of keys stored in the backup |
299 | int count() const { return loadFromJson<int>(keyName: "count"_ls ); } |
300 | }; |
301 | |
302 | /*! \brief Store several keys in the backup for a given room. |
303 | * |
304 | * Store several keys in the backup for a given room. |
305 | */ |
306 | class QUOTIENT_API PutRoomKeysByRoomIdJob : public BaseJob { |
307 | public: |
308 | /*! \brief Store several keys in the backup for a given room. |
309 | * |
310 | * \param roomId |
311 | * The ID of the room that the keys are for. |
312 | * |
313 | * \param version |
314 | * The backup in which to store the keys. Must be the current backup. |
315 | * |
316 | * \param backupData |
317 | * The backup data |
318 | */ |
319 | explicit PutRoomKeysByRoomIdJob(const QString& roomId, |
320 | const QString& version, |
321 | const RoomKeyBackup& backupData); |
322 | |
323 | // Result properties |
324 | |
325 | /// The new etag value representing stored keys in the backup. |
326 | /// See `GET /room_keys/version/{version}` for more details. |
327 | QString etag() const { return loadFromJson<QString>(keyName: "etag"_ls ); } |
328 | |
329 | /// The number of keys stored in the backup |
330 | int count() const { return loadFromJson<int>(keyName: "count"_ls ); } |
331 | }; |
332 | |
333 | /*! \brief Retrieve the keys from the backup for a given room. |
334 | * |
335 | * Retrieve the keys from the backup for a given room. |
336 | */ |
337 | class QUOTIENT_API GetRoomKeysByRoomIdJob : public BaseJob { |
338 | public: |
339 | /*! \brief Retrieve the keys from the backup for a given room. |
340 | * |
341 | * \param roomId |
342 | * The ID of the room that the requested key is for. |
343 | * |
344 | * \param version |
345 | * The backup from which to retrieve the key. |
346 | */ |
347 | explicit GetRoomKeysByRoomIdJob(const QString& roomId, |
348 | const QString& version); |
349 | |
350 | /*! \brief Construct a URL without creating a full-fledged job object |
351 | * |
352 | * This function can be used when a URL for GetRoomKeysByRoomIdJob |
353 | * is necessary but the job itself isn't. |
354 | */ |
355 | static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, |
356 | const QString& version); |
357 | |
358 | // Result properties |
359 | |
360 | /// The key data. If no keys are found, then an object with an empty |
361 | /// `sessions` property will be returned (`{"sessions": {}}`). |
362 | RoomKeyBackup data() const { return fromJson<RoomKeyBackup>(json: jsonData()); } |
363 | }; |
364 | |
365 | /*! \brief Delete the keys from the backup for a given room. |
366 | * |
367 | * Delete the keys from the backup for a given room. |
368 | */ |
369 | class QUOTIENT_API DeleteRoomKeysByRoomIdJob : public BaseJob { |
370 | public: |
371 | /*! \brief Delete the keys from the backup for a given room. |
372 | * |
373 | * \param roomId |
374 | * The ID of the room that the specified key is for. |
375 | * |
376 | * \param version |
377 | * The backup from which to delete the key. |
378 | */ |
379 | explicit DeleteRoomKeysByRoomIdJob(const QString& roomId, |
380 | const QString& version); |
381 | |
382 | /*! \brief Construct a URL without creating a full-fledged job object |
383 | * |
384 | * This function can be used when a URL for DeleteRoomKeysByRoomIdJob |
385 | * is necessary but the job itself isn't. |
386 | */ |
387 | static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, |
388 | const QString& version); |
389 | |
390 | // Result properties |
391 | |
392 | /// The new etag value representing stored keys in the backup. |
393 | /// See `GET /room_keys/version/{version}` for more details. |
394 | QString etag() const { return loadFromJson<QString>(keyName: "etag"_ls ); } |
395 | |
396 | /// The number of keys stored in the backup |
397 | int count() const { return loadFromJson<int>(keyName: "count"_ls ); } |
398 | }; |
399 | |
400 | /*! \brief Store several keys in the backup. |
401 | * |
402 | * Store several keys in the backup. |
403 | */ |
404 | class QUOTIENT_API PutRoomKeysJob : public BaseJob { |
405 | public: |
406 | /*! \brief Store several keys in the backup. |
407 | * |
408 | * \param version |
409 | * The backup in which to store the keys. Must be the current backup. |
410 | * |
411 | * \param rooms |
412 | * A map of room IDs to room key backup data. |
413 | */ |
414 | explicit PutRoomKeysJob(const QString& version, |
415 | const QHash<QString, RoomKeyBackup>& rooms); |
416 | |
417 | // Result properties |
418 | |
419 | /// The new etag value representing stored keys in the backup. |
420 | /// See `GET /room_keys/version/{version}` for more details. |
421 | QString etag() const { return loadFromJson<QString>(keyName: "etag"_ls ); } |
422 | |
423 | /// The number of keys stored in the backup |
424 | int count() const { return loadFromJson<int>(keyName: "count"_ls ); } |
425 | }; |
426 | |
427 | /*! \brief Retrieve the keys from the backup. |
428 | * |
429 | * Retrieve the keys from the backup. |
430 | */ |
431 | class QUOTIENT_API GetRoomKeysJob : public BaseJob { |
432 | public: |
433 | /*! \brief Retrieve the keys from the backup. |
434 | * |
435 | * \param version |
436 | * The backup from which to retrieve the keys. |
437 | */ |
438 | explicit GetRoomKeysJob(const QString& version); |
439 | |
440 | /*! \brief Construct a URL without creating a full-fledged job object |
441 | * |
442 | * This function can be used when a URL for GetRoomKeysJob |
443 | * is necessary but the job itself isn't. |
444 | */ |
445 | static QUrl makeRequestUrl(QUrl baseUrl, const QString& version); |
446 | |
447 | // Result properties |
448 | |
449 | /// A map of room IDs to room key backup data. |
450 | QHash<QString, RoomKeyBackup> rooms() const |
451 | { |
452 | return loadFromJson<QHash<QString, RoomKeyBackup>>(keyName: "rooms"_ls ); |
453 | } |
454 | }; |
455 | |
456 | /*! \brief Delete the keys from the backup. |
457 | * |
458 | * Delete the keys from the backup. |
459 | */ |
460 | class QUOTIENT_API DeleteRoomKeysJob : public BaseJob { |
461 | public: |
462 | /*! \brief Delete the keys from the backup. |
463 | * |
464 | * \param version |
465 | * The backup from which to delete the key |
466 | */ |
467 | explicit DeleteRoomKeysJob(const QString& version); |
468 | |
469 | /*! \brief Construct a URL without creating a full-fledged job object |
470 | * |
471 | * This function can be used when a URL for DeleteRoomKeysJob |
472 | * is necessary but the job itself isn't. |
473 | */ |
474 | static QUrl makeRequestUrl(QUrl baseUrl, const QString& version); |
475 | |
476 | // Result properties |
477 | |
478 | /// The new etag value representing stored keys in the backup. |
479 | /// See `GET /room_keys/version/{version}` for more details. |
480 | QString etag() const { return loadFromJson<QString>(keyName: "etag"_ls ); } |
481 | |
482 | /// The number of keys stored in the backup |
483 | int count() const { return loadFromJson<int>(keyName: "count"_ls ); } |
484 | }; |
485 | |
486 | } // namespace Quotient |
487 | |