/*
 * 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 SearchResult {
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "path")]
    pub path: String,
    #[serde(rename = "version", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub version: Option<Option<String>>,
    #[serde(rename = "format")]
    pub format: String,
    #[serde(rename = "repository_key")]
    pub repository_key: String,
    #[serde(rename = "size_bytes")]
    pub size_bytes: i32,
    /// Matched fields from the search query
    #[serde(rename = "highlight", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub highlight: Option<Option<serde_json::Value>>,
}

impl SearchResult {
    pub fn new(id: uuid::Uuid, name: String, path: String, format: String, repository_key: String, size_bytes: i32) -> SearchResult {
        SearchResult {
            id,
            name,
            path,
            version: None,
            format,
            repository_key,
            size_bytes,
            highlight: None,
        }
    }
}

