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

/// GcpTriggerData : Data for creating or updating a Google Cloud Pub/Sub trigger.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct GcpTriggerData {
    /// Path to the GCP resource containing service account credentials for authentication.
    #[serde(rename = "gcp_resource_path")]
    pub gcp_resource_path: String,
    #[serde(rename = "subscription_mode")]
    pub subscription_mode: models::SubscriptionMode,
    /// Google Cloud Pub/Sub topic ID to subscribe to.
    #[serde(rename = "topic_id")]
    pub topic_id: String,
    /// Google Cloud Pub/Sub subscription ID.
    #[serde(rename = "subscription_id", skip_serializing_if = "Option::is_none")]
    pub subscription_id: Option<String>,
    /// Base URL for push delivery endpoint.
    #[serde(rename = "base_endpoint", skip_serializing_if = "Option::is_none")]
    pub base_endpoint: Option<String>,
    #[serde(rename = "delivery_type", skip_serializing_if = "Option::is_none")]
    pub delivery_type: Option<models::DeliveryType>,
    #[serde(rename = "delivery_config", skip_serializing_if = "Option::is_none")]
    pub delivery_config: Option<Box<models::PushConfig>>,
    /// 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 a message is received.
    #[serde(rename = "script_path")]
    pub script_path: 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", skip_serializing_if = "Option::is_none")]
    pub mode: Option<models::TriggerMode>,
    /// If true, automatically acknowledge messages after processing.
    #[serde(rename = "auto_acknowledge_msg", skip_serializing_if = "Option::is_none")]
    pub auto_acknowledge_msg: Option<bool>,
    /// Time in seconds within which the message must be acknowledged. If not provided, defaults to the subscription's acknowledgment deadline (600 seconds).
    #[serde(rename = "ack_deadline", skip_serializing_if = "Option::is_none")]
    pub ack_deadline: Option<i32>,
    /// Path to a script or flow to run when the triggered job fails.
    #[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 user or group this trigger runs as. Used during deployment to preserve the original trigger owner.
    #[serde(rename = "permissioned_as", skip_serializing_if = "Option::is_none")]
    pub permissioned_as: Option<String>,
    /// When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.
    #[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 GcpTriggerData {
    /// Data for creating or updating a Google Cloud Pub/Sub trigger.
    pub fn new(gcp_resource_path: String, subscription_mode: models::SubscriptionMode, topic_id: String, path: String, script_path: String, is_flow: bool) -> GcpTriggerData {
        GcpTriggerData {
            gcp_resource_path,
            subscription_mode,
            topic_id,
            subscription_id: None,
            base_endpoint: None,
            delivery_type: None,
            delivery_config: None,
            path,
            script_path,
            is_flow,
            mode: None,
            auto_acknowledge_msg: None,
            ack_deadline: None,
            error_handler_path: None,
            error_handler_args: None,
            retry: None,
            permissioned_as: None,
            preserve_permissioned_as: None,
            labels: None,
        }
    }
}

