ruma_client_api/backup/create_backup_version.rs
1//! `POST /_matrix/client/*/room_keys/version`
2//!
3//! Create a new backup version.
4
5pub mod v3 {
6 //! `/v3/` ([spec])
7 //!
8 //! [spec]: https://spec.matrix.org/v1.18/client-server-api/#post_matrixclientv3room_keysversion
9
10 use ruma_common::{
11 api::{auth_scheme::AccessToken, request, response},
12 metadata,
13 serde::Raw,
14 };
15
16 use crate::backup::BackupAlgorithm;
17
18 metadata! {
19 method: POST,
20 rate_limited: true,
21 authentication: AccessToken,
22 history: {
23 unstable => "/_matrix/client/unstable/room_keys/version",
24 1.1 => "/_matrix/client/v3/room_keys/version",
25 }
26 }
27
28 /// Request type for the `create_backup_version` endpoint.
29 #[request]
30 pub struct Request {
31 /// The algorithm used for storing backups.
32 #[ruma_api(body)]
33 pub algorithm: Raw<BackupAlgorithm>,
34 }
35
36 /// Response type for the `create_backup_version` endpoint.
37 #[response]
38 pub struct Response {
39 /// The backup version.
40 pub version: String,
41 }
42
43 impl Request {
44 /// Creates a new `Request` with the given backup algorithm.
45 pub fn new(algorithm: Raw<BackupAlgorithm>) -> Self {
46 Self { algorithm }
47 }
48 }
49
50 impl Response {
51 /// Creates a new `Response` with the given version.
52 pub fn new(version: String) -> Self {
53 Self { version }
54 }
55 }
56}