/*
 * 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.2.4
 * 
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ArtifactHealthResponse {
    #[serde(rename = "artifact_id")]
    pub artifact_id: uuid::Uuid,
    #[serde(rename = "checks")]
    pub checks: Vec<models::CheckSummary>,
    #[serde(rename = "checks_passed")]
    pub checks_passed: i32,
    #[serde(rename = "checks_total")]
    pub checks_total: i32,
    #[serde(rename = "critical_issues")]
    pub critical_issues: i32,
    #[serde(rename = "health_grade")]
    pub health_grade: String,
    #[serde(rename = "health_score")]
    pub health_score: i32,
    #[serde(rename = "last_checked_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub last_checked_at: Option<Option<String>>,
    #[serde(rename = "license_score", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub license_score: Option<Option<i32>>,
    #[serde(rename = "metadata_score", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub metadata_score: Option<Option<i32>>,
    #[serde(rename = "quality_score", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub quality_score: Option<Option<i32>>,
    #[serde(rename = "security_score", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub security_score: Option<Option<i32>>,
    #[serde(rename = "total_issues")]
    pub total_issues: i32,
}

impl ArtifactHealthResponse {
    pub fn new(artifact_id: uuid::Uuid, checks: Vec<models::CheckSummary>, checks_passed: i32, checks_total: i32, critical_issues: i32, health_grade: String, health_score: i32, total_issues: i32) -> ArtifactHealthResponse {
        ArtifactHealthResponse {
            artifact_id,
            checks,
            checks_passed,
            checks_total,
            critical_issues,
            health_grade,
            health_score,
            last_checked_at: None,
            license_score: None,
            metadata_score: None,
            quality_score: None,
            security_score: None,
            total_issues,
        }
    }
}

