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

/// UpsertScanConfigRequest : Request to create or update a scan configuration.  Every field is optional so a `PUT /repositories/{key}/security` can carry any subset of mutable columns; fields the client omits keep their existing value (or fall back to the documented default when the row does not exist yet). The previous shape required all of `scan_enabled`, `scan_on_upload`, `scan_on_proxy`, `block_on_policy_violation`, `severity_threshold` on every call. That was the #1374 bug class on a second entity: a partial PUT (for example just `{scan_enabled: true}`) either bounced as a 422 or, worse, silently reset every other column to its default so a follow-up GET showed the untouched fields stale. The upsert is now a read-modify-write that merges the patch over the existing row, so multiple fields persist together and an omitted field is never clobbered. See #1374 / B11.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct UpsertScanConfigRequest {
    #[serde(rename = "block_on_policy_violation", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub block_on_policy_violation: Option<Option<bool>>,
    #[serde(rename = "scan_enabled", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub scan_enabled: Option<Option<bool>>,
    #[serde(rename = "scan_on_proxy", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub scan_on_proxy: Option<Option<bool>>,
    #[serde(rename = "scan_on_upload", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub scan_on_upload: Option<Option<bool>>,
    #[serde(rename = "severity_threshold", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub severity_threshold: Option<Option<String>>,
}

impl UpsertScanConfigRequest {
    /// Request to create or update a scan configuration.  Every field is optional so a `PUT /repositories/{key}/security` can carry any subset of mutable columns; fields the client omits keep their existing value (or fall back to the documented default when the row does not exist yet). The previous shape required all of `scan_enabled`, `scan_on_upload`, `scan_on_proxy`, `block_on_policy_violation`, `severity_threshold` on every call. That was the #1374 bug class on a second entity: a partial PUT (for example just `{scan_enabled: true}`) either bounced as a 422 or, worse, silently reset every other column to its default so a follow-up GET showed the untouched fields stale. The upsert is now a read-modify-write that merges the patch over the existing row, so multiple fields persist together and an omitted field is never clobbered. See #1374 / B11.
    pub fn new() -> UpsertScanConfigRequest {
        UpsertScanConfigRequest {
            block_on_policy_violation: None,
            scan_enabled: None,
            scan_on_proxy: None,
            scan_on_upload: None,
            severity_threshold: None,
        }
    }
}

