/*
 * Artifact Keeper API
 *
 * REST API for Artifact Keeper, an open-source universal artifact registry. Covers user management, repositories, artifacts, search, security scanning, SBOM, dependency tracking, SSO, analytics, monitoring, telemetry, lifecycle policies, plugins, edge nodes, migration, and administration. Format-specific protocol endpoints (npm, PyPI, Maven, Docker/OCI, etc.) are not included; those follow their respective upstream specifications.
 *
 * The version of the OpenAPI document: 1.0.0-a2
 * 
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Webhook {
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    #[serde(rename = "url")]
    pub url: String,
    #[serde(rename = "events")]
    pub events: Vec<Events>,
    #[serde(rename = "repository_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub repository_id: Option<Option<uuid::Uuid>>,
    #[serde(rename = "is_enabled")]
    pub is_enabled: bool,
    #[serde(rename = "last_triggered_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub last_triggered_at: Option<Option<String>>,
    #[serde(rename = "created_at")]
    pub created_at: String,
}

impl Webhook {
    pub fn new(id: uuid::Uuid, url: String, events: Vec<Events>, is_enabled: bool, created_at: String) -> Webhook {
        Webhook {
            id,
            url,
            events,
            repository_id: None,
            is_enabled,
            last_triggered_at: None,
            created_at,
        }
    }
}
/// 
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Events {
    #[serde(rename = "artifact_uploaded")]
    ArtifactUploaded,
    #[serde(rename = "artifact_deleted")]
    ArtifactDeleted,
    #[serde(rename = "repository_created")]
    RepositoryCreated,
    #[serde(rename = "repository_deleted")]
    RepositoryDeleted,
    #[serde(rename = "user_created")]
    UserCreated,
    #[serde(rename = "user_deleted")]
    UserDeleted,
    #[serde(rename = "build_started")]
    BuildStarted,
    #[serde(rename = "build_completed")]
    BuildCompleted,
    #[serde(rename = "build_failed")]
    BuildFailed,
}

impl Default for Events {
    fn default() -> Events {
        Self::ArtifactUploaded
    }
}

