Skip to main content

stormchaser_model/
storage.rs

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