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

/// ConnectionRefreshResult : Result payload for a `data_refresh_connection` job.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ConnectionRefreshResult {
    #[serde(rename = "connection_id")]
    pub connection_id: String,
    #[serde(rename = "duration_ms")]
    pub duration_ms: i64,
    #[serde(rename = "errors", skip_serializing_if = "Option::is_none")]
    pub errors: Option<Vec<models::TableRefreshError>>,
    #[serde(rename = "tables_failed")]
    pub tables_failed: i32,
    #[serde(rename = "tables_refreshed")]
    pub tables_refreshed: i32,
    #[serde(rename = "total_rows")]
    pub total_rows: i32,
    #[serde(rename = "warnings", skip_serializing_if = "Option::is_none")]
    pub warnings: Option<Vec<models::RefreshWarning>>,
}

impl ConnectionRefreshResult {
    /// Result payload for a `data_refresh_connection` job.
    pub fn new(
        connection_id: String,
        duration_ms: i64,
        tables_failed: i32,
        tables_refreshed: i32,
        total_rows: i32,
    ) -> ConnectionRefreshResult {
        ConnectionRefreshResult {
            connection_id,
            duration_ms,
            errors: None,
            tables_failed,
            tables_refreshed,
            total_rows,
            warnings: None,
        }
    }
}
