/*
 * Artifact Keeper API
 *
 * Enterprise artifact registry supporting 45+ package formats.
 *
 * The version of the OpenAPI document: 1.2.1
 * 
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CreateWebhookRequest {
    /// Pinned event payload version. Defaults to \"2026-04-01\" when omitted. Must match a value in `SUPPORTED_EVENT_VERSIONS` or the request is rejected with HTTP 422.
    #[serde(rename = "event_schema_version", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub event_schema_version: Option<Option<String>>,
    #[serde(rename = "events")]
    pub events: Vec<String>,
    #[serde(rename = "headers", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub headers: Option<Option<serde_json::Value>>,
    #[serde(rename = "name")]
    pub name: String,
    /// Payload layout for the target platform (default: generic).
    #[serde(rename = "payload_template", skip_serializing_if = "Option::is_none")]
    pub payload_template: Option<models::PayloadTemplate>,
    #[serde(rename = "repository_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub repository_id: Option<Option<uuid::Uuid>>,
    /// Optional caller-supplied secret. When omitted the server generates a fresh `whsec_*` secret. Either way the raw value is returned in the 201 response body exactly once and is unrecoverable thereafter.
    #[serde(rename = "secret", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub secret: Option<Option<String>>,
    #[serde(rename = "url")]
    pub url: String,
}

impl CreateWebhookRequest {
    pub fn new(events: Vec<String>, name: String, url: String) -> CreateWebhookRequest {
        CreateWebhookRequest {
            event_schema_version: None,
            events,
            headers: None,
            name,
            payload_template: None,
            repository_id: None,
            secret: None,
            url,
        }
    }
}

