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

/// CrashReport : A stored crash report.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CrashReport {
    #[serde(rename = "app_version")]
    pub app_version: String,
    #[serde(rename = "component")]
    pub component: String,
    #[serde(rename = "context")]
    pub context: serde_json::Value,
    #[serde(rename = "created_at")]
    pub created_at: String,
    #[serde(rename = "error_message")]
    pub error_message: String,
    #[serde(rename = "error_signature")]
    pub error_signature: String,
    #[serde(rename = "error_type")]
    pub error_type: String,
    #[serde(rename = "first_seen_at")]
    pub first_seen_at: String,
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    #[serde(rename = "last_seen_at")]
    pub last_seen_at: String,
    #[serde(rename = "occurrence_count")]
    pub occurrence_count: i32,
    #[serde(rename = "os_info", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub os_info: Option<Option<String>>,
    #[serde(rename = "severity")]
    pub severity: String,
    #[serde(rename = "stack_trace", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub stack_trace: Option<Option<String>>,
    #[serde(rename = "submission_error", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub submission_error: Option<Option<String>>,
    #[serde(rename = "submitted")]
    pub submitted: bool,
    #[serde(rename = "submitted_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub submitted_at: Option<Option<String>>,
    #[serde(rename = "uptime_seconds", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub uptime_seconds: Option<Option<i64>>,
}

impl CrashReport {
    /// A stored crash report.
    pub fn new(app_version: String, component: String, context: serde_json::Value, created_at: String, error_message: String, error_signature: String, error_type: String, first_seen_at: String, id: uuid::Uuid, last_seen_at: String, occurrence_count: i32, severity: String, submitted: bool) -> CrashReport {
        CrashReport {
            app_version,
            component,
            context,
            created_at,
            error_message,
            error_signature,
            error_type,
            first_seen_at,
            id,
            last_seen_at,
            occurrence_count,
            os_info: None,
            severity,
            stack_trace: None,
            submission_error: None,
            submitted,
            submitted_at: None,
            uptime_seconds: None,
        }
    }
}

