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

/// AzureTrigger : An Azure Event Grid trigger that executes a script or flow when events arrive.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct AzureTrigger {
    #[serde(rename = "azure_resource_path")]
    pub azure_resource_path: String,
    #[serde(rename = "azure_mode")]
    pub azure_mode: models::AzureMode,
    /// ARM resource ID of the topic (basic) or namespace (namespace modes).
    #[serde(rename = "scope_resource_id")]
    pub scope_resource_id: String,
    /// Topic name within the namespace (namespace modes only).
    #[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,
    #[serde(rename = "event_type_filters", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub event_type_filters: Option<Option<Vec<String>>>,
    #[serde(rename = "server_id", skip_serializing_if = "Option::is_none")]
    pub server_id: Option<String>,
    #[serde(rename = "last_server_ping", skip_serializing_if = "Option::is_none")]
    pub last_server_ping: Option<String>,
    #[serde(rename = "error", skip_serializing_if = "Option::is_none")]
    pub error: Option<String>,
    #[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>>,
    /// 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,
    /// Path to the script or flow to execute when triggered
    #[serde(rename = "script_path")]
    pub script_path: String,
    /// The user or group this trigger runs as (permissioned_as)
    #[serde(rename = "permissioned_as")]
    pub permissioned_as: String,
    /// Additional permissions for this trigger
    #[serde(rename = "extra_perms")]
    pub extra_perms: std::collections::HashMap<String, bool>,
    /// The workspace this trigger belongs to
    #[serde(rename = "workspace_id")]
    pub workspace_id: String,
    /// Username of the last person who edited this trigger
    #[serde(rename = "edited_by")]
    pub edited_by: String,
    /// Timestamp of the last edit
    #[serde(rename = "edited_at")]
    pub edited_at: String,
    /// True if script_path points to a flow, false if it points to a script
    #[serde(rename = "is_flow")]
    pub is_flow: bool,
    #[serde(rename = "mode")]
    pub mode: models::TriggerMode,
    #[serde(rename = "labels", skip_serializing_if = "Option::is_none")]
    pub labels: Option<Vec<String>>,
}

impl AzureTrigger {
    /// An Azure Event Grid trigger that executes a script or flow when events arrive.
    pub fn new(azure_resource_path: String, azure_mode: models::AzureMode, scope_resource_id: String, subscription_name: String, path: String, script_path: String, permissioned_as: String, extra_perms: std::collections::HashMap<String, bool>, workspace_id: String, edited_by: String, edited_at: String, is_flow: bool, mode: models::TriggerMode) -> AzureTrigger {
        AzureTrigger {
            azure_resource_path,
            azure_mode,
            scope_resource_id,
            topic_name: None,
            subscription_name,
            event_type_filters: None,
            server_id: None,
            last_server_ping: None,
            error: None,
            error_handler_path: None,
            error_handler_args: None,
            retry: None,
            path,
            script_path,
            permissioned_as,
            extra_perms,
            workspace_id,
            edited_by,
            edited_at,
            is_flow,
            mode,
            labels: None,
        }
    }
}

