Skip to main content

stormchaser_model/
connections.rs

1//! Storage backend and artifact registry models.
2
3use crate::id::{ArtifactId, ConnectionId, RunId, StepInstanceId};
4use serde::{Deserialize, Serialize};
5use serde_json::Value;
6use utoipa::ToSchema;
7
8/// Supported connection types for storage, databases, APIs, and VCS.
9#[derive(Debug, Serialize, Deserialize, Clone, sqlx::Type, PartialEq, Eq, ToSchema)]
10#[sqlx(type_name = "connection_type", rename_all = "snake_case")]
11#[serde(rename_all = "snake_case")]
12pub enum ConnectionType {
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    /// PostgreSQL database.
24    Postgres,
25    /// MySQL database.
26    Mysql,
27    /// Generic HTTP API.
28    HttpApi,
29    /// Git Repository.
30    Git,
31}
32
33/// Represents a configured connection instance.
34#[derive(Debug, Serialize, Deserialize, Clone, sqlx::FromRow, ToSchema)]
35pub struct Connection {
36    /// Unique identifier for the connection.
37    pub id: ConnectionId,
38    /// Logical name of the connection.
39    pub name: String,
40    /// Optional description of the connection's purpose.
41    pub description: Option<String>,
42    /// The type of connection.
43    pub connection_type: ConnectionType,
44    /// JSON configuration specific to the connection type.
45    pub config: Value,
46    /// Encrypted credentials (e.g. passwords, tokens).
47    pub encrypted_credentials: Option<String>,
48    /// Optional AWS role ARN to assume via STS (primarily for S3).
49    pub aws_assume_role_arn: Option<String>,
50    /// Whether this connection is the default Stormchaser File System (SFS).
51    pub is_default_sfs: bool,
52    /// Optional custom CA certificate for mTLS.
53    pub ca_cert: Option<String>,
54    /// Optional client certificate for mTLS.
55    pub client_cert: Option<String>,
56    /// Optional client private key for mTLS.
57    pub client_key: Option<String>,
58    /// Timestamp when the connection was registered.
59    pub created_at: chrono::DateTime<chrono::Utc>,
60    /// Timestamp when the connection configuration was last updated.
61    pub updated_at: chrono::DateTime<chrono::Utc>,
62}
63
64/// Registry of workflow artifacts stored in connections.
65#[derive(Debug, Serialize, Deserialize, Clone, sqlx::FromRow, ToSchema)]
66pub struct ArtifactRegistry {
67    /// Unique identifier for the artifact record.
68    pub id: ArtifactId,
69    /// Associated workflow run ID.
70    pub run_id: RunId,
71    /// Associated step instance ID that produced the artifact.
72    pub step_instance_id: StepInstanceId,
73    /// Logical name of the artifact.
74    pub artifact_name: String,
75    /// Identifier of the connection where the artifact is located.
76    pub connection_id: ConnectionId,
77    /// Path or locator within the connection.
78    pub remote_path: String,
79    /// Additional metadata about the artifact.
80    pub metadata: Value,
81    /// Timestamp when the artifact was registered.
82    pub created_at: chrono::DateTime<chrono::Utc>,
83}