/*
 * 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 ComponentResponse {
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    #[serde(rename = "sbom_id")]
    pub sbom_id: uuid::Uuid,
    /// Component name.
    #[serde(rename = "name")]
    pub name: String,
    /// Component version string.
    #[serde(rename = "version", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub version: Option<Option<String>>,
    /// Package URL (purl) identifier.
    #[serde(rename = "purl", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub purl: Option<Option<String>>,
    /// Common Platform Enumeration identifier.
    #[serde(rename = "cpe", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub cpe: Option<Option<String>>,
    /// Component type (e.g. library, framework, application).
    #[serde(rename = "component_type", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub component_type: Option<Option<String>>,
    /// SPDX license identifiers associated with this component.
    #[serde(rename = "licenses")]
    pub licenses: Vec<String>,
    /// SHA-256 checksum of the component artifact.
    #[serde(rename = "sha256", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub sha256: Option<Option<String>>,
    /// SHA-1 checksum of the component artifact.
    #[serde(rename = "sha1", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub sha1: Option<Option<String>>,
    /// MD5 checksum of the component artifact.
    #[serde(rename = "md5", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub md5: Option<Option<String>>,
    /// Organisation or individual that supplied the component.
    #[serde(rename = "supplier", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub supplier: Option<Option<String>>,
    /// Author of the component.
    #[serde(rename = "author", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub author: Option<Option<String>>,
}

impl ComponentResponse {
    pub fn new(id: uuid::Uuid, sbom_id: uuid::Uuid, name: String, licenses: Vec<String>) -> ComponentResponse {
        ComponentResponse {
            id,
            sbom_id,
            name,
            version: None,
            purl: None,
            cpe: None,
            component_type: None,
            licenses,
            sha256: None,
            sha1: None,
            md5: None,
            supplier: None,
            author: None,
        }
    }
}

