Skip to main content

stormchaser_model/
storage.rs

1//! Storage backend and artifact registry models.
2
3use serde::{Deserialize, Serialize};
4use serde_json::Value;
5use uuid::Uuid;
6
7/// Supported storage backend types for artifacts and engine data.
8#[derive(Debug, Serialize, Deserialize, Clone, sqlx::Type, PartialEq, Eq)]
9#[sqlx(type_name = "backend_type", rename_all = "snake_case")]
10#[serde(rename_all = "snake_case")]
11pub enum BackendType {
12    /// Amazon S3 or compatible storage.
13    S3,
14    /// OCI-compliant registry.
15    Oci,
16    /// JFrog Artifactory.
17    Jfrog,
18    /// Google Cloud Storage.
19    Gcs,
20    /// Azure Blob Storage.
21    Azure,
22}
23
24/// Represents a configured storage backend instance.
25#[derive(Debug, Serialize, Deserialize, Clone, sqlx::FromRow)]
26pub struct StorageBackend {
27    /// Unique identifier for the storage backend.
28    pub id: Uuid,
29    /// Logical name of the backend.
30    pub name: String,
31    /// Optional description of the backend's purpose.
32    pub description: Option<String>,
33    /// The type of storage backend.
34    pub backend_type: BackendType,
35    /// JSON configuration specific to the backend type.
36    pub config: Value,
37    /// Whether this backend is the default Stormchaser File System (SFS).
38    pub is_default_sfs: bool,
39    /// Optional custom CA certificate for mTLS.
40    pub ca_cert: Option<String>,
41    /// Optional client certificate for mTLS.
42    pub client_cert: Option<String>,
43    /// Optional client private key for mTLS.
44    pub client_key: Option<String>,
45    /// Timestamp when the backend was registered.
46    pub created_at: chrono::DateTime<chrono::Utc>,
47    /// Timestamp when the backend configuration was last updated.
48    pub updated_at: chrono::DateTime<chrono::Utc>,
49}
50
51/// Registry of workflow artifacts stored in backends.
52#[derive(Debug, Serialize, Deserialize, Clone, sqlx::FromRow)]
53pub struct ArtifactRegistry {
54    /// Unique identifier for the artifact record.
55    pub id: Uuid,
56    /// Associated workflow run ID.
57    pub run_id: Uuid,
58    /// Associated step instance ID that produced the artifact.
59    pub step_instance_id: Uuid,
60    /// Logical name of the artifact.
61    pub artifact_name: String,
62    /// Identifier of the storage backend where the artifact is located.
63    pub backend_id: Uuid,
64    /// Path or locator within the storage backend.
65    pub remote_path: String,
66    /// Additional metadata about the artifact.
67    pub metadata: Value,
68    /// Timestamp when the artifact was registered.
69    pub created_at: chrono::DateTime<chrono::Utc>,
70}