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

/// LifecyclePolicy : An automated policy governing artifact retention and cleanup.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct LifecyclePolicy {
    /// Unique identifier for the lifecycle policy.
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    /// Repository this policy is scoped to. Null indicates a global policy.
    #[serde(rename = "repository_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub repository_id: Option<Option<uuid::Uuid>>,
    /// Human-readable name for the policy.
    #[serde(rename = "name")]
    pub name: String,
    /// Longer description of the policy purpose and behavior.
    #[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub description: Option<Option<String>>,
    /// Whether the policy is active for scheduled execution.
    #[serde(rename = "enabled")]
    pub enabled: bool,
    /// Type of lifecycle policy (e.g. retention, cleanup, archive).
    #[serde(rename = "policy_type")]
    pub policy_type: String,
    /// Policy-type-specific configuration object.
    #[serde(rename = "config")]
    pub config: serde_json::Value,
    /// Execution priority. Lower values execute first.
    #[serde(rename = "priority")]
    pub priority: i32,
    /// Timestamp of the most recent policy execution.
    #[serde(rename = "last_run_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub last_run_at: Option<Option<String>>,
    /// Number of artifacts removed during the most recent execution.
    #[serde(rename = "last_run_items_removed", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub last_run_items_removed: Option<Option<i32>>,
    /// Timestamp when the policy was created.
    #[serde(rename = "created_at")]
    pub created_at: String,
    /// Timestamp when the policy was last modified.
    #[serde(rename = "updated_at")]
    pub updated_at: String,
}

impl LifecyclePolicy {
    /// An automated policy governing artifact retention and cleanup.
    pub fn new(id: uuid::Uuid, name: String, enabled: bool, policy_type: String, config: serde_json::Value, priority: i32, created_at: String, updated_at: String) -> LifecyclePolicy {
        LifecyclePolicy {
            id,
            repository_id: None,
            name,
            description: None,
            enabled,
            policy_type,
            config,
            priority,
            last_run_at: None,
            last_run_items_removed: None,
            created_at,
            updated_at,
        }
    }
}

