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

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

/// AzureTriggerData : Data for creating or updating an Azure Event Grid trigger.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct AzureTriggerData {
    #[serde(rename = "azure_resource_path")]
    pub azure_resource_path: String,
    #[serde(rename = "azure_mode")]
    pub azure_mode: models::AzureMode,
    #[serde(rename = "scope_resource_id")]
    pub scope_resource_id: String,
    #[serde(rename = "topic_name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub topic_name: Option<Option<String>>,
    #[serde(rename = "subscription_name")]
    pub subscription_name: String,
    /// Base URL for push delivery endpoints (push modes only).
    #[serde(rename = "base_endpoint", skip_serializing_if = "Option::is_none")]
    pub base_endpoint: Option<String>,
    #[serde(rename = "event_type_filters", skip_serializing_if = "Option::is_none")]
    pub event_type_filters: Option<Vec<String>>,
    /// The unique Orvanta path for this trigger. Must be of the form `u/<user>/<path>` or `f/<folder>/<path>`. This is the trigger object path, not the HTTP route path.
    #[serde(rename = "path")]
    pub path: String,
    #[serde(rename = "script_path")]
    pub script_path: String,
    #[serde(rename = "is_flow")]
    pub is_flow: bool,
    #[serde(rename = "mode", skip_serializing_if = "Option::is_none")]
    pub mode: Option<models::TriggerMode>,
    #[serde(rename = "error_handler_path", skip_serializing_if = "Option::is_none")]
    pub error_handler_path: Option<String>,
    /// The arguments to pass to the script or flow
    #[serde(rename = "error_handler_args", skip_serializing_if = "Option::is_none")]
    pub error_handler_args: Option<std::collections::HashMap<String, serde_json::Value>>,
    #[serde(rename = "retry", skip_serializing_if = "Option::is_none")]
    pub retry: Option<Box<models::Retry>>,
    #[serde(rename = "permissioned_as", skip_serializing_if = "Option::is_none")]
    pub permissioned_as: Option<String>,
    #[serde(rename = "preserve_permissioned_as", skip_serializing_if = "Option::is_none")]
    pub preserve_permissioned_as: Option<bool>,
    #[serde(rename = "labels", skip_serializing_if = "Option::is_none")]
    pub labels: Option<Vec<String>>,
}

impl AzureTriggerData {
    /// Data for creating or updating an Azure Event Grid trigger.
    pub fn new(azure_resource_path: String, azure_mode: models::AzureMode, scope_resource_id: String, subscription_name: String, path: String, script_path: String, is_flow: bool) -> AzureTriggerData {
        AzureTriggerData {
            azure_resource_path,
            azure_mode,
            scope_resource_id,
            topic_name: None,
            subscription_name,
            base_endpoint: None,
            event_type_filters: None,
            path,
            script_path,
            is_flow,
            mode: None,
            error_handler_path: None,
            error_handler_args: None,
            retry: None,
            permissioned_as: None,
            preserve_permissioned_as: None,
            labels: None,
        }
    }
}

