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