commit 27f0a19d591f88ce4ae92490893a3622717cb0b5
parent 16f193248098bf77c62195352ad388d3e64d7244
Author: quantumish <freifeld.david@gmail.com>
Date: Thu, 22 Sep 2022 20:08:44 -0700
Add DELETE requests to API
Diffstat:
1 file changed, 47 insertions(+), 1 deletion(-)
diff --git a/scuttlebutt/src/main.rs b/scuttlebutt/src/main.rs
@@ -62,6 +62,16 @@ enum UserResponse {
BadRequest,
}
+#[derive(ApiResponse)]
+enum DeleteResponse {
+ /// The delete operation succeeded
+ #[oai(status = 200)]
+ Success,
+ /// Invalid ID
+ #[oai(status = 404)]
+ NotFound,
+}
+
#[OpenApi]
impl Api {
#[oai(path = "/user", method = "get")]
@@ -86,11 +96,23 @@ impl Api {
todo!()
}
+ #[oai(path = "/user", method = "delete")]
+ /// Deletes a user
+ async fn delete_user(&self, id: Query<i64>) -> DeleteResponse {
+ todo!()
+ }
+
#[oai(path = "/user/groups", method = "get")]
/// Gets all groups accessible to a user
async fn get_groups(&self, id: Query<i64>) -> Json<Vec<Group>> {
todo!()
}
+
+ #[oai(path = "/user/groups", method = "delete")]
+ /// Leaves a group accessible to the user
+ async fn leave_group(&self, uid: Query<i64>, gid: Query<i64>) -> Json<Vec<Group>> {
+ todo!()
+ }
#[oai(path = "/group", method = "get")]
/// Gets the group with the given ID
@@ -110,6 +132,12 @@ impl Api {
todo!()
}
+ #[oai(path = "/group", method = "delete")]
+ /// Deletes a user
+ async fn delete_group(&self, id: Query<i64>) -> DeleteResponse {
+ todo!()
+ }
+
#[oai(path = "/group/members", method = "get")]
/// Gets the members of the specified group
async fn get_group_members(&self, id: Query<i64>) -> Json<Vec<User>> {
@@ -122,6 +150,12 @@ impl Api {
todo!()
}
+ #[oai(path = "/group/members", method = "delete")]
+ /// Adds a member to an existing group
+ async fn remove_group_member(&self, gid: Query<i64>, uid: Query<i64>) -> Json<Vec<User>> {
+ todo!()
+ }
+
#[oai(path = "/group/channels", method = "get")]
/// Gets all channels in a group that are accessible to a user
async fn get_channels(&self, gid: Query<i64>, uid: Query<i64>) -> Json<Vec<Channel>> {
@@ -133,12 +167,18 @@ impl Api {
async fn make_channel(&self, gid: Query<i64>, name: Query<String>) -> Json<Channel> {
todo!()
}
-
+
#[oai(path = "/channel", method = "put")]
/// Updates the name of a channel
async fn update_channel(&self, id: Query<i64>, name: Query<String>) -> Json<Channel> {
todo!()
}
+
+ #[oai(path = "/channel", method = "delete")]
+ /// Deletes a channel
+ async fn delete_channel(&self, id: Query<i64>) -> DeleteResponse {
+ todo!()
+ }
#[oai(path = "/channel/members", method = "get")]
/// Gets the members that can access a channel
@@ -151,6 +191,12 @@ impl Api {
async fn add_channel_member(&self, cid: Query<i64>, uid: Query<i64>) -> Json<Channel> {
todo!()
}
+
+ #[oai(path = "/channel/members", method = "delete")]
+ /// Removes a member from a channel
+ async fn remove_channel_member(&self, cid: Query<i64>, uid: Query<i64>) -> DeleteResponse {
+ todo!()
+ }
}
#[tokio::main]