Skip to main content

swarmhive_api_types/
app.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use utoipa::ToSchema;
4use uuid::Uuid;
5
6use crate::platform::Platform;
7
8/// An application whose releases SwarmHive distributes. `slug` is unique within
9/// the org and immutable after creation (it appears in URLs and object keys).
10#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
11pub struct App {
12    pub id: Uuid,
13    pub org_id: Uuid,
14    pub slug: String,
15    pub display_name: String,
16    pub platforms: Vec<Platform>,
17    pub created_at: DateTime<Utc>,
18    pub updated_at: DateTime<Utc>,
19}
20
21#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
22pub struct CreateAppRequest {
23    pub slug: String,
24    pub display_name: String,
25    pub platforms: Vec<Platform>,
26}
27
28/// All fields optional — only the present ones are mutated. `slug` is absent on
29/// purpose: it is immutable. `default_channel` names the channel to mark
30/// default (the server unsets the previous default in the same transaction).
31#[derive(Debug, Clone, Default, Serialize, Deserialize, ToSchema)]
32pub struct UpdateAppRequest {
33    #[serde(default)]
34    pub display_name: Option<String>,
35    #[serde(default)]
36    pub platforms: Option<Vec<Platform>>,
37    #[serde(default)]
38    pub default_channel: Option<String>,
39}