/*
* Hotdata API
*
* Powerful data platform API for instant databases, 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};
/// CreateDatabaseRequest : Request body for POST /databases
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CreateDatabaseRequest {
/// Optional name the database's auto-created default catalog answers to inside its query scope. Must be a valid SQL identifier (`[a-z0-9_]`, not starting with a digit) and may not collide with the reserved catalog names `hotdata` or `information_schema`. Defaults to `default` when omitted, so `default.main.<table>` keeps working.
#[serde(
rename = "default_catalog",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub default_catalog: Option<Option<String>>,
/// Optional schema that unqualified table names resolve to inside this database's query scope. Must be a valid SQL identifier (`[a-z0-9_]`, not starting with a digit). When omitted, a database that declares exactly one schema adopts that schema as its default; otherwise unqualified names resolve to `main`. Fully-qualified names (`<catalog>.<schema>.<table>`) are unaffected, and a per-query `default_schema` still takes precedence.
#[serde(
rename = "default_schema",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub default_schema: Option<Option<String>>,
/// When this database expires. Accepts either an RFC 3339 timestamp (e.g. `\"2026-06-01T00:00:00Z\"`) or a relative duration suffixed with `h` (hours), `m` (minutes), or `d` (days) — for example `\"24h\"`, `\"48h\"`, or `\"7d\"`. Omitted (or empty) means the database never expires. Expiry is best-effort: the database will not be deleted before `expires_at`, but cleanup may run later than the exact timestamp.
#[serde(
rename = "expires_at",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub expires_at: Option<Option<String>>,
/// Return the database that already carries this `name` instead of creating a second one with it. Requires `name`; the comparison is case-insensitive for unaccented Latin letters and digits, and ignores surrounding whitespace, matching `GET /v1/databases/by-name`. A match responds `200` with the existing database rather than `201`, and is returned exactly as it stands: the rest of this request — `schemas`, `expires_at`, `default_catalog`, `default_schema` — is neither compared against it nor applied to it. Nothing is created, so this is safe to call on every start-up.
#[serde(rename = "if_not_exists", skip_serializing_if = "Option::is_none")]
pub if_not_exists: Option<bool>,
/// Optional free-form display label (for UIs/CLIs). When omitted, a label derived from the database's ID is assigned. Not unique. Not an identifier — databases are always addressed by `id`. Accepts the legacy `description` key as an alias so clients that predate the rename keep populating this field.
#[serde(
rename = "name",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub name: Option<Option<String>>,
/// Optional schemas/tables to declare on the database's auto-created default catalog. Tables declared here can be loaded via the standard managed-table load endpoint targeting `default_connection_id`. Omitted or empty means the default catalog starts empty.
#[serde(rename = "schemas", skip_serializing_if = "Option::is_none")]
pub schemas: Option<Vec<models::DatabaseDefaultSchemaDecl>>,
}
impl CreateDatabaseRequest {
/// Request body for POST /databases
pub fn new() -> CreateDatabaseRequest {
CreateDatabaseRequest {
default_catalog: None,
default_schema: None,
expires_at: None,
if_not_exists: None,
name: None,
schemas: None,
}
}
}