/*
 * Artifact Keeper API
 *
 * Enterprise artifact registry supporting 45+ package formats.
 *
 * The version of the OpenAPI document: 1.2.1
 * 
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CreateRepositoryRequest {
    /// Alias for `is_public`. When set to true, anonymous users can download artifacts from this repository without authentication. Useful for remote (pull-through cache) repositories that proxy public upstream registries. If both `is_public` and `allow_anonymous_access` are provided, `allow_anonymous_access` takes precedence.
    #[serde(rename = "allow_anonymous_access", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub allow_anonymous_access: Option<Option<bool>>,
    #[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,
    /// Custom format key for WASM plugin format handlers (e.g. \"rpm-custom\").
    #[serde(rename = "format_key", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub format_key: Option<Option<String>>,
    /// Separate index host for Cargo registries that split index and download across two hosts (e.g. crates.io uses `https://index.crates.io` for the sparse index but `https://crates.io` for tarball downloads). Stored in `repository_config` under the key `index_upstream_url`.
    #[serde(rename = "index_upstream_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub index_upstream_url: Option<Option<String>>,
    #[serde(rename = "is_public", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub is_public: Option<Option<bool>>,
    #[serde(rename = "key")]
    pub key: String,
    /// Member repositories to add when creating a virtual repository. Each entry specifies a repository key and optional priority.
    #[serde(rename = "member_repos", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub member_repos: Option<Option<Vec<models::CreateVirtualMemberInput>>>,
    #[serde(rename = "name")]
    pub name: String,
    /// When true, direct user uploads to this repository are rejected: artifacts must arrive via the promotion path. Admin-only to set. Defaults to false (no behavior change for existing repositories).
    #[serde(rename = "promotion_only", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub promotion_only: 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,
    /// Override the default storage backend for this repository. When omitted, the server's configured default is used. Non-admin users may only use the default backend.
    #[serde(rename = "storage_backend", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub storage_backend: Option<Option<String>>,
    /// Upstream auth type: \"basic\" or \"bearer\". Only valid for remote repos.
    #[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>>,
    /// Password (basic) or token (bearer). Write-only, never returned in responses.
    #[serde(rename = "upstream_password", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub upstream_password: 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>>,
    /// Username for basic auth.
    #[serde(rename = "upstream_username", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub upstream_username: Option<Option<String>>,
}

impl CreateRepositoryRequest {
    pub fn new(format: String, key: String, name: String, repo_type: String) -> CreateRepositoryRequest {
        CreateRepositoryRequest {
            allow_anonymous_access: None,
            description: None,
            format,
            format_key: None,
            index_upstream_url: None,
            is_public: None,
            key,
            member_repos: None,
            name,
            promotion_only: None,
            quota_bytes: None,
            repo_type,
            storage_backend: None,
            upstream_auth_type: None,
            upstream_password: None,
            upstream_url: None,
            upstream_username: None,
        }
    }
}

