/*
 * 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 SbomResponse {
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    #[serde(rename = "artifact_id")]
    pub artifact_id: uuid::Uuid,
    #[serde(rename = "repository_id")]
    pub repository_id: uuid::Uuid,
    /// SBOM format identifier (e.g. cyclonedx, spdx).
    #[serde(rename = "format")]
    pub format: String,
    /// Version of the SBOM format specification used.
    #[serde(rename = "format_version")]
    pub format_version: String,
    /// Specification version string embedded in the SBOM document.
    #[serde(rename = "spec_version", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub spec_version: Option<Option<String>>,
    /// Number of components declared in the SBOM.
    #[serde(rename = "component_count")]
    pub component_count: i32,
    /// Number of dependency relationships in the SBOM.
    #[serde(rename = "dependency_count")]
    pub dependency_count: i32,
    /// Number of distinct licenses found across all components.
    #[serde(rename = "license_count")]
    pub license_count: i32,
    /// Distinct SPDX license identifiers found in the SBOM.
    #[serde(rename = "licenses")]
    pub licenses: Vec<String>,
    /// SHA-256 hash of the raw SBOM content for integrity verification.
    #[serde(rename = "content_hash")]
    pub content_hash: String,
    /// Name of the tool that produced the SBOM.
    #[serde(rename = "generator", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub generator: Option<Option<String>>,
    /// Version of the generator tool.
    #[serde(rename = "generator_version", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub generator_version: Option<Option<String>>,
    /// Timestamp when the SBOM was generated.
    #[serde(rename = "generated_at")]
    pub generated_at: String,
    #[serde(rename = "created_at")]
    pub created_at: String,
}

impl SbomResponse {
    pub fn new(id: uuid::Uuid, artifact_id: uuid::Uuid, repository_id: uuid::Uuid, format: String, format_version: String, component_count: i32, dependency_count: i32, license_count: i32, licenses: Vec<String>, content_hash: String, generated_at: String, created_at: String) -> SbomResponse {
        SbomResponse {
            id,
            artifact_id,
            repository_id,
            format,
            format_version,
            spec_version: None,
            component_count,
            dependency_count,
            license_count,
            licenses,
            content_hash,
            generator: None,
            generator_version: None,
            generated_at,
            created_at,
        }
    }
}

