/*
 * Artifact Keeper API
 *
 * Enterprise artifact registry supporting 45+ package formats.  ## Authentication  The JSON management API under `/api/v1/_*` accepts **API tokens only as `Authorization: Bearer <token>`**. This is the canonical scheme for programmatic access; JWTs issued by the login flow also use `Bearer`. HTTP Basic credentials on `/api/v1/_*` are validated *only* as a real `username:password` login — the password half is **not** retried as an API token. A request to `/api/v1/_*` that sends an API token in the password field of Basic auth therefore returns `401 AUTH_ERROR`; switch to `Authorization: Bearer <token>`.  Format (package-manager) endpoints such as `/v2/_*` (OCI), `/incus/_*`, `/debian/_*`, and the language registries are intentionally more permissive for client compatibility: in addition to Bearer, they accept HTTP **Basic** auth with the API token supplied in the *password* field (any username), matching the `pip` netrc / Artifactory-style `token:<api_token>` convention used by package managers that cannot send a Bearer header. This Basic-with-token fallback applies to format endpoints only, never to `/api/v1/_*`.
 *
 * The version of the OpenAPI document: 1.4.2
 * 
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ScanResponse {
    #[serde(rename = "artifact_id")]
    pub artifact_id: uuid::Uuid,
    #[serde(rename = "artifact_name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub artifact_name: Option<Option<String>>,
    #[serde(rename = "artifact_version", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub artifact_version: Option<Option<String>>,
    #[serde(rename = "completed_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub completed_at: Option<Option<String>>,
    #[serde(rename = "created_at")]
    pub created_at: String,
    #[serde(rename = "critical_count")]
    pub critical_count: i32,
    #[serde(rename = "error_message", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub error_message: Option<Option<String>>,
    #[serde(rename = "findings_count")]
    pub findings_count: i32,
    #[serde(rename = "high_count")]
    pub high_count: i32,
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    #[serde(rename = "info_count")]
    pub info_count: i32,
    /// True when the row was synthesized by the dedup path (`copy_scan_results`) because a prior scan with the same `(checksum_sha256, scan_type)` pair already existed within the dedup TTL. No scanner was actually invoked for this row; counts and findings were copied from `source_scan_id`.
    #[serde(rename = "is_reused")]
    pub is_reused: bool,
    #[serde(rename = "low_count")]
    pub low_count: i32,
    #[serde(rename = "medium_count")]
    pub medium_count: i32,
    #[serde(rename = "repository_id")]
    pub repository_id: uuid::Uuid,
    #[serde(rename = "scan_type")]
    pub scan_type: String,
    #[serde(rename = "scanner_version", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub scanner_version: Option<Option<String>>,
    /// When `is_reused` is true, the `id` of the source scan whose results were copied. Useful for distinguishing \"fresh scan\" from \"deduped satisfaction\" in release-gate provenance checks. None for original (non-reused) scans.
    #[serde(rename = "source_scan_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub source_scan_id: Option<Option<uuid::Uuid>>,
    #[serde(rename = "started_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub started_at: Option<Option<String>>,
    #[serde(rename = "status")]
    pub status: String,
}

impl ScanResponse {
    pub fn new(artifact_id: uuid::Uuid, created_at: String, critical_count: i32, findings_count: i32, high_count: i32, id: uuid::Uuid, info_count: i32, is_reused: bool, low_count: i32, medium_count: i32, repository_id: uuid::Uuid, scan_type: String, status: String) -> ScanResponse {
        ScanResponse {
            artifact_id,
            artifact_name: None,
            artifact_version: None,
            completed_at: None,
            created_at,
            critical_count,
            error_message: None,
            findings_count,
            high_count,
            id,
            info_count,
            is_reused,
            low_count,
            medium_count,
            repository_id,
            scan_type,
            scanner_version: None,
            source_scan_id: None,
            started_at: None,
            status,
        }
    }
}

