/*
 * 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};

/// SavedQueryDetail : Saved query detail (includes latest version's SQL)
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct SavedQueryDetail {
    #[serde(
        rename = "category",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub category: Option<Option<String>>,
    #[serde(rename = "created_at")]
    pub created_at: String,
    #[serde(rename = "description")]
    pub description: String,
    #[serde(
        rename = "has_aggregation",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub has_aggregation: Option<Option<bool>>,
    #[serde(
        rename = "has_group_by",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub has_group_by: Option<Option<bool>>,
    #[serde(
        rename = "has_join",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub has_join: Option<Option<bool>>,
    #[serde(
        rename = "has_limit",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub has_limit: Option<Option<bool>>,
    #[serde(
        rename = "has_order_by",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub has_order_by: Option<Option<bool>>,
    #[serde(
        rename = "has_predicate",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub has_predicate: Option<Option<bool>>,
    #[serde(rename = "id")]
    pub id: String,
    #[serde(rename = "latest_version")]
    pub latest_version: i32,
    #[serde(rename = "name")]
    pub name: String,
    #[serde(
        rename = "num_tables",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub num_tables: Option<Option<i32>>,
    #[serde(rename = "sql")]
    pub sql: String,
    #[serde(rename = "sql_hash")]
    pub sql_hash: String,
    #[serde(
        rename = "table_size",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub table_size: Option<Option<String>>,
    #[serde(rename = "tags")]
    pub tags: Vec<String>,
    #[serde(rename = "updated_at")]
    pub updated_at: String,
}

impl SavedQueryDetail {
    /// Saved query detail (includes latest version's SQL)
    pub fn new(
        created_at: String,
        description: String,
        id: String,
        latest_version: i32,
        name: String,
        sql: String,
        sql_hash: String,
        tags: Vec<String>,
        updated_at: String,
    ) -> SavedQueryDetail {
        SavedQueryDetail {
            category: None,
            created_at,
            description,
            has_aggregation: None,
            has_group_by: None,
            has_join: None,
            has_limit: None,
            has_order_by: None,
            has_predicate: None,
            id,
            latest_version,
            name,
            num_tables: None,
            sql,
            sql_hash,
            table_size: None,
            tags,
            updated_at,
        }
    }
}
