/*
 * 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 RepositoryResponse {
    /// Whether anonymous (unauthenticated) downloads are allowed. This is always equal to `is_public` and provided as a convenience alias so the semantics are clear for remote (pull-through cache) repositories.
    #[serde(rename = "allow_anonymous_access")]
    pub allow_anonymous_access: bool,
    #[serde(rename = "created_at")]
    pub created_at: String,
    #[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub description: Option<Option<String>>,
    #[serde(rename = "format")]
    pub format: String,
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    #[serde(rename = "is_public")]
    pub is_public: bool,
    #[serde(rename = "key")]
    pub key: String,
    #[serde(rename = "name")]
    pub name: String,
    /// When true, direct user uploads are rejected; artifacts must be promoted.
    #[serde(rename = "promotion_only")]
    pub promotion_only: bool,
    /// Configured quarantine hold duration in minutes, read back from `repository_config` (#1770 B). `None` when unset.
    #[serde(rename = "quarantine_duration_minutes", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub quarantine_duration_minutes: Option<Option<i64>>,
    /// Whether the Package Age / quarantine policy is enabled for this repository, read back from `repository_config` (#1770 B). `None` when the repository has no explicit setting (the global default applies).
    #[serde(rename = "quarantine_enabled", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub quarantine_enabled: Option<Option<bool>>,
    #[serde(rename = "quota_bytes", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub quota_bytes: Option<Option<i64>>,
    #[serde(rename = "repo_type")]
    pub repo_type: String,
    #[serde(rename = "storage_used_bytes")]
    pub storage_used_bytes: i64,
    #[serde(rename = "updated_at")]
    pub updated_at: String,
    #[serde(rename = "upstream_auth_configured")]
    pub upstream_auth_configured: bool,
    #[serde(rename = "upstream_auth_type", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub upstream_auth_type: Option<Option<String>>,
    #[serde(rename = "upstream_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub upstream_url: Option<Option<String>>,
}

impl RepositoryResponse {
    pub fn new(allow_anonymous_access: bool, created_at: String, format: String, id: uuid::Uuid, is_public: bool, key: String, name: String, promotion_only: bool, repo_type: String, storage_used_bytes: i64, updated_at: String, upstream_auth_configured: bool) -> RepositoryResponse {
        RepositoryResponse {
            allow_anonymous_access,
            created_at,
            description: None,
            format,
            id,
            is_public,
            key,
            name,
            promotion_only,
            quarantine_duration_minutes: None,
            quarantine_enabled: None,
            quota_bytes: None,
            repo_type,
            storage_used_bytes,
            updated_at,
            upstream_auth_configured,
            upstream_auth_type: None,
            upstream_url: None,
        }
    }
}

