hotdata 0.1.2

Powerful data platform API for datasets, queries, and analytics.
Documentation
/*
 * Hotdata API
 *
 * Powerful data platform API for datasets, queries, and analytics.
 *
 * The version of the OpenAPI document: 1.0.0
 * Contact: developers@hotdata.dev
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// CreateConnectionRequest : Request body for POST /connections
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CreateConnectionRequest {
    /// Connection configuration object. Fields vary by source type (host, port, database, etc.).
    #[serde(rename = "config")]
    pub config: std::collections::HashMap<String, serde_json::Value>,
    #[serde(rename = "name")]
    pub name: String,
    /// Optional reference to a secret by ID (e.g., \"secr_abc123\"). If provided, this secret will be used for authentication. Mutually exclusive with `secret_name`.
    #[serde(
        rename = "secret_id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub secret_id: Option<Option<String>>,
    /// Optional reference to a secret by name. If provided, this secret will be used for authentication. Mutually exclusive with `secret_id`.
    #[serde(
        rename = "secret_name",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub secret_name: Option<Option<String>>,
    /// If true, skip automatic schema discovery after registering the connection. The connection will be created but no tables will be discovered. You can run discovery later via the refresh endpoint.
    #[serde(rename = "skip_discovery", skip_serializing_if = "Option::is_none")]
    pub skip_discovery: Option<bool>,
    #[serde(rename = "source_type")]
    pub source_type: String,
    /// Physical storage backend for tables created under this connection. `\"parquet\"` (default) uses the versioned parquet cache. `\"ducklake\"` stores data in a DuckLake catalog in the shared metadata DB configured via `ducklake.metadata_pg_url`; accepted for any source type and requires that pool to be configured.
    #[serde(
        rename = "storage_backend",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub storage_backend: Option<Option<String>>,
}

impl CreateConnectionRequest {
    /// Request body for POST /connections
    pub fn new(
        config: std::collections::HashMap<String, serde_json::Value>,
        name: String,
        source_type: String,
    ) -> CreateConnectionRequest {
        CreateConnectionRequest {
            config,
            name,
            secret_id: None,
            secret_name: None,
            skip_discovery: None,
            source_type,
            storage_backend: None,
        }
    }
}