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

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct RepoHealthResponse {
    #[serde(rename = "artifacts_evaluated")]
    pub artifacts_evaluated: i32,
    #[serde(rename = "artifacts_failing")]
    pub artifacts_failing: i32,
    #[serde(rename = "artifacts_passing")]
    pub artifacts_passing: i32,
    #[serde(rename = "avg_license_score", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub avg_license_score: Option<Option<i32>>,
    #[serde(rename = "avg_metadata_score", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub avg_metadata_score: Option<Option<i32>>,
    #[serde(rename = "avg_quality_score", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub avg_quality_score: Option<Option<i32>>,
    #[serde(rename = "avg_security_score", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub avg_security_score: Option<Option<i32>>,
    #[serde(rename = "health_grade")]
    pub health_grade: String,
    #[serde(rename = "health_score")]
    pub health_score: i32,
    #[serde(rename = "last_evaluated_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub last_evaluated_at: Option<Option<String>>,
    #[serde(rename = "repository_id")]
    pub repository_id: uuid::Uuid,
    #[serde(rename = "repository_key")]
    pub repository_key: String,
}

impl RepoHealthResponse {
    pub fn new(artifacts_evaluated: i32, artifacts_failing: i32, artifacts_passing: i32, health_grade: String, health_score: i32, repository_id: uuid::Uuid, repository_key: String) -> RepoHealthResponse {
        RepoHealthResponse {
            artifacts_evaluated,
            artifacts_failing,
            artifacts_passing,
            avg_license_score: None,
            avg_metadata_score: None,
            avg_quality_score: None,
            avg_security_score: None,
            health_grade,
            health_score,
            last_evaluated_at: None,
            repository_id,
            repository_key,
        }
    }
}

