hotdata 0.8.1

Powerful data platform API for datasets, queries, and analytics.
Documentation
/*
 * Hotdata API
 *
 * Powerful data platform API for managed 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};

/// QueryRequest : Request body for POST /query
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct QueryRequest {
    /// When true, execute the query asynchronously and return a query run ID for polling via GET /query-runs/{id}. The query results can be retrieved via GET /results/{id} once the query run status is \"succeeded\".
    #[serde(rename = "async", skip_serializing_if = "Option::is_none")]
    pub r#async: Option<bool>,
    /// If set (requires `async` = true), first attempt the query synchronously and wait up to this many milliseconds: if it finishes in time the full result is returned, otherwise an async response (a run id to poll) is returned. Must be at least 1000 and at most the server's configured maximum; a value out of that range, or set without `async` = true, is rejected with 400.
    #[serde(
        rename = "async_after_ms",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub async_after_ms: Option<Option<i32>>,
    /// Database to scope the query to (its id). Alternative to the `X-Database-Id` header — exactly one source must be provided. If both this field and the header are set and they disagree, the request is rejected with a 400.
    #[serde(
        rename = "database_id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub database_id: Option<Option<String>>,
    /// Catalog that unqualified table references resolve against within the query's database scope. Must name a catalog visible in the database (`default`, an attached catalog alias, or a system catalog). Defaults to `default` when omitted.
    #[serde(
        rename = "default_catalog",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub default_catalog: Option<Option<String>>,
    /// Schema that unqualified table references resolve against within the query's database scope. Defaults to `main` when omitted. Existence is not validated up front — an unknown schema surfaces as a \"table not found\" error at planning time.
    #[serde(
        rename = "default_schema",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub default_schema: Option<Option<String>>,
    #[serde(rename = "sql")]
    pub sql: String,
}

impl QueryRequest {
    /// Request body for POST /query
    pub fn new(sql: String) -> QueryRequest {
        QueryRequest {
            r#async: None,
            async_after_ms: None,
            database_id: None,
            default_catalog: None,
            default_schema: None,
            sql,
        }
    }
}