/*
 * 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};

/// OciBlobFootprintReport : Read-only OCI blob storage footprint report (issue #1408).  This is a **reporting-only** view. It performs no deletion and takes no locks. It surfaces how much storage the tracked `oci_blobs` rows account for so operators can see the magnitude of un-reclaimed blob layers before any garbage-collection mechanism is enabled.  It deliberately does NOT attempt to classify which blobs are \"reclaimable orphans\": that requires a manifest -> blob reference table that does not yet exist in the schema, and any per-`(repository_id, digest)` orphan heuristic would mis-handle the cross-repo dedup case (multiple `oci_blobs` rows, one physical object) and report in-use blobs as reclaimable. The numbers here are exact aggregates only.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct OciBlobFootprintReport {
    /// Distinct digests older than `grace_hours` (eligible to be *considered* by a future GC sweep once a reference table exists). Reporting only.
    #[serde(rename = "aged_distinct_digests")]
    pub aged_distinct_digests: i64,
    /// Physical bytes (distinct-digest) older than `grace_hours`.
    #[serde(rename = "aged_physical_bytes")]
    pub aged_physical_bytes: i64,
    /// Number of distinct blob digests (content-addressed identities). When this is smaller than `total_blob_rows`, the difference is cross-repo deduplication: rows that share one physical storage object.
    #[serde(rename = "distinct_digests")]
    pub distinct_digests: i64,
    /// Grace window (hours) applied to the `aged_*` figures below.
    #[serde(rename = "grace_hours")]
    pub grace_hours: i64,
    /// Sum of `size_bytes` over every `oci_blobs` row. Double-counts deduplicated blobs once per referencing repository.
    #[serde(rename = "logical_bytes")]
    pub logical_bytes: i64,
    /// Per-repository logical footprint, largest `logical_bytes` first.
    #[serde(rename = "per_repository")]
    pub per_repository: Vec<models::OciBlobRepoFootprint>,
    /// Sum of `size_bytes` counting each distinct digest exactly once. This approximates the physical bytes occupied in the storage backend.
    #[serde(rename = "physical_bytes")]
    pub physical_bytes: i64,
    /// Total number of `oci_blobs` rows across all repositories.
    #[serde(rename = "total_blob_rows")]
    pub total_blob_rows: i64,
}

impl OciBlobFootprintReport {
    /// Read-only OCI blob storage footprint report (issue #1408).  This is a **reporting-only** view. It performs no deletion and takes no locks. It surfaces how much storage the tracked `oci_blobs` rows account for so operators can see the magnitude of un-reclaimed blob layers before any garbage-collection mechanism is enabled.  It deliberately does NOT attempt to classify which blobs are \"reclaimable orphans\": that requires a manifest -> blob reference table that does not yet exist in the schema, and any per-`(repository_id, digest)` orphan heuristic would mis-handle the cross-repo dedup case (multiple `oci_blobs` rows, one physical object) and report in-use blobs as reclaimable. The numbers here are exact aggregates only.
    pub fn new(aged_distinct_digests: i64, aged_physical_bytes: i64, distinct_digests: i64, grace_hours: i64, logical_bytes: i64, per_repository: Vec<models::OciBlobRepoFootprint>, physical_bytes: i64, total_blob_rows: i64) -> OciBlobFootprintReport {
        OciBlobFootprintReport {
            aged_distinct_digests,
            aged_physical_bytes,
            distinct_digests,
            grace_hours,
            logical_bytes,
            per_repository,
            physical_bytes,
            total_blob_rows,
        }
    }
}

