1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
#![allow(clippy::exhaustive_structs)]
#[derive(Copy, Clone, Debug, ruma_common::serde::Incoming, serde::Serialize)]
pub struct OtherThing<'t> {
pub some: &'t str,
pub t: &'t [u8],
}
mod empty_response {
use ruma_common::{api::ruma_api, RoomAliasId, RoomId};
ruma_api! {
metadata: {
description: "Add an alias to a room.",
method: PUT,
name: "create_alias",
unstable_path: "/_matrix/client/r0/directory/room/:room_alias",
rate_limited: false,
authentication: AccessToken,
}
request: {
/// The room alias to set.
#[ruma_api(path)]
pub room_alias: &'a RoomAliasId,
/// The room ID to set.
pub room_id: &'a RoomId,
}
response: {}
}
}
mod nested_types {
use ruma_common::{api::ruma_api, RoomAliasId};
ruma_api! {
metadata: {
description: "Add an alias to a room.",
method: PUT,
name: "create_alias",
unstable_path: "/_matrix/client/r0/directory/room",
rate_limited: false,
authentication: AccessToken,
}
request: {
/// The room alias to set.
pub room_alias: &'a [Option<&'a RoomAliasId>],
/// The room ID to set.
pub room_id: &'b [Option<Option<&'a ruma_common::DeviceId>>],
}
response: {}
}
}
mod full_request_response {
use ruma_common::api::ruma_api;
use super::{IncomingOtherThing, OtherThing};
ruma_api! {
metadata: {
description: "Does something.",
method: POST,
name: "no_fields",
unstable_path: "/_matrix/my/endpoint/:thing",
rate_limited: false,
authentication: None,
}
request: {
#[ruma_api(query)]
pub abc: &'a str,
#[ruma_api(path)]
pub thing: &'a str,
#[ruma_api(header = CONTENT_TYPE)]
pub stuff: &'a str,
pub more: OtherThing<'t>,
}
response: {
#[ruma_api(body)]
pub thing: Vec<String>,
#[ruma_api(header = CONTENT_TYPE)]
pub stuff: String,
}
}
}
mod full_request_response_with_query_map {
use ruma_common::api::ruma_api;
ruma_api! {
metadata: {
description: "Does something.",
method: GET,
name: "no_fields",
unstable_path: "/_matrix/my/endpoint/:thing",
rate_limited: false,
authentication: None,
}
request: {
#[ruma_api(query_map)]
// pub abc: &'a [(&'a str, &'a str)], // TODO handle this use case
pub abc: Vec<(String, String)>,
#[ruma_api(path)]
pub thing: &'a str,
#[ruma_api(header = CONTENT_TYPE)]
pub stuff: &'a str,
}
response: {
#[ruma_api(body)]
pub thing: String,
#[ruma_api(header = CONTENT_TYPE)]
pub stuff: String,
}
}
}
mod query_fields {
use ruma_common::api::ruma_api;
ruma_api! {
metadata: {
description: "Get the list of rooms in this homeserver's public directory.",
method: GET,
name: "get_public_rooms",
unstable_path: "/_matrix/client/r0/publicRooms",
rate_limited: false,
authentication: None,
}
request: {
/// Limit for the number of results to return.
#[serde(skip_serializing_if = "Option::is_none")]
#[ruma_api(query)]
pub limit: Option<usize>,
/// Pagination token from a previous request.
#[serde(skip_serializing_if = "Option::is_none")]
#[ruma_api(query)]
pub since: Option<&'a str>,
/// The server to fetch the public room lists from.
///
/// `None` means the server this request is sent to.
#[serde(skip_serializing_if = "Option::is_none")]
#[ruma_api(query)]
pub server: Option<&'a str>,
}
response: {}
}
}
|