/*
* 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};
/// CreateDatabaseResponse : Response body for POST /databases
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CreateDatabaseResponse {
/// Whether this call brought the database into existence. Only `false` when `if_not_exists` found a database already carrying the requested name, in which case nothing was created and the existing one is returned. The response status says the same thing — `201` against `200` — but generated clients often surface only the body, so it is stated here as well. Always sent. It is declared optional so that a client built against a newer version of this API still accepts a response from a deployment that predates the field. Absent therefore means \"this deployment cannot say\", which is not the same as `false` — test for the two values explicitly rather than for truthiness.
#[serde(
rename = "created",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub created: Option<Option<bool>>,
/// Name the database's default catalog answers to inside its query scope (`default` unless overridden at create time).
#[serde(rename = "default_catalog")]
pub default_catalog: String,
/// Internal id of the connection that backs this database's `default` catalog. Workspace-level connection endpoints (list, get, health, delete, cache purge) refuse to act on this id — it is exposed only for the managed-tables load endpoint (`POST /v1/connections/{id}/schemas/{s}/tables/{t}/loads`) so callers can load data into tables declared at database-create time. Addressing it directly in SQL is not the recommended path — use `default` inside an `X-Database-Id` scope instead.
#[serde(rename = "default_connection_id")]
pub default_connection_id: String,
/// Schema that unqualified table names resolve to inside this database's query scope. `main` unless the database declares a single schema or a `default_schema` was set at create time.
#[serde(rename = "default_schema")]
pub default_schema: String,
/// When this database expires.
#[serde(
rename = "expires_at",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub expires_at: Option<Option<String>>,
#[serde(
rename = "forked_from",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub forked_from: Option<Option<Box<models::ForkedFromInfo>>>,
#[serde(rename = "id")]
pub id: String,
#[serde(
rename = "name",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub name: Option<Option<String>>,
}
impl CreateDatabaseResponse {
/// Response body for POST /databases
pub fn new(
default_catalog: String,
default_connection_id: String,
default_schema: String,
id: String,
) -> CreateDatabaseResponse {
CreateDatabaseResponse {
created: None,
default_catalog,
default_connection_id,
default_schema,
expires_at: None,
forked_from: None,
id,
name: None,
}
}
}