/*
 * 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 MigrationJobRow {
    #[serde(rename = "completed_items")]
    pub completed_items: i32,
    #[serde(rename = "config")]
    pub config: serde_json::Value,
    #[serde(rename = "created_at")]
    pub created_at: String,
    #[serde(rename = "created_by", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub created_by: Option<Option<uuid::Uuid>>,
    #[serde(rename = "error_summary", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub error_summary: Option<Option<String>>,
    #[serde(rename = "failed_items")]
    pub failed_items: i32,
    #[serde(rename = "finished_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub finished_at: Option<Option<String>>,
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    #[serde(rename = "job_type")]
    pub job_type: String,
    #[serde(rename = "skipped_items")]
    pub skipped_items: i32,
    #[serde(rename = "source_connection_id")]
    pub source_connection_id: uuid::Uuid,
    #[serde(rename = "started_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub started_at: Option<Option<String>>,
    #[serde(rename = "status")]
    pub status: String,
    #[serde(rename = "total_bytes")]
    pub total_bytes: i64,
    #[serde(rename = "total_items")]
    pub total_items: i32,
    #[serde(rename = "transferred_bytes")]
    pub transferred_bytes: i64,
}

impl MigrationJobRow {
    pub fn new(completed_items: i32, config: serde_json::Value, created_at: String, failed_items: i32, id: uuid::Uuid, job_type: String, skipped_items: i32, source_connection_id: uuid::Uuid, status: String, total_bytes: i64, total_items: i32, transferred_bytes: i64) -> MigrationJobRow {
        MigrationJobRow {
            completed_items,
            config,
            created_at,
            created_by: None,
            error_summary: None,
            failed_items,
            finished_at: None,
            id,
            job_type,
            skipped_items,
            source_connection_id,
            started_at: None,
            status,
            total_bytes,
            total_items,
            transferred_bytes,
        }
    }
}

