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

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CreateSessionRequest {
    #[serde(rename = "artifact_metadata", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub artifact_metadata: Option<Option<serde_json::Value>>,
    /// Source artifact metadata format for peer replication.
    #[serde(rename = "artifact_metadata_format", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub artifact_metadata_format: Option<Option<String>>,
    #[serde(rename = "artifact_metadata_properties", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub artifact_metadata_properties: Option<Option<serde_json::Value>>,
    /// Artifact name to persist when the upload completes.  Optional for regular client uploads. Peer replication sets this from the source artifact row so chunked replication preserves metadata.
    #[serde(rename = "artifact_name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub artifact_name: Option<Option<String>>,
    /// Path within the repository (e.g. \"images/vm.ova\")
    #[serde(rename = "artifact_path")]
    pub artifact_path: String,
    /// Artifact version to persist when the upload completes.  Optional for regular client uploads. Peer replication sets this from the source artifact row so chunked replication preserves metadata.
    #[serde(rename = "artifact_version", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub artifact_version: Option<Option<String>>,
    /// Expected SHA256 checksum of the complete file
    #[serde(rename = "checksum_sha256")]
    pub checksum_sha256: String,
    /// Chunk size in bytes (default 8 MB, range 1 MB - 256 MB)
    #[serde(rename = "chunk_size", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub chunk_size: Option<Option<i32>>,
    /// MIME content type (default \"application/octet-stream\")
    #[serde(rename = "content_type", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub content_type: Option<Option<String>>,
    /// Source package description for peer replication.
    #[serde(rename = "package_description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub package_description: Option<Option<String>>,
    #[serde(rename = "package_metadata", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub package_metadata: Option<Option<serde_json::Value>>,
    /// Repository key (e.g. \"my-repo\")
    #[serde(rename = "repository_key")]
    pub repository_key: String,
    /// Total file size in bytes
    #[serde(rename = "total_size")]
    pub total_size: i64,
}

impl CreateSessionRequest {
    pub fn new(artifact_path: String, checksum_sha256: String, repository_key: String, total_size: i64) -> CreateSessionRequest {
        CreateSessionRequest {
            artifact_metadata: None,
            artifact_metadata_format: None,
            artifact_metadata_properties: None,
            artifact_name: None,
            artifact_path,
            artifact_version: None,
            checksum_sha256,
            chunk_size: None,
            content_type: None,
            package_description: None,
            package_metadata: None,
            repository_key,
            total_size,
        }
    }
}

