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

/// MavenComponentResponse : A Maven component grouped by GAV (groupId, artifactId, version).  Each component collects the individual files (jar, pom, checksums, etc.) that share the same Maven coordinates.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct MavenComponentResponse {
    /// Individual filenames belonging to this component.
    #[serde(rename = "artifact_files")]
    pub artifact_files: Vec<String>,
    /// Maven artifactId (e.g. `junit-jupiter-api`).
    #[serde(rename = "artifact_id")]
    pub artifact_id: String,
    /// Earliest creation timestamp among the component files.
    #[serde(rename = "created_at")]
    pub created_at: String,
    /// Total download count across all files in this component.
    #[serde(rename = "download_count")]
    pub download_count: i64,
    /// Repository format (always `maven` or `gradle`).
    #[serde(rename = "format")]
    pub format: String,
    /// Maven groupId with dots (e.g. `org.junit.jupiter`).
    #[serde(rename = "group_id")]
    pub group_id: String,
    /// Representative artifact ID (the first file in the group).
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    /// Repository key this component belongs to.
    #[serde(rename = "repository_key")]
    pub repository_key: String,
    /// Total size in bytes across all files in this component.
    #[serde(rename = "size_bytes")]
    pub size_bytes: i64,
    /// Maven version string (e.g. `5.11.0`).
    #[serde(rename = "version")]
    pub version: String,
}

impl MavenComponentResponse {
    /// A Maven component grouped by GAV (groupId, artifactId, version).  Each component collects the individual files (jar, pom, checksums, etc.) that share the same Maven coordinates.
    pub fn new(artifact_files: Vec<String>, artifact_id: String, created_at: String, download_count: i64, format: String, group_id: String, id: uuid::Uuid, repository_key: String, size_bytes: i64, version: String) -> MavenComponentResponse {
        MavenComponentResponse {
            artifact_files,
            artifact_id,
            created_at,
            download_count,
            format,
            group_id,
            id,
            repository_key,
            size_bytes,
            version,
        }
    }
}

