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

/// StaleArtifact : An artifact that has not been downloaded within the staleness threshold.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct StaleArtifact {
    /// Unique identifier of the artifact.
    #[serde(rename = "artifact_id")]
    pub artifact_id: uuid::Uuid,
    /// Key of the repository containing the artifact.
    #[serde(rename = "repository_key")]
    pub repository_key: String,
    /// Artifact file name.
    #[serde(rename = "name")]
    pub name: String,
    /// Full path within the repository.
    #[serde(rename = "path")]
    pub path: String,
    /// Size of the artifact in bytes.
    #[serde(rename = "size_bytes")]
    pub size_bytes: i64,
    /// Timestamp when the artifact was first uploaded.
    #[serde(rename = "created_at")]
    pub created_at: String,
    /// Timestamp of the most recent download, or null if the artifact has never been downloaded.
    #[serde(rename = "last_downloaded_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub last_downloaded_at: Option<Option<String>>,
    /// Number of days since the artifact was last downloaded. If never downloaded, this reflects days since creation.
    #[serde(rename = "days_since_download")]
    pub days_since_download: i32,
    /// Total number of times this artifact has been downloaded.
    #[serde(rename = "download_count")]
    pub download_count: i64,
}

impl StaleArtifact {
    /// An artifact that has not been downloaded within the staleness threshold.
    pub fn new(artifact_id: uuid::Uuid, repository_key: String, name: String, path: String, size_bytes: i64, created_at: String, days_since_download: i32, download_count: i64) -> StaleArtifact {
        StaleArtifact {
            artifact_id,
            repository_key,
            name,
            path,
            size_bytes,
            created_at,
            last_downloaded_at: None,
            days_since_download,
            download_count,
        }
    }
}

