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

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct NewHttpTrigger {
    /// 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 URL route path that will trigger this endpoint (e.g., 'api/myendpoint'). Must NOT start with a /.
    #[serde(rename = "route_path")]
    pub route_path: String,
    /// If true, the route includes the workspace ID in the path
    #[serde(rename = "workspaced_route", skip_serializing_if = "Option::is_none")]
    pub workspaced_route: Option<bool>,
    /// Short summary describing the purpose of this trigger
    #[serde(rename = "summary", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub summary: Option<Option<String>>,
    /// Detailed description of what this trigger does
    #[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub description: Option<Option<String>>,
    #[serde(rename = "static_asset_config", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub static_asset_config: Option<Option<Box<models::NewHttpTriggerStaticAssetConfig>>>,
    /// 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 = "http_method")]
    pub http_method: models::HttpMethod,
    /// Path to the resource containing authentication configuration (for api_key, basic_http, custom_script, signature methods)
    #[serde(rename = "authentication_resource_path", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub authentication_resource_path: Option<Option<String>>,
    /// Deprecated, use request_type instead
    #[serde(rename = "is_async", skip_serializing_if = "Option::is_none")]
    pub is_async: Option<bool>,
    #[serde(rename = "request_type", skip_serializing_if = "Option::is_none")]
    pub request_type: Option<models::HttpRequestType>,
    #[serde(rename = "authentication_method")]
    pub authentication_method: models::AuthenticationMethod,
    /// If true, serves static files from S3/storage instead of running a script
    #[serde(rename = "is_static_website")]
    pub is_static_website: bool,
    /// If true, wraps the request body in a 'body' parameter
    #[serde(rename = "wrap_body", skip_serializing_if = "Option::is_none")]
    pub wrap_body: Option<bool>,
    #[serde(rename = "mode", skip_serializing_if = "Option::is_none")]
    pub mode: Option<models::TriggerMode>,
    /// If true, passes the request body as a raw string instead of parsing as JSON
    #[serde(rename = "raw_string", skip_serializing_if = "Option::is_none")]
    pub raw_string: Option<bool>,
    /// 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 NewHttpTrigger {
    pub fn new(path: String, script_path: String, route_path: String, is_flow: bool, http_method: models::HttpMethod, authentication_method: models::AuthenticationMethod, is_static_website: bool) -> NewHttpTrigger {
        NewHttpTrigger {
            path,
            script_path,
            route_path,
            workspaced_route: None,
            summary: None,
            description: None,
            static_asset_config: None,
            is_flow,
            http_method,
            authentication_resource_path: None,
            is_async: None,
            request_type: None,
            authentication_method,
            is_static_website,
            wrap_body: None,
            mode: None,
            raw_string: None,
            error_handler_path: None,
            error_handler_args: None,
            retry: None,
            permissioned_as: None,
            preserve_permissioned_as: None,
            labels: None,
        }
    }
}

