summaryrefslogtreecommitdiff
path: root/server/src/api_model.rs
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2025-02-09 23:56:38 +0100
committerJoel Klinghed <the_jk@spawned.biz>2025-02-09 23:56:38 +0100
commitbf025b4977543a371df9dbdddfe9cc2f02f2a8d0 (patch)
treefc8937a3b5f3311ff7b8209aec3961668ac83d8c /server/src/api_model.rs
parentbd74717e10fb36e19893c15941876b2383b94714 (diff)
First integration test
Sets up a whole slew of docker instances, all started from clean slate for test.
Diffstat (limited to 'server/src/api_model.rs')
-rw-r--r--server/src/api_model.rs240
1 files changed, 0 insertions, 240 deletions
diff --git a/server/src/api_model.rs b/server/src/api_model.rs
deleted file mode 100644
index dbb42d8..0000000
--- a/server/src/api_model.rs
+++ /dev/null
@@ -1,240 +0,0 @@
-use rocket::serde::{Deserialize, Serialize};
-use utoipa::ToSchema;
-
-#[derive(Copy, Clone, Deserialize, Serialize, ToSchema)]
-pub enum ReviewState {
- Draft,
- Open,
- Dropped,
- Closed,
-}
-
-impl TryFrom<u8> for ReviewState {
- type Error = &'static str;
-
- fn try_from(value: u8) -> Result<Self, Self::Error> {
- match value {
- 0 => Ok(ReviewState::Draft),
- 1 => Ok(ReviewState::Open),
- 2 => Ok(ReviewState::Dropped),
- 3 => Ok(ReviewState::Closed),
- _ => Err("Invalid review state"),
- }
- }
-}
-
-#[derive(Copy, Clone, Deserialize, Serialize, ToSchema)]
-pub enum Rewrite {
- Disabled,
- History,
- Rebase,
-}
-
-impl TryFrom<u8> for Rewrite {
- type Error = &'static str;
-
- fn try_from(value: u8) -> Result<Self, Self::Error> {
- match value {
- 0 => Ok(Rewrite::Disabled),
- 1 => Ok(Rewrite::History),
- 2 => Ok(Rewrite::Rebase),
- _ => Err("Invalid review state"),
- }
- }
-}
-
-#[derive(Copy, Clone, Debug, Deserialize, PartialEq, Serialize, ToSchema)]
-pub enum UserReviewRole {
- Reviewer,
- Watcher,
- None,
-}
-
-#[derive(Debug, Deserialize, Serialize, PartialEq, ToSchema)]
-pub struct User {
- #[schema(example = "jsmith")]
- pub id: String,
- #[schema(example = "John Smith")]
- pub name: String,
- #[schema(example = true)]
- pub active: bool,
-}
-
-#[derive(Deserialize, Serialize, ToSchema)]
-pub struct Users {
- #[schema(example = 0u32)]
- pub offset: u32,
- #[schema(example = 10u32)]
- pub limit: u32,
- #[schema(example = 42u32)]
- pub total_count: u32,
- #[schema(example = true)]
- pub more: bool,
- pub users: Vec<User>,
-}
-
-#[derive(Serialize, ToSchema)]
-pub struct ReviewUserEntry {
- pub user: User,
- #[schema(example = UserReviewRole::Reviewer)]
- pub role: UserReviewRole,
-}
-
-#[derive(Serialize, ToSchema)]
-pub struct Review {
- #[schema(example = 1000u64)]
- pub id: u64,
- #[schema(example = "FAKE-512: Add more features")]
- pub title: String,
- #[schema(example = "We're adding more features because features are what we want.")]
- pub description: String,
- pub owner: User,
- pub users: Vec<ReviewUserEntry>,
- #[schema(example = ReviewState::Open)]
- pub state: ReviewState,
- #[schema(example = 37.5)]
- pub progress: f32,
- #[schema(example = "r/user/TASK-123456")]
- pub branch: String,
- #[schema(example = false)]
- pub archived: bool,
-}
-
-#[derive(Deserialize, Serialize, ToSchema)]
-pub struct ReviewEntry {
- #[schema(example = 1000u64)]
- pub id: u64,
- #[schema(example = "FAKE-512: Add more features")]
- pub title: String,
- pub owner: User,
- #[schema(example = ReviewState::Open)]
- pub state: ReviewState,
- #[schema(example = 37.5)]
- pub progress: f32,
- #[schema(example = "r/user/TASK-123456")]
- pub branch: String,
-}
-
-#[derive(Deserialize, Serialize, ToSchema)]
-pub struct Reviews {
- #[schema(example = 0u32)]
- pub offset: u32,
- #[schema(example = 10u32)]
- pub limit: u32,
- #[schema(example = 42u32)]
- pub total_count: u32,
- #[schema(example = true)]
- pub more: bool,
- pub reviews: Vec<ReviewEntry>,
-}
-
-#[derive(Debug, Deserialize, PartialEq, Serialize, ToSchema)]
-pub struct ProjectUserEntry {
- pub user: User,
- #[schema(example = UserReviewRole::Reviewer)]
- pub default_role: UserReviewRole,
- #[schema(example = false)]
- pub maintainer: bool,
-}
-
-#[derive(Deserialize, Serialize, ToSchema)]
-pub struct ProjectUserEntryData {
- #[schema(example = UserReviewRole::Reviewer)]
- pub default_role: Option<UserReviewRole>,
- #[schema(example = false)]
- pub maintainer: Option<bool>,
-}
-
-#[derive(Debug, Deserialize, PartialEq, Serialize, ToSchema)]
-pub struct Project {
- #[schema(example = "fake")]
- pub id: String,
- #[schema(example = "FAKE: Features All Kids Erase")]
- pub title: String,
- #[schema(example = "Example project")]
- pub description: String,
- #[schema(example = "ssh://git.example.org/srv/git/")]
- pub remote: String,
- #[schema(example = "main")]
- pub main_branch: String,
- pub users: Vec<ProjectUserEntry>,
-}
-
-#[derive(Deserialize, Serialize, ToSchema)]
-pub struct ProjectData<'r> {
- #[schema(example = "FAKE: Features All Kids Erase")]
- pub title: Option<&'r str>,
- #[schema(example = "Example project")]
- pub description: Option<&'r str>,
- #[schema(example = "ssh://git.example.org/srv/git/")]
- pub remote: Option<&'r str>,
- #[schema(example = "main")]
- pub main_branch: Option<&'r str>,
-}
-
-#[derive(Deserialize, Serialize, ToSchema)]
-pub struct ProjectEntry {
- #[schema(example = "fake")]
- pub id: String,
- #[schema(example = "FAKE: Features All Kids Erase")]
- pub title: String,
-}
-
-#[derive(Deserialize, Serialize, ToSchema)]
-pub struct Projects {
- #[schema(example = 0u32)]
- pub offset: u32,
- #[schema(example = 10u32)]
- pub limit: u32,
- #[schema(example = 1u32)]
- pub total_count: u32,
- #[schema(example = false)]
- pub more: bool,
- pub projects: Vec<ProjectEntry>,
-}
-
-#[derive(Deserialize, Serialize, ToSchema)]
-pub struct StatusResponse {
- pub ok: bool,
- #[serde(
- skip_serializing_if = "Option::is_none",
- // &'static str is problematic for serde, only used in tests anyway.
- skip_deserializing,
- )]
- pub error: Option<&'static str>,
-}
-
-#[derive(Debug, Deserialize, PartialEq, Serialize, ToSchema)]
-pub struct UserKey {
- #[schema(example = 1u64)]
- pub id: u64,
- #[schema(example = "ssh-rsa")]
- pub kind: String,
- #[schema(example = "AAAAfoobar==")]
- pub data: String,
- #[schema(example = "user@host 1970-01-01")]
- pub comment: String,
-}
-
-#[derive(Deserialize, Serialize, ToSchema)]
-pub struct UserKeyData<'r> {
- #[schema(example = "ssh-rsa")]
- pub kind: &'r str,
- #[schema(example = "AAAAfoobar==")]
- pub data: &'r str,
- #[schema(example = "user@host 1970-01-01")]
- pub comment: Option<&'r str>,
-}
-
-#[derive(Deserialize, Serialize, ToSchema)]
-pub struct UserKeys {
- #[schema(example = 0u32)]
- pub offset: u32,
- #[schema(example = 10u32)]
- pub limit: u32,
- #[schema(example = 2u32)]
- pub total_count: u32,
- #[schema(example = false)]
- pub more: bool,
- pub keys: Vec<UserKey>,
-}