/*
 * Orvanta API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.2.0
 * Contact: contact@orvanta.cloud
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// NativeTriggerWithExternal : Full trigger response containing both Orvanta data and external service data
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct NativeTriggerWithExternal {
    /// The unique identifier from the external service
    #[serde(rename = "external_id")]
    pub external_id: String,
    /// The workspace this trigger belongs to
    #[serde(rename = "workspace_id")]
    pub workspace_id: String,
    #[serde(rename = "service_name")]
    pub service_name: models::NativeServiceName,
    /// The path to the script or flow that will be triggered
    #[serde(rename = "script_path")]
    pub script_path: String,
    /// Whether the trigger targets a flow (true) or a script (false)
    #[serde(rename = "is_flow")]
    pub is_flow: bool,
    /// Configuration for the trigger including event_type and service_config
    #[serde(rename = "service_config")]
    pub service_config: std::collections::HashMap<String, serde_json::Value>,
    /// Error message if the trigger is in an error state
    #[serde(rename = "error", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub error: Option<Option<String>>,
    /// Short summary to be displayed when listed
    #[serde(rename = "summary", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub summary: Option<Option<String>>,
    /// Configuration data from the external service
    #[serde(rename = "external_data")]
    pub external_data: std::collections::HashMap<String, serde_json::Value>,
}

impl NativeTriggerWithExternal {
    /// Full trigger response containing both Orvanta data and external service data
    pub fn new(external_id: String, workspace_id: String, service_name: models::NativeServiceName, script_path: String, is_flow: bool, service_config: std::collections::HashMap<String, serde_json::Value>, external_data: std::collections::HashMap<String, serde_json::Value>) -> NativeTriggerWithExternal {
        NativeTriggerWithExternal {
            external_id,
            workspace_id,
            service_name,
            script_path,
            is_flow,
            service_config,
            error: None,
            summary: None,
            external_data,
        }
    }
}

