swarmhive_api_types/
storage.rs1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use utoipa::ToSchema;
4use uuid::Uuid;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
8#[serde(rename_all = "lowercase")]
9pub enum UrlMode {
10 Public,
12 Signed,
14}
15
16#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ToSchema)]
18pub struct StorageBackendView {
19 pub id: Uuid,
20 pub name: String,
21 pub kind: String,
22 pub active: bool,
23 pub endpoint: String,
24 pub bucket: String,
25 pub region: String,
26 pub access_key_id: String,
27 pub secret_set: bool,
28 pub force_path_style: bool,
29 pub prefix: Option<String>,
30 pub public_base_url: Option<String>,
31 pub url_mode: UrlMode,
32 pub signed_url_ttl_secs: i64,
33 pub supports_sha256_checksum: bool,
34 pub connectivity_status: Option<serde_json::Value>,
35 pub created_at: DateTime<Utc>,
36 pub updated_at: DateTime<Utc>,
37}
38
39fn default_ttl_secs() -> i64 {
40 600
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
44pub struct CreateStorageBackendRequest {
45 pub name: String,
46 pub endpoint: String,
47 pub bucket: String,
48 pub region: String,
49 pub access_key_id: String,
50 pub access_key_secret: String,
51 #[serde(default)]
52 pub force_path_style: bool,
53 #[serde(default)]
54 pub prefix: Option<String>,
55 #[serde(default)]
56 pub public_base_url: Option<String>,
57 pub url_mode: UrlMode,
58 #[serde(default = "default_ttl_secs")]
59 pub signed_url_ttl_secs: i64,
60}
61
62#[derive(Debug, Clone, Default, Serialize, Deserialize, ToSchema)]
64pub struct UpdateStorageBackendRequest {
65 #[serde(default)]
66 pub name: Option<String>,
67 #[serde(default)]
68 pub endpoint: Option<String>,
69 #[serde(default)]
70 pub bucket: Option<String>,
71 #[serde(default)]
72 pub region: Option<String>,
73 #[serde(default)]
74 pub access_key_id: Option<String>,
75 #[serde(default)]
76 pub access_key_secret: Option<String>,
77 #[serde(default)]
78 pub force_path_style: Option<bool>,
79 #[serde(default)]
80 pub prefix: Option<String>,
81 #[serde(default)]
82 pub public_base_url: Option<String>,
83 #[serde(default)]
84 pub url_mode: Option<UrlMode>,
85 #[serde(default)]
86 pub signed_url_ttl_secs: Option<i64>,
87}
88
89#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
91pub struct StorageTestResult {
92 pub ok: bool,
93 pub supports_sha256_checksum: bool,
94 pub detail: String,
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
100pub struct CorsConfigRequest {
101 pub allowed_origins: Vec<String>,
102}
103
104#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
107pub struct CorsConfigResult {
108 pub ok: bool,
109 pub detail: String,
110}